From d7b3ace0b0f773e801a2f4969cee4090084d299d Mon Sep 17 00:00:00 2001 From: Ondra Machacek Date: Thu, 8 Jun 2017 22:58:54 +0200 Subject: [PATCH] cloud: ovirt: Fix upgraded state of the ovirt_hosts module (#25169) --- lib/ansible/modules/cloud/ovirt/ovirt_hosts.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_hosts.py b/lib/ansible/modules/cloud/ovirt/ovirt_hosts.py index 8a573a3294..420b0e5261 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_hosts.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_hosts.py @@ -179,6 +179,7 @@ host: type: dict ''' +import time import traceback try: @@ -309,6 +310,8 @@ def control_state(host_module): fail_condition=failed_state, ) + return host + def main(): argument_spec = ovirt_full_argument_spec( @@ -351,7 +354,7 @@ def main(): ) state = module.params['state'] - control_state(hosts_module) + host = control_state(hosts_module) if state == 'present': hosts_module.create( deploy_hosted_engine=( @@ -375,10 +378,12 @@ def main(): ) ret = hosts_module.create() elif state == 'upgraded': + result_state = hoststate.MAINTENANCE if host.status == hoststate.MAINTENANCE else hoststate.UP ret = hosts_module.action( action='upgrade', action_condition=lambda h: h.update_available, - wait_condition=lambda h: h.status == hoststate.UP, + wait_condition=lambda h: h.status == result_state, + post_action=lambda h: time.sleep(module.params['poll_interval']), fail_condition=failed_state, ) elif state == 'started':