Extrat data from gvnfmdriver to vnflcm 77/65477/2
authorHuang Haibin <haibin.huang@intel.com>
Mon, 10 Sep 2018 08:48:13 +0000 (16:48 +0800)
committerHuang Haibin <haibin.huang@intel.com>
Mon, 10 Sep 2018 09:05:34 +0000 (17:05 +0800)
When OOF return data to NSLCM which will be formated in NSLCM. GVNFM
will get data from NSLCM in the process of granting vnf.

Change-Id: If1a550517886afefc9c00143256c1df4285d5259
Issue-ID: VFC-1085
Signed-off-by: Huang Haibin <haibin.huang@intel.com>
lcm/lcm/nf/biz/grant_vnf.py
lcm/lcm/nf/biz/instantiate_vnf.py
lcm/lcm/nf/tests/test_instantiate_vnf.py

index a92f365..0889e6d 100644 (file)
@@ -99,4 +99,5 @@ def grant_resource(data, nf_inst_id, job_id, grant_type, vdus):
     content_args['additionalParams']['vnfmid'] = vnfInsts[0].vnfminstid
     logger.info('Grant request data=%s' % content_args)
     apply_result = apply_grant_to_nfvo(json.dumps(content_args))
+    logger.info("apply_result: %s" % apply_result)
     return apply_result
index 1c9a66b..56e9c14 100644 (file)
@@ -155,15 +155,38 @@ class InstantiateVnf(Thread):
                         break
 
     def set_location(self, apply_result):
+        vim_connections = ignore_case_get(apply_result, "vimConnections")
+        vnfid = ignore_case_get(apply_result, "vnfInstanceId")
+        directive = ignore_case_get(apply_result, "directive")
+        vim_assets = ignore_case_get(apply_result, "vimAssets")
+        access_info = ignore_case_get(vim_connections[0], "accessInfo")
+        tenant = ignore_case_get(access_info, "tenant")
+        vimid = ignore_case_get(vim_connections[0], "vimId")
+        cloud_owner, cloud_regionid = vimid.split("_")
+        vdu_info = []
+
+        for flavor in ignore_case_get(vim_assets, "vimComputeResourceFlavour"):
+            vdu_info.append({"vduName": flavor["resourceProviderId"],
+                             "flavorName": flavor["vimFlavourId"],
+                             "directive": directive})
+
         for resource_type in ['vdus', 'vls']:
             for resource in ignore_case_get(self.vnfd_info, resource_type):
                 if "location_info" in resource["properties"]:
-                    resource["properties"]["location_info"]["vimid"] = ignore_case_get(apply_result, "vimid")
-                    resource["properties"]["location_info"]["tenant"] = ignore_case_get(apply_result, "tenant")
+                    resource["properties"]["location_info"]["vimid"] = vimid
+                    resource["properties"]["location_info"]["tenant"] = tenant
+                    resource["properties"]["location_info"]["vnfId"] = vnfid
+                    resource["properties"]["location_info"]["cloudOwner"] = cloud_owner
+                    resource["properties"]["location_info"]["cloudRegionId"] = cloud_regionid
+                    resource["properties"]["location_info"]["vduInfo"] = vdu_info
                 else:
                     resource["properties"]["location_info"] = {
-                        "vimid": ignore_case_get(apply_result, "vimid"),
-                        "tenant": ignore_case_get(apply_result, "tenant")}
+                        "vimid": vimid,
+                        "tenant": tenant,
+                        "vnfId": vnfid,
+                        "cloudOwner": cloud_owner,
+                        "cloudRegionId": cloud_regionid,
+                        "vduInfo": vdu_info}
 
     '''
     def get_subnet_ids(self, ext_cp):
index 5801cb9..e698c4d 100644 (file)
@@ -35,8 +35,26 @@ class TestNFInstantiate(TestCase):
     def setUp(self):\r
         self.client = APIClient()\r
         self.grant_result = {\r
-            "vimid": 'vim_1',\r
-            "tenant": 'chinamobile',\r
+            "vimConnections": [\r
+                {\r
+                    "vimid": 'vim_1',\r
+                    "accessInfo":\r
+                    {\r
+                        "tenant": 'chinamobile'\r
+                    }\r
+                },\r
+            ],\r
+            "vnfId": "413aa1fe-b4d1-11e8-8268-dff5aab95c63",\r
+            "vimAssets":\r
+            {\r
+                "vimComputeResourceFlavour": [\r
+                    {\r
+                        "resourceProviderId": "vgw",\r
+                        "vimFlavourId": "yui",\r
+                        "directive": ""\r
+                    },\r
+                ]\r
+            }\r
         }\r
 \r
     def tearDown(self):\r