def test_rest_api(self): pnfId = str(uuid.uuid4()) PNFInstModel(pnfId=pnfId, pnfName="Test PNF", pnfdId=str(uuid.uuid4()), pnfdInfoId=str(uuid.uuid4()), pnfProfileId=str(uuid.uuid4()), cpInfo=[{ "cpInstanceId": str(uuid.uuid4()), "cpdId": "pnf_ext_cp01", "cpProtocolData": [] }]).save() response = self.client.delete("/api/nslcm/v1/pnfs/%s" % pnfId) self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code)
def test_pnfid_filter(self): pnfId = str(uuid.uuid4()) PNFInstModel(pnfId=pnfId, pnfName="Test PNF", pnfdId=str(uuid.uuid4()), pnfdInfoId=str(uuid.uuid4()), pnfProfileId=str(uuid.uuid4()), cpInfo=[{ "cpInstanceId": str(uuid.uuid4()), "cpdId": "pnf_ext_cp01", "cpProtocolData": [] }]).save() pnfInst = GetPnf({"pnfId": pnfId}).do_biz() self.assertEqual("Test PNF", pnfInst[0].pnfName)
def test_do_biz(self): pnfId = str(uuid.uuid4()) PNFInstModel(pnfId=pnfId, pnfName="Test PNF", pnfdId=str(uuid.uuid4()), pnfdInfoId=str(uuid.uuid4()), pnfProfileId=str(uuid.uuid4()), cpInfo=[{ "cpInstanceId": str(uuid.uuid4()), "cpdId": "pnf_ext_cp01", "cpProtocolData": [] }]).save() DeletePnf(pnfId).do_biz() pnfInst = PNFInstModel.objects.filter(pnfId=pnfId) self.assertEqual(0, len(pnfInst))
def setUp(self): self.client = APIClient() self.ns_inst_id = 'test_ns_terminate_001' self.url = '/api/nslcm/v1/ns/%s/terminate' % self.ns_inst_id self.job_id = JobUtil.create_job(JOB_TYPE.NS, JOB_ACTION.TERMINATE, self.ns_inst_id) NSInstModel(id=self.ns_inst_id).save() NSInstModel(id='test_ns_terminate_002').save() FPInstModel(nsinstid=self.ns_inst_id, sfcid='test_sfc_inst_001', fpname='xxx', status='zzz').save() NfInstModel(ns_inst_id=self.ns_inst_id).save() VLInstModel(ownertype=OWNER_TYPE.NS, ownerid=self.ns_inst_id).save() PNFInstModel(nsInstances=self.ns_inst_id).save()
def test_get_individual_instance_restapi(self): pnfId = str(uuid.uuid4()) nsInstanceId = str(uuid.uuid4()) PNFInstModel(pnfId=pnfId, pnfName="Test PNF", pnfdId=str(uuid.uuid4()), pnfdInfoId=str(uuid.uuid4()), pnfProfileId=str(uuid.uuid4()), cpInfo=[{ "cpInstanceId": str(uuid.uuid4()), "cpdId": "pnf_ext_cp01", "cpProtocolData": [] }], emsId=str(uuid.uuid4()), nsInstances=nsInstanceId).save() response = self.client.get("/api/nslcm/v1/pnfs/%s" % pnfId) self.assertEqual(status.HTTP_200_OK, response.status_code)
def create_pnf_inst(self): pnfInstances = PNFInstModel.objects.filter(pnfId=self.pnfId) if pnfInstances: if pnfInstances[0].nsInstances: if not pnfInstances.filter( nsInstances__contains=self.nsInstances): for pnfInstance in pnfInstances: new_nsInstances = pnfInstance.nsInstances + "," + self.nsInstances pnfInstance.nsInstances = new_nsInstances pnfInstance.save() else: PNFInstModel(pnfId=self.pnfId, pnfName=self.pnfName, pnfdId=self.pnfdId, pnfdInfoId=self.pnfdInfoId, pnfProfileId=self.pnfProfileId, cpInfo=self.cpInfo, emsId=self.emsId, nsInstances=self.nsInstances).save()