fix 1042 add timeout option for ns-action and vnf-scale
Change-Id: I5a30f4d1ca9c17875800d602ecaa5406bc9ff1a1
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
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 @@
@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 @@
action_name,
params,
params_file,
+ timeout,
wait):
"""executes an action/primitive over a NS instance
@@ -3612,6 +3614,8 @@
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 @@
@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 @@
scaling_group,
scale_in,
scale_out,
+ timeout,
wait):
"""
Executes a VNF scale (adding/removing VDUs)
@@ -3655,7 +3661,7 @@
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 @@
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 @@
"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: