From fe57037f84e5dee39c86bf44a2475f59665f4d9a Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 31 Jul 2013 22:32:41 -0400 Subject: [PATCH 1/3] now uses get_bin_path for lvg executables Signed-off-by: Brian Coca --- system/lvg | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/system/lvg b/system/lvg index f302a27441a..893c8ae8bd9 100644 --- a/system/lvg +++ b/system/lvg @@ -116,6 +116,8 @@ def main(): elif state == 'present': module.fail_json(msg="No physical volumes given.") + + if state=='present': ### check given devices for test_dev in dev_list: @@ -123,7 +125,8 @@ def main(): module.fail_json(msg="Device %s not found."%test_dev) ### get pv list - rc,current_pvs,err = module.run_command("pvs --noheadings -o pv_name,vg_name --separator ';'") + pvs_cmd = module.get_bin_path('pvs', True) + rc,current_pvs,err = module.run_command("%s --noheadings -o pv_name,vg_name --separator ';'" % pvs_cmd) if rc != 0: module.fail_json(msg="Failed executing pvs command.",rc=rc, err=err) @@ -133,7 +136,8 @@ def main(): if used_pvs: module.fail_json(msg="Device %s is already in %s volume group."%(used_pvs[0]['name'],used_pvs[0]['vg_name'])) - rc,current_vgs,err = module.run_command("vgs --noheadings -o vg_name,pv_count,lv_count --separator ';'") + vgs_cmd = module.get_bin_path('vgs', True) + rc,current_vgs,err = module.run_command("%s --noheadings -o vg_name,pv_count,lv_count --separator ';'" % vgs_cmd) if rc != 0: module.fail_json(msg="Failed executing vgs command.",rc=rc, err=err) @@ -156,13 +160,15 @@ def main(): changed = True else: ### create PV + pvcreate_cmd = module.get_bin_path('pvcreate',True) for current_dev in dev_list: - rc,_,err = module.run_command("pvcreate %s"%current_dev) + rc,_,err = module.run_command("%s %s"%(pvcreate_cmd,current_dev)) if rc == 0: changed = True else: module.fail_json(msg="Creating physical volume '%s' failed"%current_dev, rc=rc, err=err) - rc,_,err = module.run_command("vgcreate -s %s %s %s"%(pesize, vg, dev_string)) + vgcreate_cmd = module.get_bin_path('vgcreate') + rc,_,err = module.run_command("%s -s %s %s %s"%(vgcreate_cmd, pesize, vg, dev_string)) if rc == 0: changed = True else: @@ -174,7 +180,8 @@ def main(): else: if this_vg['lv_count'] == 0 or force: ### remove VG - rc,_,err = module.run_command("vgremove --force %s"%(vg)) + vgremove_cmd = module.get_bin_path('vgremove',True) + rc,_,err = module.run_command("%s --force %s"%(vgremove_cmd,vg)) if rc == 0: module.exit_json(changed=True) else: @@ -194,14 +201,16 @@ def main(): if devs_to_add: devs_to_add_string = ' '.join(devs_to_add) ### create PV + pvcreate_cmd = module.get_bin_path('pvcreate',True) for current_dev in devs_to_add: - rc,_,err = module.run_command("pvcreate %s"%current_dev) + rc,_,err = module.run_command("%s %s"%(pvcreate_cmd,current_dev)) if rc == 0: changed = True else: module.fail_json(msg="Creating physical volume '%s' failed"%current_dev, rc=rc, err=err) ### add PV to our VG - rc,_,err = module.run_command("vgextend %s %s"%(vg, devs_to_add_string)) + vgextend_cmd = module.get_bin_path('vgextend',True) + rc,_,err = module.run_command("vgextend %s %s"%(vgextend_cmd, vg, devs_to_add_string)) if rc == 0: changed = True else: @@ -210,7 +219,8 @@ def main(): ### remove some PV from our VG if devs_to_remove: devs_to_remove_string = ' '.join(devs_to_remove) - rc,_,err = module.run_command("vgreduce --force %s %s"%(vg, devs_to_remove_string)) + vgreduce_cmd = module.get_bin_path('vgreduce',True) + rc,_,err = module.run_command("%s --force %s %s"%(vgreduce_cmd, vg, devs_to_remove_string)) if rc == 0: changed = True else: From 2c06418f6d09cd6c753f939a344e55beefd0336f Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 31 Jul 2013 23:26:28 -0400 Subject: [PATCH 2/3] whitespace updates on new lines Signed-off-by: Brian Coca --- system/lvg | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/system/lvg b/system/lvg index 893c8ae8bd9..fdbdde55773 100644 --- a/system/lvg +++ b/system/lvg @@ -160,7 +160,7 @@ def main(): changed = True else: ### create PV - pvcreate_cmd = module.get_bin_path('pvcreate',True) + pvcreate_cmd = module.get_bin_path('pvcreate', True) for current_dev in dev_list: rc,_,err = module.run_command("%s %s"%(pvcreate_cmd,current_dev)) if rc == 0: @@ -180,8 +180,8 @@ def main(): else: if this_vg['lv_count'] == 0 or force: ### remove VG - vgremove_cmd = module.get_bin_path('vgremove',True) - rc,_,err = module.run_command("%s --force %s"%(vgremove_cmd,vg)) + vgremove_cmd = module.get_bin_path('vgremove', True) + rc,_,err = module.run_command("%s --force %s" % (vgremove_cmd, vg)) if rc == 0: module.exit_json(changed=True) else: @@ -201,15 +201,15 @@ def main(): if devs_to_add: devs_to_add_string = ' '.join(devs_to_add) ### create PV - pvcreate_cmd = module.get_bin_path('pvcreate',True) + pvcreate_cmd = module.get_bin_path('pvcreate', True) for current_dev in devs_to_add: - rc,_,err = module.run_command("%s %s"%(pvcreate_cmd,current_dev)) + rc,_,err = module.run_command("%s %s" % (pvcreate_cmd, current_dev)) if rc == 0: changed = True else: module.fail_json(msg="Creating physical volume '%s' failed"%current_dev, rc=rc, err=err) ### add PV to our VG - vgextend_cmd = module.get_bin_path('vgextend',True) + vgextend_cmd = module.get_bin_path('vgextend', True) rc,_,err = module.run_command("vgextend %s %s"%(vgextend_cmd, vg, devs_to_add_string)) if rc == 0: changed = True @@ -219,8 +219,8 @@ def main(): ### remove some PV from our VG if devs_to_remove: devs_to_remove_string = ' '.join(devs_to_remove) - vgreduce_cmd = module.get_bin_path('vgreduce',True) - rc,_,err = module.run_command("%s --force %s %s"%(vgreduce_cmd, vg, devs_to_remove_string)) + vgreduce_cmd = module.get_bin_path('vgreduce', True) + rc,_,err = module.run_command("%s --force %s %s" % (vgreduce_cmd, vg, devs_to_remove_string)) if rc == 0: changed = True else: From e8e8779dfa7a822f20c0b3cf0f706cef49667cc2 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 1 Aug 2013 00:24:34 -0400 Subject: [PATCH 3/3] fixed bug from prev update Signed-off-by: Brian Coca --- system/lvg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/lvg b/system/lvg index fdbdde55773..545ab1df5db 100644 --- a/system/lvg +++ b/system/lvg @@ -210,7 +210,7 @@ def main(): module.fail_json(msg="Creating physical volume '%s' failed"%current_dev, rc=rc, err=err) ### add PV to our VG vgextend_cmd = module.get_bin_path('vgextend', True) - rc,_,err = module.run_command("vgextend %s %s"%(vgextend_cmd, vg, devs_to_add_string)) + rc,_,err = module.run_command("%s %s %s"%(vgextend_cmd, vg, devs_to_add_string)) if rc == 0: changed = True else: