Modify vnf instantiation related stuffs. 55/59855/2
authorlaili <lai.li@zte.com.cn>
Thu, 9 Aug 2018 13:13:00 +0000 (21:13 +0800)
committerlaili <lai.li@zte.com.cn>
Fri, 10 Aug 2018 00:54:59 +0000 (08:54 +0800)
Modify const.py used to match vnf instantiation related serializers.
Make minor changes in test_instantiation_vnf.py, instantiate_vnf_view.py, and instantiate_vnf.

Change-Id: Ic4a5414ae6c55d05c153b54ae0236cccd28c5642
Issue-ID: VFC-1017
Signed-off-by: laili <lai.li@zte.com.cn>
lcm/lcm/nf/biz/instantiate_vnf.py
lcm/lcm/nf/const.py
lcm/lcm/nf/tests/test_instantiate_vnf.py
lcm/lcm/nf/views/instantiate_vnf_view.py

index f47746d..87d4f40 100644 (file)
@@ -100,7 +100,7 @@ class InstantiateVnf(Thread):
         if not is_exist:
             NfvoRegInfoModel.objects.create(
                 nfvoid=self.nf_inst_id,
-                vnfminstid=ignore_case_get(self.data, "vnfmId"),
+                vnfminstid=ignore_case_get(self.data, "vnfmId"),
                 apiurl=self.vim_id)
         JobUtil.add_job_status(self.job_id, 15, 'Nf instancing pre-check finish')
         logger.info("Nf instancing pre-check finish")
@@ -216,7 +216,7 @@ class InstantiateVnf(Thread):
 
     def vnf_inst_failed_handle(self, error_msg):
         logger.error('VNF instantiation failed, detail message: %s' % error_msg)
-        NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status='FAILED', lastuptime=now_time())
+        NfInstModel.objects.filter(nfinstid=self.nf_inst_id).update(status='NOT_INSTANTIATED', lastuptime=now_time())
         JobUtil.add_job_status(self.job_id, 255, error_msg)
 
     def do_notify(self, res_type, ret):
