Create ns/vnf/vserver relationship 73/15373/3
authorying.yunlong <ying.yunlong@zte.com.cn>
Tue, 26 Sep 2017 06:53:35 +0000 (14:53 +0800)
committerying.yunlong <ying.yunlong@zte.com.cn>
Tue, 26 Sep 2017 07:50:54 +0000 (15:50 +0800)
Create ns/vnf/vserver relationship to aai in vfc-nfvo-lcm

Change-Id: Id84041063b7369e7e02bdb62df93a1ce55a9b4ee
Issue-ID: VFC-458
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
lcm/ns/vnfs/create_vnfs.py

index 0af4c6d..7a17a4b 100644 (file)
@@ -16,8 +16,8 @@ import logging
 import traceback
 import uuid
 from threading import Thread
-from lcm.ns.const import OWNER_TYPE
 
+from lcm.ns.const import OWNER_TYPE
 from lcm.ns.vnfs.const import VNF_STATUS, NFVO_VNF_INST_TIMEOUT_SECOND, INST_TYPE, INST_TYPE_NAME
 from lcm.ns.vnfs.wait_job import wait_job_finish
 from lcm.pub.config.config import REPORT_TO_AAI
@@ -279,16 +279,39 @@ class CreateVnfs(Thread):
             "vnf-type": "vnf-type-test111",
             "service-id": self.ns_inst_id,
             "in-maint": True,
-            "is-closed-loop-disabled": False
+            "is-closed-loop-disabled": False,
+            "relationship-list": {
+                "relationship": [
+                    {
+                        "related-to": "service-instance",
+                        "relationship-data": [
+                            {
+                                "relationship-key": "customer.global-customer-id",
+                                "relationship-value": "global-customer-id-" + self.ns_inst_id
+                            },
+                            {
+                                "relationship-key": "service-subscription.service-type",
+                                "relationship-value": "service-type-" + self.ns_inst_id
+                            },
+                            {
+                                "relationship-key": "service-instance.service-instance-id",
+                                "relationship-value": self.ns_inst_id
+                            }
+                        ]
+                    }
+                ]
+            }
         }
         resp_data, resp_status = create_vnf_aai(self.nf_inst_id, data)
         if resp_data:
-            logger.debug("Fail to create vnf instance[%s] to aai, resp_status: [%s]." % (self.nf_inst_id, resp_status))
+            logger.debug("Fail to create vnf instance[%s] to aai, vnf instance=[%s], resp_status: [%s]."
+                         % (self.nf_inst_id, self.ns_inst_id, resp_status))
         else:
-            logger.debug("Success to create vnf instance[%s] to aai, resp_status: [%s]." % (self.nf_inst_id, resp_status))
+            logger.debug("Success to create vnf instance[%s] to aai, vnf instance=[%s], resp_status: [%s]."
+                         % (self.nf_inst_id, self.ns_inst_id, resp_status))
 
     def create_vserver_in_aai(self):
-        logger.debug("create_vserver_in_aai start!")
+        logger.debug("CreateVnfs::create_vserver_in_aai::report vserver instance to aai.")
         cloud_owner, cloud_region_id = split_vim_to_owner_region(self.vim_id)
 
         # query vim_info from aai
@@ -303,16 +326,27 @@ class CreateVnfs(Thread):
                 "prov-status": "ACTIVE",
                 "vserver-selflink": "",
                 "in-maint": True,
-                "is-closed-loop-disabled": False
+                "is-closed-loop-disabled": False,
+                "relationship-list": {
+                    "relationship": [
+                        {
+                            "related-to": "generic-vnf",
+                            "relationship-data": [
+                                {
+                                    "relationship-key": "generic-vnf.vnf-id",
+                                    "relationship-value": self.nf_inst_id
+                                }
+                            ]
+                        }
+                    ]
+                }
             }
 
             # create vserver instance in aai
             resp_data, resp_status = create_vserver_aai(cloud_owner, cloud_region_id, tenant_id, vserver_id, data)
             if resp_data:
-                logger.debug(
-                    "Fail to create vserver instance[%s] to aai, resp_status: [%s]." % (vserver_id, resp_status))
+                logger.debug("Fail to create vserver instance[%s] to aai, vnf instance=[%s], resp_status: [%s]."
+                             % (vserver_id, self.nf_inst_id, resp_status))
             else:
-                logger.debug(
-                    "Success to create vserver instance[%s] to aai, resp_status: [%s]." % (vserver_id, resp_status))
-
-        logger.debug("create_vserver_in_aai end!")
+                logger.debug("Success to create vserver instance[%s] to aai, vnf instance=[%s], resp_status: [%s]."
+                             % (vserver_id, self.nf_inst_id, resp_status))