Updated volume create methods for a more consistent process

The volume create methods were making an assumption on the unit
sizes being presented by the `vgdisplay` and the `lvdisplay`
commands. To correct the assumption the commands will now enforce
a unit size of "g" which will alway convert sives to gigabytes.
This was an issue brought up by @hughsaunders.
pull/18777/head
Kevin Carter 10 years ago committed by Matt Clay
parent e5b0c1ced5
commit 798f89c2e5

@ -1015,9 +1015,12 @@ class LxcContainerManagement(object):
:returns: size and measurement of an LV :returns: size and measurement of an LV
:type: ``tuple`` :type: ``tuple``
""" """
build_command = [ build_command = [
'vgdisplay', 'vgdisplay',
name name,
'--units',
'g'
] ]
rc, stdout, err = self._run_command(build_command) rc, stdout, err = self._run_command(build_command)
if rc != 0: if rc != 0:
@ -1041,11 +1044,14 @@ class LxcContainerManagement(object):
:returns: size and measurement of an LV :returns: size and measurement of an LV
:type: ``tuple`` :type: ``tuple``
""" """
vg = self._get_lxc_vg() vg = self._get_lxc_vg()
lv = os.path.join(vg, name) lv = os.path.join(vg, name)
build_command = [ build_command = [
'lvdisplay', 'lvdisplay',
lv lv,
'--units',
'g'
] ]
rc, stdout, err = self._run_command(build_command) rc, stdout, err = self._run_command(build_command)
if rc != 0: if rc != 0:
@ -1072,6 +1078,7 @@ class LxcContainerManagement(object):
:param snapshot_size_gb: Size of snapshot to create :param snapshot_size_gb: Size of snapshot to create
:type snapshot_size_gb: ``int`` :type snapshot_size_gb: ``int``
""" """
vg = self._get_lxc_vg() vg = self._get_lxc_vg()
free_space, messurement = self._get_vg_free_pe(name=vg) free_space, messurement = self._get_vg_free_pe(name=vg)
@ -1112,6 +1119,7 @@ class LxcContainerManagement(object):
:param mount_point: path on the file system that is mounted. :param mount_point: path on the file system that is mounted.
:type mount_point: ``str`` :type mount_point: ``str``
""" """
vg = self._get_lxc_vg() vg = self._get_lxc_vg()
build_command = [ build_command = [
@ -1181,6 +1189,7 @@ class LxcContainerManagement(object):
:param name: The name of the logical volume :param name: The name of the logical volume
:type name: ``str`` :type name: ``str``
""" """
vg = self._get_lxc_vg() vg = self._get_lxc_vg()
build_command = [ build_command = [
self.module.get_bin_path('lvremove', True), self.module.get_bin_path('lvremove', True),
@ -1204,6 +1213,7 @@ class LxcContainerManagement(object):
:param temp_dir: path to the temporary local working directory :param temp_dir: path to the temporary local working directory
:type temp_dir: ``str`` :type temp_dir: ``str``
""" """
build_command = [ build_command = [
self.module.get_bin_path('rsync', True), self.module.get_bin_path('rsync', True),
'-aHAX', '-aHAX',
@ -1225,6 +1235,7 @@ class LxcContainerManagement(object):
:param mount_point: path on the file system that is mounted. :param mount_point: path on the file system that is mounted.
:type mount_point: ``str`` :type mount_point: ``str``
""" """
build_command = [ build_command = [
self.module.get_bin_path('umount', True), self.module.get_bin_path('umount', True),
mount_point, mount_point,

Loading…
Cancel
Save