index 5f84b4f..33ba654 100644 (file)
@@ -25,74 +25,85 @@ RESOURCE_MAP = {'Storage': 'volumn', 'Network': 'network', 'SubNetwork': 'subnet
 inst_req_data = {
     "flavourId": "flavour_1",
     "instantiationLevelId": "instantiationLevel_1",
-    "vnfmId": "vnfm_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",
+            "id": "extVirtualLink_1",
+            "vimConnectionId": "vimConnection_1",
+            "resourceProviderId": "resourceProvider_1",
+            "resourceId": "resource_1",
             "extCps": [
                 {
-                    "cpdId": "11",
-                    "addresses": [
+                    "cpdId": "cpd_1",
+                    "cpConfig": [
                         {
-                            "addressType": "MAC",
-                            "l2AddressData": "00:f3:43:20:a2:a3"
-                        },
-                        {
-                            "addressType": "IP",
-                            "l3AddressData": {
-                                "iPAddressType": "IPv4",
-                                "iPAddress": "192.168.104.2"
-                            }
+                            "cpInstanceId": "cpInstance_1",
+                            "linkPortId": "linkPort_1",
+                            "cpProtocolData": [
+                                {
+                                    "layerProtocol": "IP_OVER_ETHERNET",
+                                    "ipOverEthernet": {
+                                        "macAddress": "00:f3:43:20:a2:a3",
+                                        "ipAddresses": [
+                                            {
+                                                "type": "IPV4",
+                                                "fixedAddresses": ["192.168.104.2", ],
+                                                "numDynamicAddresses": 0,
+                                                "addressRange": None,
+                                                "subnetId": "subnet_1",
+                                            }
+                                        ]
+                                    }
+                                }
+                            ]
                         }
-                    ],
-                    "numDynamicAddresses": 0
+                    ]
+                }
+            ],
+            "extLinkPorts": [
+                {
+                    "id": "extLinkPort_1",
+                    "resourceHandle": {
+                        "vimConnectionId": "vimConnection_1",
+                        "resourceProviderId": "resourceProvider_1",
+                        "resourceId": "resource_1",
+                        "vimLevelResourceType": "vimLevelResourceType_1",
+                    }
                 }
             ]
-        },
+        }
+    ],
+    "extManagedVirtualLinks": [
         {
-            "vlInstanceId": '55',
-            "resourceId": '55_network',
-            "resourceSubnetId": '55_subnet',
-            "cpdId": 'cpId1',
-            "vim": {
-                "vimId": '55_vimid'
-            }
+            "id": 'extManagedVirtualLink_1',
+            "virtualLinkDescId": 'virtualLinkDesc_1',
+            "vimConnectionId": 'vimConnection_1',
+            "resourceProviderId": 'resourceProvider_1',
+            "resourceId": 'resource_1',
+        }
+    ],
+    "vimConnectionInfo": [
+        {
+            "id": 'vimConnection_1',
+            "vimId": 'vim_1',
+            "vimType": 'vim',
+            "interfaceInfo": {
+                "apiVersion": "apiVersion_1",
+                "protocolType": "http"
+            },
+            "accessInfo": {
+                "tenant": "tenant_vCPE",
+                "username": "vCPE",
+                "password": "vCPE_321",
+            },
+            "extra": None,
         }
     ],
     "localizationLanguage": "en_US",
     "additionalParams": {
-        "vimId": "vim_1",
-        "inputs": {
-            "key1": "test1",
-            "key2": "test2"
-        },
-        "extVirtualLinks": [
-            {
-                "vlInstanceId": '55',
-                "resourceId": '55_network',
-                "resourceSubnetId": '55_subnet',
-                "cpdId": 'cpId1',
-                "vim": {
-                    "vimId": '55_vimid'
-                }
-            }
-        ]
+        # "inputs": {
+        "key1": "test1",
+        "key2": "test2"
+        # }
     }
 }
 
index 7cf2646..e760499 100644 (file)
@@ -36,7 +36,7 @@ class TestNFInstantiate(TestCase):
         self.client = APIClient()\r
         self.grant_result = {\r
             "vimid": 'vimid_1',\r
-            "tenant": 'tenantname_1'\r
+            "tenant": 'tenantname_1',\r
         }\r
 \r
     def tearDown(self):\r
@@ -50,7 +50,7 @@ class TestNFInstantiate(TestCase):
 \r
     @mock.patch.object(InstantiateVnf, 'run')\r
     def test_instantiate_vnf(self, mock_run):\r
-        NfInstModel(nfinstid='12', nf_name='VNF1').save()\r
+        NfInstModel(nfinstid='12', nf_name='VNF1', status="UN_INSTANTIATED").save()\r
         mock_run.re.return_value = None\r
         response = self.client.post("/api/vnflcm/v1/vnf_instances/12/instantiate", data=inst_req_data, format='json')\r
         self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code)\r
index 3e9c334..fec85d1 100644 (file)
@@ -21,7 +21,9 @@ from rest_framework import status
 from rest_framework.response import Response\r
 from rest_framework.views import APIView\r
 \r
-from lcm.nf.serializers.serializers import InstOrTeriVnfResponseSerializer, InstantiateVnfRequestSerializer\r
+# from lcm.nf.serializers.serializers import InstantiateVnfRequestSerializer, InstOrTeriVnfResponseSerializer\r
+from lcm.nf.serializers.instantiate_vnf_request import InstantiateVnfRequestSerializer\r
+from lcm.nf.serializers.inst_or_teri_vnf_response import InstOrTeriVnfResponseSerializer\r
 from lcm.pub.exceptions import NFLCMException\r
 from lcm.pub.utils.jobutil import JobUtil\r
 \r