From 3438b975a2c637dc87f1ba39d109184cf504f741 Mon Sep 17 00:00:00 2001 From: tierno Date: Thu, 2 Apr 2020 15:59:04 +0000 Subject: [PATCH] fix 1042 add timeout option for ns-action and vnf-scale Change-Id: I5a30f4d1ca9c17875800d602ecaa5406bc9ff1a1 Signed-off-by: tierno --- osmclient/scripts/osm.py | 8 +++++++- osmclient/sol005/ns.py | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index 6e0dc9e..40cb542 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -3580,6 +3580,7 @@ def upload_package(ctx, filename, skip_charm_build): @click.option('--action_name', prompt=True, help='action name') @click.option('--params', default=None, help='action params in YAML/JSON inline string') @click.option('--params_file', default=None, help='YAML/JSON file with action params') +@click.option('--timeout', required=False, default=None, type=int, help='timeout in seconds') @click.option('--wait', required=False, default=False, @@ -3595,6 +3596,7 @@ def ns_action(ctx, action_name, params, params_file, + timeout, wait): """executes an action/primitive over a NS instance @@ -3612,6 +3614,8 @@ def ns_action(ctx, op_data['vdu_id'] = vdu_id if vdu_count: op_data['vdu_count_index'] = vdu_count + if timeout: + op_data['timeout_ns_action'] = timeout op_data['primitive'] = action_name if params_file: with open(params_file, 'r') as pf: @@ -3633,6 +3637,7 @@ def ns_action(ctx, @click.option('--scaling-group', prompt=True, help="scaling-group-descriptor name to use") @click.option('--scale-in', default=False, is_flag=True, help="performs a scale in operation") @click.option('--scale-out', default=False, is_flag=True, help="performs a scale out operation (by default)") +@click.option('--timeout', required=False, default=None, type=int, help='timeout in seconds') @click.option('--wait', required=False, default=False, is_flag=True, help='do not return the control immediately, but keep it until the operation is completed, or timeout') @click.pass_context @@ -3642,6 +3647,7 @@ def vnf_scale(ctx, scaling_group, scale_in, scale_out, + timeout, wait): """ Executes a VNF scale (adding/removing VDUs) @@ -3655,7 +3661,7 @@ def vnf_scale(ctx, check_client_version(ctx.obj, ctx.command.name) if not scale_in and not scale_out: scale_out = True - ctx.obj.ns.scale_vnf(ns_name, vnf_name, scaling_group, scale_in, scale_out, wait) + ctx.obj.ns.scale_vnf(ns_name, vnf_name, scaling_group, scale_in, scale_out, wait, timeout) # except ClientException as e: # print(str(e)) # exit(1) diff --git a/osmclient/sol005/ns.py b/osmclient/sol005/ns.py index f4b5b89..dfe46e7 100644 --- a/osmclient/sol005/ns.py +++ b/osmclient/sol005/ns.py @@ -394,7 +394,7 @@ class Ns(object): str(exc)) raise ClientException(message) - def scale_vnf(self, ns_name, vnf_name, scaling_group, scale_in, scale_out, wait=False): + def scale_vnf(self, ns_name, vnf_name, scaling_group, scale_in, scale_out, wait=False, timeout=None): """Scales a VNF by adding/removing VDUs """ self._logger.debug("") @@ -413,6 +413,8 @@ class Ns(object): "member-vnf-index": vnf_name, "scaling-group-descriptor": scaling_group, } + if timeout: + op_data["timeout_ns_scale"] = timeout op_id = self.exec_op(ns_name, op_name='scale', op_data=op_data, wait=wait) print(str(op_id)) except ClientException as exc: -- 2.25.1