From 798f89c2e5a8d404d510810f806cdb818ddf4064 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Tue, 2 Dec 2014 08:18:00 -0600 Subject: [PATCH] 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. --- .../modules/extras/cloud/lxc/lxc-container.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/extras/cloud/lxc/lxc-container.py b/lib/ansible/modules/extras/cloud/lxc/lxc-container.py index b72890972db..6df27867267 100644 --- a/lib/ansible/modules/extras/cloud/lxc/lxc-container.py +++ b/lib/ansible/modules/extras/cloud/lxc/lxc-container.py @@ -1015,9 +1015,12 @@ class LxcContainerManagement(object): :returns: size and measurement of an LV :type: ``tuple`` """ + build_command = [ 'vgdisplay', - name + name, + '--units', + 'g' ] rc, stdout, err = self._run_command(build_command) if rc != 0: @@ -1041,11 +1044,14 @@ class LxcContainerManagement(object): :returns: size and measurement of an LV :type: ``tuple`` """ + vg = self._get_lxc_vg() lv = os.path.join(vg, name) build_command = [ 'lvdisplay', - lv + lv, + '--units', + 'g' ] rc, stdout, err = self._run_command(build_command) if rc != 0: @@ -1072,6 +1078,7 @@ class LxcContainerManagement(object): :param snapshot_size_gb: Size of snapshot to create :type snapshot_size_gb: ``int`` """ + vg = self._get_lxc_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. :type mount_point: ``str`` """ + vg = self._get_lxc_vg() build_command = [ @@ -1181,6 +1189,7 @@ class LxcContainerManagement(object): :param name: The name of the logical volume :type name: ``str`` """ + vg = self._get_lxc_vg() build_command = [ self.module.get_bin_path('lvremove', True), @@ -1204,6 +1213,7 @@ class LxcContainerManagement(object): :param temp_dir: path to the temporary local working directory :type temp_dir: ``str`` """ + build_command = [ self.module.get_bin_path('rsync', True), '-aHAX', @@ -1225,6 +1235,7 @@ class LxcContainerManagement(object): :param mount_point: path on the file system that is mounted. :type mount_point: ``str`` """ + build_command = [ self.module.get_bin_path('umount', True), mount_point,