Merge pull request #3722 from bcoca/lvg_gets_bin_path
now uses get_bin_path for lvg executables
This commit is contained in:
commit
7f77b6c72e
1 changed files with 18 additions and 8 deletions
|
@ -116,6 +116,8 @@ def main():
|
||||||
elif state == 'present':
|
elif state == 'present':
|
||||||
module.fail_json(msg="No physical volumes given.")
|
module.fail_json(msg="No physical volumes given.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if state=='present':
|
if state=='present':
|
||||||
### check given devices
|
### check given devices
|
||||||
for test_dev in dev_list:
|
for test_dev in dev_list:
|
||||||
|
@ -123,7 +125,8 @@ def main():
|
||||||
module.fail_json(msg="Device %s not found."%test_dev)
|
module.fail_json(msg="Device %s not found."%test_dev)
|
||||||
|
|
||||||
### get pv list
|
### 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:
|
if rc != 0:
|
||||||
module.fail_json(msg="Failed executing pvs command.",rc=rc, err=err)
|
module.fail_json(msg="Failed executing pvs command.",rc=rc, err=err)
|
||||||
|
|
||||||
|
@ -133,7 +136,8 @@ def main():
|
||||||
if used_pvs:
|
if used_pvs:
|
||||||
module.fail_json(msg="Device %s is already in %s volume group."%(used_pvs[0]['name'],used_pvs[0]['vg_name']))
|
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:
|
if rc != 0:
|
||||||
module.fail_json(msg="Failed executing vgs command.",rc=rc, err=err)
|
module.fail_json(msg="Failed executing vgs command.",rc=rc, err=err)
|
||||||
|
@ -156,13 +160,15 @@ def main():
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
### create PV
|
### create PV
|
||||||
|
pvcreate_cmd = module.get_bin_path('pvcreate', True)
|
||||||
for current_dev in dev_list:
|
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:
|
if rc == 0:
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg="Creating physical volume '%s' failed"%current_dev, rc=rc, err=err)
|
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:
|
if rc == 0:
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
|
@ -174,7 +180,8 @@ def main():
|
||||||
else:
|
else:
|
||||||
if this_vg['lv_count'] == 0 or force:
|
if this_vg['lv_count'] == 0 or force:
|
||||||
### remove VG
|
### 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:
|
if rc == 0:
|
||||||
module.exit_json(changed=True)
|
module.exit_json(changed=True)
|
||||||
else:
|
else:
|
||||||
|
@ -194,14 +201,16 @@ def main():
|
||||||
if devs_to_add:
|
if devs_to_add:
|
||||||
devs_to_add_string = ' '.join(devs_to_add)
|
devs_to_add_string = ' '.join(devs_to_add)
|
||||||
### create PV
|
### create PV
|
||||||
|
pvcreate_cmd = module.get_bin_path('pvcreate', True)
|
||||||
for current_dev in devs_to_add:
|
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:
|
if rc == 0:
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg="Creating physical volume '%s' failed"%current_dev, rc=rc, err=err)
|
module.fail_json(msg="Creating physical volume '%s' failed"%current_dev, rc=rc, err=err)
|
||||||
### add PV to our VG
|
### 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("%s %s %s"%(vgextend_cmd, vg, devs_to_add_string))
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
|
@ -210,7 +219,8 @@ def main():
|
||||||
### remove some PV from our VG
|
### remove some PV from our VG
|
||||||
if devs_to_remove:
|
if devs_to_remove:
|
||||||
devs_to_remove_string = ' '.join(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:
|
if rc == 0:
|
||||||
changed = True
|
changed = True
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue