Commit 76694f1e authored by Swann Perarnau's avatar Swann Perarnau

[feature] make wait optional on create/delete

Stack create and delete take an option to wait for the operation to
complete. It doesn't actually wait for the operation to complete, just
for the Openstack side of it to be done. For creation for exemple, the
nodes might still be booting.
parent 8db9d2cc
...@@ -51,7 +51,7 @@ def do_create(argv): ...@@ -51,7 +51,7 @@ def do_create(argv):
template = os.path.abspath(argv.template) template = os.path.abspath(argv.template)
try: try:
ret = shade_client.create_stack(argv.name, template_file=template, ret = shade_client.create_stack(argv.name, template_file=template,
wait=True, **extra_args) wait=argv.wait, **extra_args)
print(json.dumps(ret, indent=4)) print(json.dumps(ret, indent=4))
except shade.exc.OpenStackCloudHTTPError as e: except shade.exc.OpenStackCloudHTTPError as e:
print(e) print(e)
...@@ -60,7 +60,7 @@ def do_create(argv): ...@@ -60,7 +60,7 @@ def do_create(argv):
def do_delete(argv): def do_delete(argv):
"""Delete an appliance with <name>.""" """Delete an appliance with <name>."""
shade_client = get_shade_client(argv.region) shade_client = get_shade_client(argv.region)
ret = shade_client.delete_stack(argv.name) ret = shade_client.delete_stack(argv.name, wait=argv.wait)
if ret: if ret:
print("Appliance successfully deleted.") print("Appliance successfully deleted.")
else: else:
...@@ -216,6 +216,8 @@ def main(): ...@@ -216,6 +216,8 @@ def main():
# create a lease # create a lease
parser_create = subparsers.add_parser("create", help="Create an appliance") parser_create = subparsers.add_parser("create", help="Create an appliance")
parser_create.add_argument("--wait", action='store_true',
help="Wait for the operation to complete")
parser_create.add_argument("name", help="Name of the appliance") parser_create.add_argument("name", help="Name of the appliance")
parser_create.add_argument("lease", help="Lease for the appliance") parser_create.add_argument("lease", help="Lease for the appliance")
parser_create.add_argument("template", help="Appliance template") parser_create.add_argument("template", help="Appliance template")
...@@ -225,6 +227,8 @@ def main(): ...@@ -225,6 +227,8 @@ def main():
parser_create.set_defaults(func=do_create) parser_create.set_defaults(func=do_create)
parser_delete = subparsers.add_parser("delete", help="Delete an appliance") parser_delete = subparsers.add_parser("delete", help="Delete an appliance")
parser_delete.add_argument("--wait", action='store_true',
help="Wait for the operation to complete")
parser_delete.add_argument("name", help="Name of the appliance") parser_delete.add_argument("name", help="Name of the appliance")
parser_delete.set_defaults(func=do_delete) parser_delete.set_defaults(func=do_delete)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment