Update vnf instaniation code of gvnfm vnflcm
authorying.yunlong <ying.yunlong@zte.com.cn>
Thu, 2 Mar 2017 06:53:37 +0000 (14:53 +0800)
committerying.yunlong <ying.yunlong@zte.com.cn>
Thu, 2 Mar 2017 06:53:37 +0000 (14:53 +0800)
Change-Id: I79e55ea322a95e3fbfcf793b64e06279e37cf27d
Issue-Id: GVNFM-42
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
lcm/lcm/nf/vnfs/const.py
lcm/lcm/nf/vnfs/vnf_create/inst_vnf.py
lcm/lcm/pub/msapi/nfvolcm.py
lcm/lcm/pub/vimapi/adaptor.py

index a3a2f5f..f368271 100644 (file)
@@ -22,43 +22,52 @@ inst_req_data = {
     "flavourId": "flavour_1",
     "instantiationLevelId": "instantiationLevel_1",
     "extVirtualLinks": [
+        # {
+        #     "vlInstanceId": "1",
+        #     "vim": {
+        #         "vimInfoId": "1",
+        #         "vimId": "1",
+        #         "interfaceInfo": {
+        #             "vimType": "vim",
+        #             "apiVersion": "v2",
+        #             "protocolType": "http"
+        #         },
+        #         "accessInfo": {
+        #             "tenant": "tenant_vCPE",
+        #             "username": "vCPE",
+        #             "password": "vCPE_321"
+        #         },
+        #         "interfaceEndpoint": "http://10.43.21.105:80/"
+        #     },
+        #     "resourceId": "1246",
+        #     "extCps": [
+        #         {
+        #             "cpdId": "11",
+        #             "addresses": [
+        #                 {
+        #                     "addressType": "MAC",
+        #                     "l2AddressData": "00:f3:43:20:a2:a3"
+        #                 },
+        #                 {
+        #                     "addressType": "IP",
+        #                     "l3AddressData": {
+        #                         "iPAddressType": "IPv4",
+        #                         "iPAddress": "192.168.104.2"
+        #                     }
+        #                 }
+        #             ],
+        #             "numDynamicAddresses": 0
+        #         }
+        #     ]
+        # },
         {
-            "vlInstanceId": "1",
+            "vlInstanceId": '55',
+            "resourceId": '55_network',
+            "resourceSubnetId": '55_subnet',
+            "cpdId": 'cpId1',
             "vim": {
-                "vimInfoId": "1",
-                "vimId": "1",
-                "interfaceInfo": {
-                    "vimType": "vim",
-                    "apiVersion": "v2",
-                    "protocolType": "http"
-                },
-                "accessInfo": {
-                    "tenant": "tenant_vCPE",
-                    "username": "vCPE",
-                    "password": "vCPE_321"
-                },
-                "interfaceEndpoint": "http://10.43.21.105:80/"
-            },
-            "resourceId": "1246",
-            "extCps": [
-                {
-                    "cpdId": "11",
-                    "addresses": [
-                        {
-                            "addressType": "MAC",
-                            "l2AddressData": "00:f3:43:20:a2:a3"
-                        },
-                        {
-                            "addressType": "IP",
-                            "l3AddressData": {
-                                "iPAddressType": "IPv4",
-                                "iPAddress": "192.168.104.2"
-                            }
-                        }
-                    ],
-                    "numDynamicAddresses": 0
-                }
-            ]
+                "vimid": '55_vimid'
+            }
         }
     ],
     "localizationLanguage": "en_US",
index e94001e..c950e15 100644 (file)
@@ -91,6 +91,7 @@ class InstVnf(Thread):
         self.vnfd_info = json.JSONDecoder().decode(self.vnfd_info)
 
         self.vnfd_info = vnfd_model_dict  # just for test
+        self.update_cps()
 
         self.checkParameterExist()
         # update NfInstModel
@@ -392,6 +393,16 @@ class InstVnf(Thread):
     # def do_notify_delete(self, ret):
     #     logger.error('Deleting [%s] resource' % ret)
 
+    def update_cps(self):
+        for extlink in ignore_case_get(self.data, "extVirtualLinks"):
+            for cp in self.vnfd_info["cps"]:
+                cpdid = ignore_case_get(extlink, "cpdId")
+                if cpdid == ignore_case_get(cp, "cp_id"):
+                    cp["networkId"] = ignore_case_get(extlink, "resourceId")
+                    cp["subnetId"] = ignore_case_get(extlink, "resourceSubnetId")
+                    break
+        pass
+
     def checkParameterExist(self):
         # if ignore_case_get(self.data, "flavourId") not in self.vnfd_info:
         #     raise NFLCMException('Input parameter is not defined in vnfd_info.')
index f6849da..362045a 100644 (file)
@@ -21,7 +21,7 @@ logger = logging.getLogger(__name__)
 
 
 def get_packageinfo_by_vnfdid(vnfdid):
-    ret = req_by_msb("openoapi/gvnfmdriver/v1/%s" % vnfdid, "GET")  # TODO
+    ret = req_by_msb("openoapi/gvnfmdriver/v1/vnfpackages", "GET")  # TODO
     if ret[0] != 0:
         logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
         raise NFLCMException("Failed to query package_info of vnfdid(%s) from nslcm." % vnfdid)
index fed69b1..a09943f 100644 (file)
@@ -167,13 +167,16 @@ def create_port(vim_cache, res_cache, data, port, do_notify, res_type):
     if not location_info:
         err_msg = "vdu_id(%s) for cp(%s) is not defined"
         raise VimException(err_msg % (port_ref_vdu_id, port["cp_id"]), ERR_CODE)
-    network_id = get_res_id(res_cache, RES_NETWORK, port["vl_id"])
-    subnet_id = get_res_id(res_cache, RES_SUBNET, port["vl_id"])
+    network_id = ignore_case_get(port, "networkId")
+    subnet_id = ignore_case_get(port, "subnetId")
+    if not network_id:
+        network_id = get_res_id(res_cache, RES_NETWORK, port["vl_id"])
+        subnet_id = get_res_id(res_cache, RES_SUBNET, port["vl_id"])
     param = {
         "networkId": network_id,
-        "subnetId": subnet_id,
         "name": port["properties"]["name"]
     }
+    set_opt_val(param, "subnetId", subnet_id)
     set_opt_val(param, "macAddress", ignore_case_get(port["properties"], "mac_address"))
     set_opt_val(param, "ip", ignore_case_get(port["properties"], "ip_address"))
     set_opt_val(param, "vnicType", ignore_case_get(port["properties"], "vnic_type"))