vmId = ignore_case_get(computeResource, 'resourceId')
vmName = ignore_case_get(computeResource, 'resourceId') # replaced with resouceId temporarily
- if changeType == 'added':
+ if changeType == 'ADDED':
VNFCInstModel(vnfcinstanceid=vnfcInstanceId, vduid=vduId,
nfinstid=self.vnf_instid, vmid=vmId).save()
VmInstModel(vmid=vmId, vimid=vimId, resouceid=vmId, insttype=INST_TYPE.VNF,
instid=self.vnf_instid, vmname=vmName, hostid='1').save()
if REPORT_TO_AAI:
self.create_vserver_in_aai(vimId, vmId, vmName)
- elif changeType == 'removed':
+ elif changeType == 'REMOVED':
if REPORT_TO_AAI:
self.delete_vserver_in_aai(vimId, vmId, vmName)
VNFCInstModel.objects.filter(vnfcinstanceid=vnfcInstanceId).delete()
- elif changeType == 'modified':
+ elif changeType == 'MODIFIED':
VNFCInstModel.objects.filter(vnfcinstanceid=vnfcInstanceId).update(vduid=vduId,
nfinstid=self.vnf_instid,
vmid=vmId)
else:
- self.exception('affectedVnfc struct error: changeType not in {added,removed,modified}')
+ self.exception('affectedVnfc struct error: changeType not in {ADDED, REMOVED, MODIFIED, TEMPORARY}')
logger.debug("Success to update all vserver to aai.")
def update_Vl(self):
ownerId = self.get_vnfinstid(self.m_vnfInstanceId, self.vnfmid)
- if changeType == 'added':
+ if changeType == 'ADDED':
VLInstModel(vlinstanceid=vlInstanceId, vldid=vldid, vlinstancename=resourceName, ownertype=0,
ownerid=ownerId, relatednetworkid=resourceId, vltype=0).save()
- elif changeType == 'removed':
+ elif changeType == 'REMOVED':
VLInstModel.objects.filter(vlinstanceid=vlInstanceId).delete()
- elif changeType == 'modified':
+ elif changeType == 'MODIFIED':
VLInstModel.objects.filter(vlinstanceid=vlInstanceId)\
.update(vldid=vldid, vlinstancename=resourceName, ownertype=0, ownerid=ownerId,
relatednetworkid=resourceId, vltype=0)
else:
- self.exception('affectedVl struct error: changeType not in {added,removed,modified}')
+ self.exception('affectedVl struct error: changeType not in {ADDED, REMOVED, MODIFIED, TEMPORARY}')
def update_Cp(self):
for cp in self.affectedCps:
ownerId = self.get_vnfinstid(self.m_vnfInstanceId, self.vnfmid)
- if changeType in ['added', 'modified']:
+ if changeType in ['ADDED', 'MODIFIED']:
self.create_network_and_subnet_in_aai(vlInstanceId, ownerId)
- elif changeType == 'removed':
+ elif changeType == 'REMOVED':
self.delete_network_and_subnet_in_aai(vlInstanceId)
else:
- logger.error('affectedVl struct error: changeType not in {added,removed,modified}')
+ logger.error('affectedVl struct error: changeType not in {ADDED, REMOVED, MODIFIED, TEMPORARY}')
except NSLCMException as e:
logger.debug("Fail to create internal network to aai, detail message: %s" % e.message)
except:
import unittest
import json
import mock
-from django.test import Client
+from rest_framework.test import APIClient
from rest_framework import status
+from lcm.pub.database.models import NfInstModel
from lcm.pub.utils import restcall
class VnfGrantViewTest(unittest.TestCase):
def setUp(self):
- self.client = Client()
+ self.client = APIClient()
def tearDown(self):
pass
}
]
}
-
self.assertEqual(expect_resp_data, resp_data)
def test_get_notify_vnf_normal(self):
"affectedVnfcs": [{
"id": "string",
"vduId": "string",
- "changeType": "added",
+ "changeType": "ADDED",
"computeResource": {
"vimConnectionId": "string",
"resourceProviderId": "string",
- "resouceId": "string",
+ "resourceId": "string",
"vimLevelResourceType": "string"
},
"metadata": {},
"removedStorageResourceIds": [],
}],
"affectedVirtualLinks": [{
- "vlInstanceId": "string",
- "vldId": "string",
- "changeType": "added",
+ "id": "string",
+ "virtualLinkDescId": "string",
+ "changeType": "ADDED",
"networkResource": {
- "resourceType": "network",
+ "vimConnectionId": "string",
+ "resourceProviderId": "string",
"resourceId": "string",
- "resourceName": "string"
+ "vimLevelResourceType": "network",
}
}],
- "affectedVirtualStorages": [{}],
+ "affectedVirtualStorages": [{
+ "id": "string",
+ "virtualStorageDescId": "string",
+ "changeType": "ADDED",
+ "storageResource": {
+ "vimConnectionId": "string",
+ "resourceProviderId": "string",
+ "resourceId": "string",
+ "vimLevelResourceType": "network",
+ },
+ "metadata": {}
+ }],
"changedInfo": {
"vnfInstanceName": "string",
"vnfInstanceDescription": "string",
}
}
}
+ NfInstModel.objects.create(nfinstid='22',
+ mnfinstid='2',
+ vnfm_inst_id='1')
response = self.client.post("/api/nslcm/v2/ns/1/vnfs/2/Notify", data=data, format='json')
self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code, response.content)