LCM Providing VDU IP address information 66/5966/7
authortierno <alfonso.tiernosepulveda@telefonica.com>
Wed, 11 Apr 2018 21:21:55 +0000 (23:21 +0200)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Mon, 23 Apr 2018 16:04:34 +0000 (17:04 +0100)
Change-Id: Ica02b90e6dd01a7a3c9498afcd326c3f9f92a96a
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
lcm/osm_lcm/ROclient.py
lcm/osm_lcm/lcm.py

index 040eb17..8564bfd 100644 (file)
@@ -299,16 +299,17 @@ class ROClient:
     @staticmethod
     def get_ns_vnf_ip(ns_descriptor):
         """
-        Get a dict with the IPs of every vnf.
+        Get a dict with the IPs of every vnf and vdu
         :param ns_descriptor: instance descriptor obtained with self.show("ns", )
-        :return: dict iwth key member_vnf_index, value ip_address
+        :return: dict with {member_vnf_index: ip_address, ... member_vnf_index.vdu_id: ip_address ...}
         """
-        ns_ip={}
+        ns_ip = {"vnf": {}, "vdu": {}}
         for vnf in ns_descriptor["vnfs"]:
-            ns_ip[str(vnf["member_vnf_index"])] = vnf["ip_address"]
-            #uuid  sce_vnf_id
-            # vnf[mgmt_access]: '{interface_id: cf3cbf00-385c-49b4-9a3f-b400b7b15dc6, vm_id: d0dd22a9-91ef-46f1-8e8f-8cf4b2d5b2d7}'
-            # vnf[vms]
+            ns_ip["vnf"][str(vnf["member_vnf_index"])] = vnf["ip_address"]
+            ns_ip["vdu"][str(vnf["member_vnf_index"])] = {}
+            for vm in vnf["vms"]:
+                if vm.get("ip_address"):
+                    ns_ip["vdu"][str(vnf["member_vnf_index"])][vm["vdu_osm_id"]] = vm["ip_address"]
         return ns_ip
 
     async def _get_item_uuid(self, session, item, item_id_name, all_tenants=False):
index 2b62c1f..aa90f3d 100644 (file)
@@ -1044,7 +1044,13 @@ class Lcm:
                     self.logger.error("Task Kafka Exception {}".format(e))
                     await asyncio.sleep(1, loop=self.loop)
         self.logger.debug("Task Kafka terminating")
+        self.logger.debug("Task Kafka exit")
+
+    def start(self):
+        self.loop = asyncio.get_event_loop()
+        self.loop.run_until_complete(self.read_kafka())
         # TODO
+        # self.logger.debug("Terminating cancelling creation tasks")
         # self.cancel_tasks("ALL", "create")
         # timeout = 200
         # while self.is_pending_tasks():
@@ -1053,11 +1059,6 @@ class Lcm:
         #     timeout -= 2
         #     if not timeout:
         #         self.cancel_tasks("ALL", "ALL")
-        self.logger.debug("Task Kafka exit")
-
-    def start(self):
-        self.loop = asyncio.get_event_loop()
-        self.loop.run_until_complete(self.read_kafka())
         self.loop.close()
         self.loop = None
         if self.db: