Bug 160 Fix SO restart with running NS instances 95/995/1
authorPhilip Joseph <philip.joseph@riftio.com>
Fri, 20 Jan 2017 09:05:09 +0000 (14:35 +0530)
committerPhilip Joseph <philip.joseph@riftio.com>
Fri, 20 Jan 2017 09:05:09 +0000 (14:35 +0530)
Signed-off-by: Philip Joseph <philip.joseph@riftio.com>
models/openmano/python/rift/openmano/openmano_client.py

index 814a50c..09fb43d 100755 (executable)
@@ -198,6 +198,7 @@ class OpenmanoCliAPI(object):
             output_lines = self._openmano_cmd(
                     ["vnf-list"],
                     )
+
         except OpenmanoCommandFailed as e:
             self._log.warning("Vnf listing returned an error: %s", str(e))
             return {}
@@ -206,8 +207,9 @@ class OpenmanoCliAPI(object):
         for line in output_lines:
             line = line.strip()
             uuid, name = line.split(" ", 1)
-            name_uuid_map[name] = uuid
+            name_uuid_map[name.strip()] = uuid.strip()
 
+        self._log.debug("VNF list: {}".format(name_uuid_map))
         return name_uuid_map
 
     def ns_create(self, ns_yaml_str, name=None):
@@ -249,8 +251,9 @@ class OpenmanoCliAPI(object):
         for line in output_lines:
             line = line.strip()
             uuid, name = line.split(" ", 1)
-            name_uuid_map[name] = uuid
+            name_uuid_map[name.strip()] = uuid.strip()
 
+        self._log.debug("Scenario list: {}".format(name_uuid_map))
         return name_uuid_map
 
     def ns_delete(self, ns_uuid):
@@ -282,8 +285,9 @@ class OpenmanoCliAPI(object):
         for line in output_lines:
             line = line.strip()
             uuid, name = line.split(" ", 1)
-            name_uuid_map[name] = uuid
+            name_uuid_map[name.strip()] = uuid.strip()
 
+        self._log.debug("Instance Scenario list: {}".format(name_uuid_map))
         return name_uuid_map
 
     def ns_instance_scenario_create(self, instance_yaml_str):
@@ -466,6 +470,10 @@ def parse_args(argv=sys.argv[1:]):
             type=valid_uuid,
             )
 
+    _ = subparsers.add_parser(
+            'vnf-list',
+            help="List all the openmano VNFs in the catalog",
+            )
 
     ns_create_parser = subparsers.add_parser(
             'scenario-create',
@@ -487,6 +495,10 @@ def parse_args(argv=sys.argv[1:]):
             type=valid_uuid,
             )
 
+    _ = subparsers.add_parser(
+            'scenario-list',
+            help="List all the openmano scenarios in the catalog",
+            )
 
     ns_instance_create_parser = subparsers.add_parser(
             'scenario-deploy',
@@ -512,8 +524,14 @@ def parse_args(argv=sys.argv[1:]):
             )
 
 
+    _ = subparsers.add_parser(
+            'instance-scenario-list',
+            help="List all the openmano scenario instances in the catalog",
+            )
+
     _ = subparsers.add_parser(
             'datacenter-list',
+            help="List all the openmano datacenters",
             )
 
     args = parser.parse_args(argv)
@@ -538,18 +556,30 @@ def main():
     elif args.command == "vnf-delete":
         openmano_cli.vnf_delete(args.uuid)
 
+    elif args.command == "vnf-list":
+        for uuid, name in openmano_cli.vnf_list().items():
+            print("{} {}".format(uuid, name))
+
     elif args.command == "scenario-create":
         openmano_cli.ns_create(args.file.read())
 
     elif args.command == "scenario-delete":
         openmano_cli.ns_delete(args.uuid)
 
+    elif args.command == "scenario-list":
+        for uuid, name in openmano_cli.ns_list().items():
+            print("{} {}".format(uuid, name))
+
     elif args.command == "scenario-deploy":
         openmano_cli.ns_instantiate(args.scenario_name, args.instance_name)
 
     elif args.command == "instance-scenario-delete":
         openmano_cli.ns_terminate(args.instance_name)
 
+    elif args.command == "instance-scenario-list":
+        for uuid, name in openmano_cli.ns_instance_list().items():
+            print("{} {}".format(uuid, name))
+
     elif args.command == "datacenter-list":
         for uuid, name in openmano_cli.datacenter_list():
             print("{} {}".format(uuid, name))