Added ns-scale-vdu command for VDU scaling 95/6295/5
authortierno <alfonso.tiernosepulveda@telefonica.com>
Mon, 25 Jun 2018 09:30:43 +0000 (11:30 +0200)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Tue, 20 Nov 2018 10:07:32 +0000 (11:07 +0100)
Change-Id: Ie4da5cd451cd7e0fcd1dec6a0e260c05cd7b28b4
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
osmclient/scripts/osm.py

index ba8ef5a..601d428 100755 (executable)
@@ -1462,5 +1462,45 @@ def ns_action(ctx,
         exit(1)
 
 
+@cli.command(name='ns-scale-vdu')
+@click.argument('ns_name' )
+@click.option('--vnf-name', prompt=True, help="member-vnf-index to scale")
+@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.pass_context
+def ns_scale_vdu(ctx,
+              ns_name,
+              vnf_name,
+              scaling_group,
+              scale_in,
+              scale_out):
+    """executes a VNF VDU scale over a NS instance
+
+    NS_NAME: name or ID of the NS instance
+    """
+    try:
+        check_client_version(ctx.obj, ctx.command.name)
+        op_data={}
+        if not scale_in and not scale_out:
+            scale_out = True
+            # print("You must provide scale type with option '--vnf-scale-in' or '--vnf-scale-out'")
+            # exit(1)
+        op_data["scaleType"] = "SCALE_VNF"
+        op_data["scaleVnfData"] = {}
+        if scale_in:
+            op_data["scaleVnfData"]["scaleVnfType"] = "SCALE_IN"
+        else:
+            op_data["scaleVnfData"]["scaleVnfType"] = "SCALE_OUT"
+        op_data["scaleVnfData"]["scaleByStepData"] = {
+            "member-vnf-index": vnf_name,
+            "scaling-group-descriptor": scaling_group,
+        }
+        ctx.obj.ns.exec_op(ns_name, op_name='scale', op_data=op_data)
+    except ClientException as inst:
+        print((inst.message))
+        exit(1)
+
+
 if __name__ == '__main__':
     cli()