From 3c815a032858cadeba3ba537be3cadf62a9d1ab8 Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 8 May 2018 08:07:59 +0200 Subject: [PATCH 1/2] Add async option in create op --- im_client.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/im_client.py b/im_client.py index afeb8a3..04e6a0e 100755 --- a/im_client.py +++ b/im_client.py @@ -353,6 +353,9 @@ def main(operation, options, args, parser): if not os.path.isfile(args[0]): print("RADL file '" + args[0] + "' does not exist") return False + asyncr = False + if len(args) >= 2: + asyncr = bool(int(args[1])) else: print("RADL file to create inf. not specified") return False @@ -370,6 +373,8 @@ def main(operation, options, args, parser): if options.restapi: headers = {"Authorization": rest_auth_data} url = "%s/infrastructures" % options.restapi + if asyncr: + url += "?async=yes" resp = requests.request("POST", url, verify=options.verify, headers=headers, data=str(radl)) success = resp.status_code == 200 inf_id = resp.text @@ -888,7 +893,7 @@ def get_parser(): parser.add_option("-v", "--verify-ssl", action="store_true", default=False, dest="verify", help="Verify the certificate of the " "InfrastructureManager XML-RCP server") parser.add_operation_help('list', '') - parser.add_operation_help('create', '') + parser.add_operation_help('create', ' [async_flag]') parser.add_operation_help('destroy', '') parser.add_operation_help('getinfo', ' [radl_attribute]') parser.add_operation_help('getradl', '') From 305cce0b570ba591bf96d93beecb37cf6b50b49e Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 8 May 2018 08:11:37 +0200 Subject: [PATCH 2/2] Add async option in create op --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 59597ae..a099921 100644 --- a/README.md +++ b/README.md @@ -224,9 +224,11 @@ The :program:`im_client` is called like this: ``list``: List the infrastructure IDs created by the user. - ``create `` + ``create [async_flag]`` Create an infrastructure using RADL specified in the file with path - ``radlfile``. + ``radlfile``. The ``async_flag`` parameter is optional + and is a flag to specify if the creation call will wait the resources + to be created or return immediately the id of the infrastructure. ``destroy `` Destroy the infrastructure with ID ``infId``.