Fixing KVM VM mgmt scenarios (contd.)

master
Sergey Shubin svs1370 5 years ago
parent 9a2c909961
commit f0c6c432d5

@ -628,6 +628,7 @@ class decort_kvmvm(DecortController):
disk_size=0,
data_disks=[], # IDs of attached data disks; this list can be emty
state="CHECK_MODE",
tech_status="",
account_id=0,
rg_id=0,
username="",
@ -649,6 +650,7 @@ class decort_kvmvm(DecortController):
ret_dict['name'] = self.comp_info['name']
ret_dict['arch'] = self.comp_info['arch']
ret_dict['state'] = self.comp_info['status']
ret_dict['tech_status'] = self.comp_info['techStatus']
ret_dict['account_id'] = self.comp_info['accountId']
ret_dict['rg_id'] = self.comp_info['rgId']
# if the VM is an imported VM, then the 'accounts' list may be empty,
@ -792,9 +794,9 @@ def main():
if subj.comp_id:
# Compute is found - package facts and report success to Ansible
subj.result['failed'] = False
subj.comp_info = subj.compute_find(comp_id=subj.comp_id)
_, rg_facts = subj.rg_find(rg_id=subj.rg_id)
subj.result['facts'] = subj.package_facts(rg_facts, amodule.check_mode)
# _, subj.comp_info, _ = subj.compute_find(comp_id=subj.comp_id)
# _, rg_facts = subj.rg_find(arg_account_id=0, arg_rg_id=subj.rg_id)
subj.result['facts'] = subj.package_facts(amodule.check_mode)
amodule.exit_json(**subj.result)
# we exit the module at this point
else:

@ -685,7 +685,7 @@ class DecortController(object):
return
powerstate_api = "" # this string will also be used as a flag to indicate that API call is necessary
api_params = dict(compId=comp_facts['id'])
api_params = dict(computeId=comp_facts['id'])
expected_state = ""
if comp_facts['techStatus'] == "STARTED":
@ -694,7 +694,7 @@ class DecortController(object):
expected_techState = "PAUSED"
elif target_state in ('poweredoff', 'halted', 'stopped'):
powerstate_api = "/restmachine/cloudapi/compute/stop"
params['force'] = force_change
api_params['force'] = force_change
expected_techState = "STOPPED"
elif target_state == 'restarted':
powerstate_api = "/restmachine/cloudapi/compute/reboot"

Loading…
Cancel
Save