Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XenServer: Minor changes and fixes in xenserver_guest #55678

Merged
merged 2 commits into from May 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,6 @@
minor_changes:
- xenserver_guest - wait_for_ip_address is now ignored when state=absent (https://github.com/ansible/ansible/issues/55348).

bugfixes:
- xenserver_guest - proper error message is shown when maximum number of network interfaces is reached and multiple network interfaces are added at once.
- xenserver_guest - fixed an issue where VM whould be powered off even though check mode is used if reconfiguration requires VM to be powered off.
15 changes: 8 additions & 7 deletions lib/ansible/modules/cloud/xenserver/xenserver_guest.py
Expand Up @@ -169,7 +169,7 @@
type: list
wait_for_ip_address:
description:
- Wait until XenServer detects an IP address for the VM.
- Wait until XenServer detects an IP address for the VM. If C(state) is set to C(absent), this parameter is ignored.
- This requires XenServer Tools to be preinstalled on the VM to work properly.
type: bool
default: no
Expand Down Expand Up @@ -597,16 +597,16 @@ def reconfigure(self):

vm_power_state_save = self.vm_params['power_state'].lower()

if "need_poweredoff" in config_changes and vm_power_state_save != 'halted':
if self.module.params['force']:
self.set_power_state("shutdownguest")
else:
self.module.fail_json(msg="VM reconfigure: VM has to be in powered off state to reconfigure but force was not specified!")
if "need_poweredoff" in config_changes and vm_power_state_save != 'halted' and not self.module.params['force']:
self.module.fail_json(msg="VM reconfigure: VM has to be in powered off state to reconfigure but force was not specified!")

# Support for Ansible check mode.
if self.module.check_mode:
return config_changes

if "need_poweredoff" in config_changes and vm_power_state_save != 'halted' and self.module.params['force']:
self.set_power_state("shutdownguest")

try:
for change in config_changes:
if isinstance(change, six.string_types):
Expand Down Expand Up @@ -1632,6 +1632,7 @@ def get_changes(self):
if vif_device not in vif_devices_allowed:
self.module.fail_json(msg="VM check networks[%s]: new network interface position %s is out of bounds!" % (position, vif_device))

vif_devices_allowed.remove(vif_device)
vif_device_highest = vif_device

# For new VIFs we only track their position.
Expand Down Expand Up @@ -1911,7 +1912,7 @@ def main():
vm.deploy()
result['changed'] = True

if module.params['wait_for_ip_address']:
if module.params['wait_for_ip_address'] and module.params['state'] != "absent":
vm.wait_for_ip_address()

result['instance'] = vm.gather_facts()
Expand Down