self.vg_name = vg_name
self.pv_list = []
self.lv_list = []
- self.vg_size = 0
- self.vg_free_space = 0
+ self.vg_size = 0.0
+ self.vg_free_space = 0.0
self.vg_lv_count = 0
self.vg_uuid = None
self.vg_thin_pool = None
- self.vg_thin_pool_size = 0
- self.vg_thin_pool_free_space = 0
+ self.vg_thin_pool_size = 0.0
+ self.vg_thin_pool_free_space = 0.0
self._supports_snapshot_lv_activation = None
self._supports_lvchange_ignoreskipactivation = None
:param vg_name: the vg where the pool is placed
:param thin_pool_name: the thin pool to gather info for
- :returns: Free space, calculated after the data_percent value
+ :returns: Free space in GB (float), calculated using data_percent
"""
cmd = ['env', 'LC_ALL=C', 'lvs', '--noheadings', '--unit=g',
# make sure to append the actual thin pool name
cmd.append("/dev/%s/%s" % (vg_name, thin_pool_name))
- free_space = 0
+ free_space = 0.0
try:
(out, err) = self._execute(*cmd,
return self._supports_lvchange_ignoreskipactivation
@staticmethod
- def get_all_volumes(root_helper, vg_name=None, no_suffix=True):
+ def get_all_volumes(root_helper, vg_name=None):
"""Static method to get all LV's on a system.
:param root_helper: root_helper to use for execute
:param vg_name: optional, gathers info for only the specified VG
- :param no_suffix: optional, reports sizes in g with no suffix
:returns: List of Dictionaries with LV info
"""
- cmd = ['env', 'LC_ALL=C', 'lvs', '--noheadings', '--unit=g',
- '-o', 'vg_name,name,size']
- if no_suffix:
- cmd.append('--nosuffix')
+ cmd = ['env', 'LC_ALL=C', 'lvs', '--noheadings', '--unit=g',
+ '-o', 'vg_name,name,size', '--nosuffix']
if vg_name is not None:
cmd.append(vg_name)
return r
@staticmethod
- def get_all_physical_volumes(root_helper, vg_name=None, no_suffix=True):
+ def get_all_physical_volumes(root_helper, vg_name=None):
"""Static method to get all PVs on a system.
:param root_helper: root_helper to use for execute
:param vg_name: optional, gathers info for only the specified VG
- :param no_suffix: optional, reports sizes in g with no suffix
:returns: List of Dictionaries with PV info
"""
cmd = ['env', 'LC_ALL=C', 'pvs', '--noheadings',
'--unit=g',
'-o', 'vg_name,name,size,free',
- '--separator', ':']
- if no_suffix:
- cmd.append('--nosuffix')
+ '--separator', ':',
+ '--nosuffix']
(out, err) = putils.execute(*cmd,
root_helper=root_helper,
return self.pv_list
@staticmethod
- def get_all_volume_groups(root_helper, vg_name=None, no_suffix=True):
+ def get_all_volume_groups(root_helper, vg_name=None):
"""Static method to get all VGs on a system.
:param root_helper: root_helper to use for execute
:param vg_name: optional, gathers info for only the specified VG
- :param no_suffix: optional, reports sizes in g with no suffix
:returns: List of Dictionaries with VG info
"""
cmd = ['env', 'LC_ALL=C', 'vgs', '--noheadings', '--unit=g',
- '-o', 'name,size,free,lv_count,uuid', '--separator', ':']
-
- if no_suffix:
- cmd.append('--nosuffix')
+ '-o', 'name,size,free,lv_count,uuid', '--separator', ':',
+ '--nosuffix']
if vg_name is not None:
cmd.append(vg_name)
for vg in vgs:
fields = vg.split(':')
vg_list.append({'name': fields[0],
- 'size': fields[1],
- 'available': fields[2],
- 'lv_count': fields[3],
+ 'size': float(fields[1]),
+ 'available': float(fields[2]),
+ 'lv_count': int(fields[3]),
'uuid': fields[4]})
return vg_list
LOG.error(_('Unable to find VG: %s') % self.vg_name)
raise exception.VolumeGroupNotFound(vg_name=self.vg_name)
- self.vg_size = vg_list[0]['size']
- self.vg_free_space = vg_list[0]['available']
- self.vg_lv_count = vg_list[0]['lv_count']
+ self.vg_size = float(vg_list[0]['size'])
+ self.vg_free_space = float(vg_list[0]['available'])
+ self.vg_lv_count = int(vg_list[0]['lv_count'])
self.vg_uuid = vg_list[0]['uuid']
if self.vg_thin_pool is not None:
if name is None:
name = '%s-pool' % self.vg_name
- self.vg_pool_name = '%s/%s' % (self.vg_name, name)
+ vg_pool_name = '%s/%s' % (self.vg_name, name)
if not size_str:
size_str = self._calculate_thin_pool_size()
- cmd = ['lvcreate', '-T', '-L', size_str, self.vg_pool_name]
+ cmd = ['lvcreate', '-T', '-L', size_str, vg_pool_name]
self._execute(*cmd,
root_helper=self._root_helper,