summaryrefslogtreecommitdiff
path: root/openstackclient/compute/v2/server.py
diff options
context:
space:
mode:
authorPavlo Shchelokovskyy <shchelokovskyy@gmail.com>2023-05-15 11:25:31 +0000
committerPavlo Shchelokovskyy <pshchelokovskyy@mirantis.com>2023-05-17 11:38:37 +0000
commit417a7ad2039c09adbd497392c0199b7667e65ef7 (patch)
tree73f4b84f4e4f5d539163a1fb540a80ce77c4d98f /openstackclient/compute/v2/server.py
parent3c9afe69bbb249b30e586fd0f8b3dd095d2cab48 (diff)
downloadpython-openstackclient-417a7ad2039c09adbd497392c0199b7667e65ef7.tar.gz
Allow server rebuild --wait for SHUTOFF servers
currently the command is waiting only for ACTIVE server status, but if the server was SHUTOFF before, it will be SHUTOFF after rebuild as well, so the command is stuck in waiting forever. Additionally, we now also pre-validate the server status on client side, and raise an error if the server to be rebuilt is not in ACTIVE, ERROR or SHUTOFF state. Change-Id: If90a4bbba9a7ecd972f8b594c52fee4f75a0ae5e Co-Authored-By: Oleksiy Molchanov <omolchanov@mirantis.com> Story: 2010751 Task: 48005
Diffstat (limited to 'openstackclient/compute/v2/server.py')
-rw-r--r--openstackclient/compute/v2/server.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py
index cde4ab05..73d66d19 100644
--- a/openstackclient/compute/v2/server.py
+++ b/openstackclient/compute/v2/server.py
@@ -3536,6 +3536,15 @@ class RebuildServer(command.ShowOne):
'future release.'
)
+ status = getattr(server, 'status', '').lower()
+ if status == 'shutoff':
+ success_status = ['shutoff']
+ elif status in ('error', 'active'):
+ success_status = ['active']
+ else:
+ msg = _("The server status is not ACTIVE, SHUTOFF or ERROR.")
+ raise exceptions.CommandError(msg)
+
try:
server = server.rebuild(image, parsed_args.password, **kwargs)
finally:
@@ -3547,6 +3556,7 @@ class RebuildServer(command.ShowOne):
compute_client.servers.get,
server.id,
callback=_show_progress,
+ success_status=success_status,
):
self.app.stdout.write(_('Complete\n'))
else: