1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

cloud: ovirt: Fix upgraded state of the ovirt_hosts module (#25169)

This commit is contained in:
Ondra Machacek 2017-06-08 22:58:54 +02:00 committed by Ryan Brown
parent c17efa4aaa
commit d7b3ace0b0

View file

@ -179,6 +179,7 @@ host:
type: dict type: dict
''' '''
import time
import traceback import traceback
try: try:
@ -309,6 +310,8 @@ def control_state(host_module):
fail_condition=failed_state, fail_condition=failed_state,
) )
return host
def main(): def main():
argument_spec = ovirt_full_argument_spec( argument_spec = ovirt_full_argument_spec(
@ -351,7 +354,7 @@ def main():
) )
state = module.params['state'] state = module.params['state']
control_state(hosts_module) host = control_state(hosts_module)
if state == 'present': if state == 'present':
hosts_module.create( hosts_module.create(
deploy_hosted_engine=( deploy_hosted_engine=(
@ -375,10 +378,12 @@ def main():
) )
ret = hosts_module.create() ret = hosts_module.create()
elif state == 'upgraded': elif state == 'upgraded':
result_state = hoststate.MAINTENANCE if host.status == hoststate.MAINTENANCE else hoststate.UP
ret = hosts_module.action( ret = hosts_module.action(
action='upgrade', action='upgrade',
action_condition=lambda h: h.update_available, 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, fail_condition=failed_state,
) )
elif state == 'started': elif state == 'started':