Fix actions and wait in os_server_action module (#43504)
* Fix call to sdk.iterate_timeout in os_server_action
* Correct indentation for several actions in os_server_action
(cherry picked from commit d5662df695
)
This commit is contained in:
parent
0730eae41b
commit
c5b49fe4a3
1 changed files with 19 additions and 19 deletions
|
@ -94,7 +94,7 @@ def _action_url(server_id):
|
||||||
def _wait(timeout, cloud, server, action, module, sdk):
|
def _wait(timeout, cloud, server, action, module, sdk):
|
||||||
"""Wait for the server to reach the desired state for the given action."""
|
"""Wait for the server to reach the desired state for the given action."""
|
||||||
|
|
||||||
for count in sdk.utils._iterate_timeout(
|
for count in sdk.utils.iterate_timeout(
|
||||||
timeout,
|
timeout,
|
||||||
"Timeout waiting for server to complete %s" % action):
|
"Timeout waiting for server to complete %s" % action):
|
||||||
try:
|
try:
|
||||||
|
@ -163,9 +163,9 @@ def main():
|
||||||
if not _system_state_change(action, status):
|
if not _system_state_change(action, status):
|
||||||
module.exit_json(changed=False)
|
module.exit_json(changed=False)
|
||||||
|
|
||||||
cloud.compute.post(
|
cloud.compute.post(
|
||||||
_action_url(server.id),
|
_action_url(server.id),
|
||||||
json={'os-start': None})
|
json={'os-start': None})
|
||||||
if wait:
|
if wait:
|
||||||
_wait(timeout, cloud, server, action, module, sdk)
|
_wait(timeout, cloud, server, action, module, sdk)
|
||||||
module.exit_json(changed=True)
|
module.exit_json(changed=True)
|
||||||
|
@ -174,9 +174,9 @@ def main():
|
||||||
if not _system_state_change(action, status):
|
if not _system_state_change(action, status):
|
||||||
module.exit_json(changed=False)
|
module.exit_json(changed=False)
|
||||||
|
|
||||||
cloud.compute.post(
|
cloud.compute.post(
|
||||||
_action_url(server.id),
|
_action_url(server.id),
|
||||||
json={'pause': None})
|
json={'pause': None})
|
||||||
if wait:
|
if wait:
|
||||||
_wait(timeout, cloud, server, action, module, sdk)
|
_wait(timeout, cloud, server, action, module, sdk)
|
||||||
module.exit_json(changed=True)
|
module.exit_json(changed=True)
|
||||||
|
@ -185,9 +185,9 @@ def main():
|
||||||
if not _system_state_change(action, status):
|
if not _system_state_change(action, status):
|
||||||
module.exit_json(changed=False)
|
module.exit_json(changed=False)
|
||||||
|
|
||||||
cloud.compute.post(
|
cloud.compute.post(
|
||||||
_action_url(server.id),
|
_action_url(server.id),
|
||||||
json={'unpause': None})
|
json={'unpause': None})
|
||||||
if wait:
|
if wait:
|
||||||
_wait(timeout, cloud, server, action, module, sdk)
|
_wait(timeout, cloud, server, action, module, sdk)
|
||||||
module.exit_json(changed=True)
|
module.exit_json(changed=True)
|
||||||
|
@ -210,9 +210,9 @@ def main():
|
||||||
if not _system_state_change(action, status):
|
if not _system_state_change(action, status):
|
||||||
module.exit_json(changed=False)
|
module.exit_json(changed=False)
|
||||||
|
|
||||||
cloud.compute.post(
|
cloud.compute.post(
|
||||||
_action_url(server.id),
|
_action_url(server.id),
|
||||||
json={'suspend': None})
|
json={'suspend': None})
|
||||||
if wait:
|
if wait:
|
||||||
_wait(timeout, cloud, server, action, module, sdk)
|
_wait(timeout, cloud, server, action, module, sdk)
|
||||||
module.exit_json(changed=True)
|
module.exit_json(changed=True)
|
||||||
|
@ -221,9 +221,9 @@ def main():
|
||||||
if not _system_state_change(action, status):
|
if not _system_state_change(action, status):
|
||||||
module.exit_json(changed=False)
|
module.exit_json(changed=False)
|
||||||
|
|
||||||
cloud.compute.post(
|
cloud.compute.post(
|
||||||
_action_url(server.id),
|
_action_url(server.id),
|
||||||
json={'resume': None})
|
json={'resume': None})
|
||||||
if wait:
|
if wait:
|
||||||
_wait(timeout, cloud, server, action, module, sdk)
|
_wait(timeout, cloud, server, action, module, sdk)
|
||||||
module.exit_json(changed=True)
|
module.exit_json(changed=True)
|
||||||
|
@ -235,9 +235,9 @@ def main():
|
||||||
module.fail_json(msg="Image does not exist")
|
module.fail_json(msg="Image does not exist")
|
||||||
|
|
||||||
# rebuild doesn't set a state, just do it
|
# rebuild doesn't set a state, just do it
|
||||||
cloud.compute.post(
|
cloud.compute.post(
|
||||||
_action_url(server.id),
|
_action_url(server.id),
|
||||||
json={'rebuild': None})
|
json={'rebuild': None})
|
||||||
if wait:
|
if wait:
|
||||||
_wait(timeout, cloud, server, action, module, sdk)
|
_wait(timeout, cloud, server, action, module, sdk)
|
||||||
module.exit_json(changed=True)
|
module.exit_json(changed=True)
|
||||||
|
|
Loading…
Reference in a new issue