XenServer: Minor bug fixes 2 (#54697)

- xenserver module_util: fixed comment in set_vm_power_state().
 - xenserver module_util: renamed cdrom.iso VM fact to cdrom.iso_name
   in gather_vm_facts() to be in line with module parameter of same name.
 - xenserver module_util: sorted IPv6 addresses by their OS index
   in gather_vm_facts().
 - xenserver_guest module: fixed a bug in deploy() where an error message
   would not be shown when VM name is empty and check mode is used.
 - xenserver_guest module: fixed a bug in destroy() where VM would be
   shut down by error when check mode is used.
 - xenserver_guest module: fixed a bug in get_changes() where wrong
   out-of-bound disk position would be shown in error message when
   CD-ROM device occupies last position.
 - xenserver_guest module: assume value "none" for "networks.type" and
   "networks.type6" module parameters in get_changes() when no value is
   found in xenstore_data (custom customization agent).
 - xenserver_guest module: added separate error message in get_changes()
   for a case when maximum number of network interfaces is reached.
 - xenserver_guest module: negative value for disk size in
   get_normalized_disk_size() now properly shows an error.
This commit is contained in:
Bojan Vitnik 2019-04-08 18:27:02 +02:00 committed by ansibot
parent a0fade797b
commit b27c4caa49
2 changed files with 24 additions and 16 deletions

View file

@ -478,7 +478,7 @@ def gather_vm_facts(module, vm_params):
vm_facts['cdrom'].update(type="none")
else:
vm_facts['cdrom'].update(type="iso")
vm_facts['cdrom'].update(iso=vm_vbd_params['VDI']['name_label'])
vm_facts['cdrom'].update(iso_name=vm_vbd_params['VDI']['name_label'])
for vm_vif_params in vm_params['VIFs']:
vm_guest_metrics_networks = vm_params['guest_metrics'].get('networks', {})
@ -492,7 +492,8 @@ def gather_vm_facts(module, vm_params):
"prefix": "",
"netmask": "",
"gateway": "",
"ip6": [vm_guest_metrics_networks[ipv6] for ipv6 in vm_guest_metrics_networks.keys() if ipv6.startswith("%s/ipv6/" % vm_vif_params['device'])],
"ip6": [vm_guest_metrics_networks[ipv6] for ipv6 in sorted(vm_guest_metrics_networks.keys()) if ipv6.startswith("%s/ipv6/" %
vm_vif_params['device'])],
"prefix6": "",
"gateway6": "",
}
@ -575,7 +576,7 @@ def set_vm_power_state(module, vm_ref, power_state, timeout=300):
# hard_shutdown will halt VM regardless of current state.
xapi_session.xenapi.VM.hard_shutdown(vm_ref)
elif power_state == "restarted":
# hard_restart will restart VM only if VM is in paused or running state.
# hard_reboot will restart VM only if VM is in paused or running state.
if vm_power_state_current in ["paused", "poweredon"]:
if not module.check_mode:
xapi_session.xenapi.VM.hard_reboot(vm_ref)