Accept the instance data from gvnfm to nfvo and process it 27/107527/3
authorYuanHong Deng <dengyuanhong@chinamobile.com>
Tue, 12 May 2020 08:12:25 +0000 (16:12 +0800)
committerYuanhong Deng <dengyuanhong@chinamobile.com>
Tue, 12 May 2020 09:37:17 +0000 (09:37 +0000)
Change-Id: I874ccdbbad57207b8f8d3f2b3c272fdd4f200441
Issue-ID: VFC-1657
Signed-off-by: YuanHong Deng <dengyuanhong@chinamobile.com>
lcm/ns_vnfs/biz/handle_notification.py
lcm/ns_vnfs/tests/tests.py

index 4e957d1..edcebbb 100644 (file)
@@ -133,18 +133,22 @@ class HandleVnfLcmOocNotification(object):
                     vimId = ignore_case_get(portResource, 'vimConnectionId')
                     resourceId = ignore_case_get(portResource, 'resourceId')
                     resourceName = ignore_case_get(portResource, 'resourceId')  # replaced with resouceId temporarily
-                    # tenant = ignore_case_get(portResource, 'tenant')
-                    # ipAddress = ignore_case_get(portResource, 'ipAddress')
-                    # macAddress = ignore_case_get(portResource, 'macAddress')
-                    # instId = ignore_case_get(portResource, 'instId')
-                    portid = str(uuid.uuid4())
-
-                    PortInstModel(portid=portid, networkid='unknown', subnetworkid='unknown', vimid=vimId,
-                                  resourceid=resourceId, name=resourceName, instid="unknown", cpinstanceid=cpInstanceId,
-                                  bandwidth='unknown', operationalstate='active', ipaddress="unkown",
-                                  macaddress='unknown',
+                    tenant = ignore_case_get(portResource, 'tenant')
+                    ipAddress = ignore_case_get(portResource, 'ipAddress')
+                    macAddress = ignore_case_get(portResource, 'macAddress')
+                    instId = ignore_case_get(portResource, 'instId')
+                    portid = ignore_case_get(portResource, 'portId')
+                    networkId = ignore_case_get(portResource, 'networkId')
+                    subnetId = ignore_case_get(portResource, 'subnetId')
+
+                    # portid = str(uuid.uuid4())
+
+                    PortInstModel(portid=portid, networkid=networkId, subnetworkid=subnetId, vimid=vimId,
+                                  resourceid=resourceId, name=resourceName, instid=instId, cpinstanceid=cpInstanceId,
+                                  bandwidth='unknown', operationalstate='active', ipaddress=ipAddress,
+                                  macaddress=macAddress,
                                   floatipaddress='unknown', serviceipaddress='unknown', typevirtualnic='unknown',
-                                  sfcencapsulation='gre', direction='unknown', tenant="unkown").save()
+                                  sfcencapsulation='gre', direction='unknown', tenant=tenant).save()
                     relatedportId = portid
 
                 CPInstModel(cpinstanceid=cpInstanceId, cpdid=cpdId, ownertype=ownertype, ownerid=ownerid,
index b490432..c3d3008 100644 (file)
@@ -2270,7 +2270,13 @@ class TestVnfNotifyView(TestCase):
                                                           "id": "cpd_id",
                                                           "resourceHandle": {
                                                               "vimConnectionId": "vim_connection_id",
-                                                              "resourceId": "resource_id"
+                                                              "resourceId": "resource_id",
+                                                              "tenant": "tenant",
+                                                              "ipAddress": "ipAddress",
+                                                              "macAddress": "macAddress",
+                                                              "instId": "instId",
+                                                              "networkId": "networkId",
+                                                              "subnetId": "subnetId"
                                                           }
                                                           }],
                                         }]
@@ -2307,13 +2313,13 @@ class TestVnfNotifyView(TestCase):
                                           vlinstancename="resource_id", ownertype=0, ownerid=self.nf_inst_id,
                                           relatednetworkid="resource_id", vltype=0)
         self.assertIsInstance(vl_inst, VLInstModel)
-        port_inst = PortInstModel.objects.get(networkid='unknown', subnetworkid='unknown', vimid="vim_connection_id",
-                                              resourceid="resource_id", name="resource_id", instid="unknown",
+        port_inst = PortInstModel.objects.get(networkid='networkId', subnetworkid='subnetId', vimid="vim_connection_id",
+                                              resourceid="resource_id", name="resource_id", instid="instId",
                                               cpinstanceid="cp_instance_id", bandwidth='unknown',
-                                              operationalstate='active', ipaddress="unkown", macaddress='unknown',
+                                              operationalstate='active', ipaddress="ipAddress", macaddress='macAddress',
                                               floatipaddress='unknown', serviceipaddress='unknown',
                                               typevirtualnic='unknown', sfcencapsulation='gre', direction='unknown',
-                                              tenant="unkown")
+                                              tenant="tenant")
         self.assertIsInstance(port_inst, PortInstModel)
         cp_inst = CPInstModel.objects.get(cpinstanceid="cp_instance_id", cpdid="cpd_id", ownertype=0,
                                           ownerid=self.nf_inst_id, relatedtype=2, status='active')
@@ -2406,7 +2412,13 @@ class TestVnfNotifyView(TestCase):
                                                           "id": "cpd_id",
                                                           "resourceHandle": {
                                                               "vimConnectionId": "vim_connection_id",
-                                                              "resourceId": "resource_id"
+                                                              "resourceId": "resource_id",
+                                                              "tenant": "tenant",
+                                                              "ipAddress": "ipAddress",
+                                                              "macAddress": "macAddress",
+                                                              "instId": "instId",
+                                                              "networkId": "networkId",
+                                                              "subnetId": "subnetId"
                                                           }
                                                           }],
                                         }]
@@ -2419,13 +2431,13 @@ class TestVnfNotifyView(TestCase):
                                           vlinstancename="resource_id", ownertype=0, ownerid=self.nf_inst_id,
                                           relatednetworkid="resource_id", vltype=0)
         self.assertIsInstance(vl_inst, VLInstModel)
-        port_inst = PortInstModel.objects.get(networkid='unknown', subnetworkid='unknown', vimid="vim_connection_id",
-                                              resourceid="resource_id", name="resource_id", instid="unknown",
+        port_inst = PortInstModel.objects.get(networkid='networkId', subnetworkid='subnetId', vimid="vim_connection_id",
+                                              resourceid="resource_id", name="resource_id", instid="instId",
                                               cpinstanceid="cp_instance_id", bandwidth='unknown',
-                                              operationalstate='active', ipaddress="unkown", macaddress='unknown',
+                                              operationalstate='active', ipaddress="ipAddress", macaddress='macAddress',
                                               floatipaddress='unknown', serviceipaddress='unknown',
                                               typevirtualnic='unknown', sfcencapsulation='gre', direction='unknown',
-                                              tenant="unkown")
+                                              tenant="tenant")
         self.assertIsInstance(port_inst, PortInstModel)
         cp_inst = CPInstModel.objects.get(cpinstanceid="cp_instance_id", cpdid="cpd_id", ownertype=0,
                                           ownerid=self.nf_inst_id, relatedtype=2, status='active')