1 # Copyright 2016-2017 ZTE Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
18 from django.test import TestCase, Client
19 from rest_framework import status
21 from lcm.pub.database.models import NfInstModel, JobModel, NSInstModel, VmInstModel, OOFDataModel
22 from lcm.pub.exceptions import NSLCMException
23 from lcm.pub.utils import restcall
24 from lcm.pub.utils.jobutil import JOB_MODEL_STATUS
25 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
26 from lcm.pub.utils.timeutil import now_time
27 from lcm.pub.utils.values import ignore_case_get
28 from lcm.ns_vnfs.biz.create_vnfs import CreateVnfs
29 from lcm.ns_vnfs.biz.heal_vnfs import NFHealService
30 from lcm.ns_vnfs.biz.scale_vnfs import NFManualScaleService
31 from lcm.ns_vnfs.biz.terminate_nfs import TerminateVnfs
32 from lcm.ns_vnfs.const import VNF_STATUS, INST_TYPE
33 from lcm.ns_vnfs.biz import create_vnfs
34 from lcm.ns_vnfs.biz.place_vnfs import PlaceVnfs
37 class TestGetVnfViews(TestCase):
39 self.client = Client()
40 self.nf_inst_id = str(uuid.uuid4())
41 NfInstModel(nfinstid=self.nf_inst_id, nf_name='vnf1', vnfm_inst_id='1', vnf_id='vnf_id1',
42 status=VNF_STATUS.ACTIVE, create_time=now_time(), lastuptime=now_time()).save()
45 NfInstModel.objects.all().delete()
47 def test_get_vnf(self):
48 response = self.client.get("/api/nslcm/v1/ns/vnfs/%s" % self.nf_inst_id)
49 self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
50 context = json.loads(response.content)
51 self.failUnlessEqual(self.nf_inst_id, context['vnfInstId'])
54 class TestCreateVnfViews(TestCase):
56 self.ns_inst_id = str(uuid.uuid4())
57 self.job_id = str(uuid.uuid4())
59 "nsInstanceId": self.ns_inst_id,
60 "additionalParamForNs": {
61 "inputs": json.dumps({
65 "additionalParamForVnf": [
67 "vnfprofileid": "VBras",
69 "inputs": json.dumps({
73 "vnfminstanceid": "1",
80 self.client = Client()
81 NSInstModel(id=self.ns_inst_id, name='ns', nspackage_id='1', nsd_id='nsd_id', description='description',
82 status='instantiating', nsd_model=json.dumps(nsd_model_dict), create_time=now_time(),
83 lastuptime=now_time()).save()
86 NfInstModel.objects.all().delete()
87 JobModel.objects.all().delete()
89 @mock.patch.object(CreateVnfs, 'run')
90 def test_create_vnf(self, mock_run):
91 response = self.client.post("/api/nslcm/v1/ns/vnfs", data=self.data)
92 self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code)
93 context = json.loads(response.content)
94 self.assertTrue(NfInstModel.objects.filter(nfinstid=context['vnfInstId']).exists())
96 @mock.patch.object(restcall, 'call_req')
97 def test_create_vnf_thread(self, mock_call_req):
98 nf_inst_id, job_id = create_vnfs.prepare_create_params()
100 "/api/ztevnfmdriver/v1/1/vnfs":
101 [0, json.JSONEncoder().encode({"jobId": self.job_id, "vnfInstanceId": 3}), '200'],
102 "/api/catalog/v1/vnfpackages/zte_vbras":
103 [0, json.JSONEncoder().encode(nf_package_info), '200'],
104 "/external-system/esr-vnfm-list/esr-vnfm/1?depth=all":
105 [0, json.JSONEncoder().encode(vnfm_info), '200'],
106 "/api/resmgr/v1/vnf":
107 [0, json.JSONEncoder().encode({}), '200'],
108 "/api/resmgr/v1/vnfinfo":
109 [0, json.JSONEncoder().encode({}), '200'],
110 "/network/generic-vnfs/generic-vnf/%s" % nf_inst_id:
111 [0, json.JSONEncoder().encode({}), '201'],
112 "/cloud-infrastructure/cloud-regions/cloud-region/zte/test?depth=all":
113 [0, json.JSONEncoder().encode(vim_info), '201'],
114 "/cloud-infrastructure/cloud-regions/cloud-region/zte/test/tenants/tenant/admin/vservers/vserver/1":
115 [0, json.JSONEncoder().encode({}), '201'],
116 "/api/ztevnfmdriver/v1/1/jobs/" + self.job_id + "?responseId=0":
117 [0, json.JSONEncoder().encode({"jobid": self.job_id,
118 "responsedescriptor": {"progress": "100",
119 "status": JOB_MODEL_STATUS.FINISHED,
121 "statusdescription": "creating",
123 "responsehistorylist": [
125 "status": JOB_MODEL_STATUS.PROCESSING,
127 "statusdescription": "creating",
128 "errorcode": "0"}]}}), '200']}
130 def side_effect(*args):
131 return mock_vals[args[4]]
132 mock_call_req.side_effect = side_effect
134 'ns_instance_id': ignore_case_get(self.data, 'nsInstanceId'),
135 'additional_param_for_ns': ignore_case_get(self.data, 'additionalParamForNs'),
136 'additional_param_for_vnf': ignore_case_get(self.data, 'additionalParamForVnf'),
137 'vnf_index': ignore_case_get(self.data, 'vnfIndex')
139 CreateVnfs(data, nf_inst_id, job_id).run()
140 self.assertTrue(NfInstModel.objects.get(nfinstid=nf_inst_id).status, VNF_STATUS.ACTIVE)
143 class TestTerminateVnfViews(TestCase):
145 self.client = Client()
146 self.ns_inst_id = str(uuid.uuid4())
147 self.nf_inst_id = '1'
148 self.vnffg_id = str(uuid.uuid4())
149 self.vim_id = str(uuid.uuid4())
150 self.job_id = str(uuid.uuid4())
152 self.tenant = "tenantname"
156 "vnfdName": "PGW001",
157 "vnfProvider": "zte",
158 "vnfdVersion": "V00001",
159 "vnfVersion": "V5.10.20",
162 "description": "PGW VNFD description",
164 "vnfExtendType": "driver"
167 NSInstModel.objects.all().delete()
168 NfInstModel.objects.all().delete()
169 VmInstModel.objects.all().delete()
170 NSInstModel(id=self.ns_inst_id, name="ns_name").save()
171 NfInstModel.objects.create(nfinstid=self.nf_inst_id,
175 ns_inst_id='111,2-2-2',
182 mnfinstid=self.nf_uuid,
184 vnfd_model=self.vnfd_model)
185 VmInstModel.objects.create(vmid="1",
188 insttype=INST_TYPE.VNF,
189 instid=self.nf_inst_id,
194 NSInstModel.objects.all().delete()
195 NfInstModel.objects.all().delete()
197 @mock.patch.object(TerminateVnfs, 'run')
198 def test_terminate_vnf_url(self, mock_run):
200 "terminationType": "forceful",
201 "gracefulTerminationTimeout": "600"}
203 response = self.client.post("/api/nslcm/v1/ns/terminatevnf/%s" % self.nf_inst_id, data=req_data)
204 self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code)
206 @mock.patch.object(restcall, 'call_req')
207 def test_terminate_vnf(self, mock_call_req):
208 job_id = JobUtil.create_job("VNF", JOB_TYPE.TERMINATE_VNF, self.nf_inst_id)
210 nfinst = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
212 self.failUnlessEqual(1, 1)
214 self.failUnlessEqual(1, 0)
217 "vnf-id": "vnf-id-test111",
218 "vnf-name": "vnf-name-test111",
219 "vnf-type": "vnf-type-test111",
221 "is-closed-loop-disabled": False,
222 "resource-version": "1505465356262"
226 "responsedescriptor": {
228 "status": JOB_MODEL_STATUS.FINISHED,
230 "statusdescription": "creating",
232 "responsehistorylist": [
235 "status": JOB_MODEL_STATUS.PROCESSING,
237 "statusdescription": "creating",
245 "/external-system/esr-vnfm-list/esr-vnfm/1?depth=all":
246 [0, json.JSONEncoder().encode(vnfm_info), '200'],
247 "/api/ztevnfmdriver/v1/1/vnfs/111/terminate":
248 [0, json.JSONEncoder().encode({"jobId": job_id}), '200'],
249 "/api/resmgr/v1/vnf/1":
250 [0, json.JSONEncoder().encode({"jobId": job_id}), '200'],
251 "/cloud-infrastructure/cloud-regions/cloud-region/zte/test?depth=all":
252 [0, json.JSONEncoder().encode(vim_info), '201'],
253 "/cloud-infrastructure/cloud-regions/cloud-region/zte/test/tenants/tenant/admin/vservers/vserver/1?depth=all":
254 [0, json.JSONEncoder().encode(vserver_info), '201'],
255 "/cloud-infrastructure/cloud-regions/cloud-region/zte/test/tenants/tenant/admin/vservers/vserver/1?resource-version=1505465356263":
256 [0, json.JSONEncoder().encode({}), '200'],
257 "/api/ztevnfmdriver/v1/1/jobs/" + job_id + "?responseId=0":
258 [0, json.JSONEncoder().encode(job_info), '200'],
259 "/network/generic-vnfs/generic-vnf/1?depth=all":
260 [0, json.JSONEncoder().encode(vnf_info), '200'],
261 "/network/generic-vnfs/generic-vnf/1?resource-version=1505465356262":
262 [0, json.JSONEncoder().encode({}), '200']
265 def side_effect(*args):
266 return mock_vals[args[4]]
267 mock_call_req.side_effect = side_effect
270 "terminationType": "forceful",
271 "gracefulTerminationTimeout": "600"
274 TerminateVnfs(req_data, self.nf_inst_id, job_id).run()
275 nfinst = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
277 self.failUnlessEqual(1, 0)
279 self.failUnlessEqual(1, 1)
282 class TestScaleVnfViews(TestCase):
284 self.client = Client()
285 self.ns_inst_id = str(uuid.uuid4())
286 self.nf_inst_id = str(uuid.uuid4())
287 self.vnffg_id = str(uuid.uuid4())
288 self.vim_id = str(uuid.uuid4())
289 self.job_id = str(uuid.uuid4())
291 self.tenant = "tenantname"
292 NSInstModel(id=self.ns_inst_id, name="ns_name").save()
293 NfInstModel.objects.create(nfinstid=self.nf_inst_id, nf_name='name_1', vnf_id='1',
294 vnfm_inst_id='1', ns_inst_id='111,2-2-2',
295 max_cpu='14', max_ram='12296', max_hd='101', max_shd="20", max_net=10,
296 status='active', mnfinstid=self.nf_uuid, package_id='pkg1',
297 vnfd_model='{"metadata": {"vnfdId": "1","vnfdName": "PGW001",'
298 '"vnfProvider": "zte","vnfdVersion": "V00001","vnfVersion": "V5.10.20",'
299 '"productType": "CN","vnfType": "PGW",'
300 '"description": "PGW VNFD description",'
301 '"isShared":true,"vnfExtendType":"driver"}}')
304 NSInstModel.objects.all().delete()
305 NfInstModel.objects.all().delete()
307 def test_scale_vnf(self):
310 "flavour_id": "flavour1",
315 "instances_minimum_number": 1,
316 "instances_maximum_number": 4,
317 "local_affinity_antiaffinity_rule": [
319 "affinity_antiaffinity": "affinity",
328 "name": "demo_aspect",
329 "description": "demo_aspect",
330 "associated_group": "elementGroup1",
336 "group_id": "elementGroup1",
339 "name": "elementGroup1",
341 "members": ["gsu_vm", "pfu_vm"]
349 "aspectId": "demo_aspect1",
351 "additionalParam": vnfd_info
355 "aspectId": "demo_aspect2",
357 "additionalParam": vnfd_info
362 NFManualScaleService(self.nf_inst_id, req_data).run()
363 nsIns = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
364 self.assertIsNotNone(nsIns)
366 @mock.patch.object(NFManualScaleService, "send_nf_scaling_request")
367 def test_scale_vnf_success(self, mock_send_nf_scaling_request):
370 "flavour_id": "flavour1",
375 "instances_minimum_number": 1,
376 "instances_maximum_number": 4,
377 "local_affinity_antiaffinity_rule": [
379 "affinity_antiaffinity": "affinity",
388 "name": "demo_aspect",
389 "description": "demo_aspect",
390 "associated_group": "elementGroup1",
396 "group_id": "elementGroup1",
399 "name": "elementGroup1",
401 "members": ["gsu_vm", "pfu_vm"]
409 "aspectId": "demo_aspect1",
411 "additionalParam": vnfd_info
415 "aspectId": "demo_aspect2",
417 "additionalParam": vnfd_info
421 scale_service = NFManualScaleService(self.nf_inst_id, req_data)
423 nsIns = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
424 self.assertIsNotNone(nsIns)
426 jobs = JobModel.objects.filter(jobid=scale_service.job_id)
427 self.assertIsNotNone(100, jobs[0].progress)
430 class TestHealVnfViews(TestCase):
432 self.client = Client()
433 self.ns_inst_id = str(uuid.uuid4())
434 self.nf_inst_id = str(uuid.uuid4())
437 self.job_id = JobUtil.create_job("VNF", JOB_TYPE.HEAL_VNF, self.nf_inst_id)
439 NSInstModel(id=self.ns_inst_id, name="ns_name").save()
440 NfInstModel.objects.create(nfinstid=self.nf_inst_id,
444 ns_inst_id='111,2-2-2',
451 mnfinstid=self.nf_uuid,
453 vnfd_model=json.dumps({
456 "vnfdName": "PGW001",
457 "vnfProvider": "zte",
458 "vnfdVersion": "V00001",
459 "vnfVersion": "V5.10.20",
462 "description": "PGW VNFD description",
464 "vnfExtendType": "driver"
469 NSInstModel.objects.all().delete()
470 NfInstModel.objects.all().delete()
472 @mock.patch.object(restcall, "call_req")
473 def test_heal_vnf(self, mock_call_req):
476 "/api/ztevnfmdriver/v1/1/vnfs/111/heal":
477 [0, json.JSONEncoder().encode({"jobId": self.job_id}), '200'],
478 "/external-system/esr-vnfm-list/esr-vnfm/1":
479 [0, json.JSONEncoder().encode(vnfm_info), '200'],
480 "/api/resmgr/v1/vnf/1":
481 [0, json.JSONEncoder().encode({"jobId": self.job_id}), '200'],
482 "/api/ztevnfmdriver/v1/1/jobs/" + self.job_id + "?responseId=0":
483 [0, json.JSONEncoder().encode({
484 "jobId": self.job_id,
485 "responsedescriptor": {
487 "status": JOB_MODEL_STATUS.FINISHED,
489 "statusdescription": "creating",
491 "responsehistorylist": [{
493 "status": JOB_MODEL_STATUS.PROCESSING,
495 "statusdescription": "creating",
501 def side_effect(*args):
502 return mock_vals[args[4]]
504 mock_call_req.side_effect = side_effect
515 NFHealService(self.nf_inst_id, req_data).run()
517 self.assertEqual(NfInstModel.objects.get(nfinstid=self.nf_inst_id).status, VNF_STATUS.ACTIVE)
519 @mock.patch.object(NFHealService, "run")
520 def test_heal_vnf_non_existing_vnf(self, mock_biz):
521 mock_biz.side_effect = NSLCMException("VNF Not Found")
534 self.assertRaises(NSLCMException, NFHealService(nf_inst_id, req_data).run)
535 self.assertEqual(len(NfInstModel.objects.filter(nfinstid=nf_inst_id)), 0)
538 class TestGetVnfmInfoViews(TestCase):
540 self.client = Client()
541 self.vnfm_id = str(uuid.uuid4())
546 @mock.patch.object(restcall, "call_req")
547 def test_get_vnfm_info(self, mock_call_req):
549 "vnfm-id": "example-vnfm-id-val-62576",
550 "vim-id": "example-vim-id-val-35114",
551 "certificate-url": "example-certificate-url-val-90242",
552 "esr-system-info-list": {
555 "esr-system-info-id": "example-esr-system-info-id-val-78484",
556 "system-name": "example-system-name-val-23790",
557 "type": "example-type-val-52596",
558 "vendor": "example-vendor-val-47399",
559 "version": "example-version-val-42051",
560 "service-url": "example-service-url-val-10731",
561 "user-name": "example-user-name-val-65946",
562 "password": "example-password-val-22505",
563 "system-type": "example-system-type-val-27221",
564 "protocal": "example-protocal-val-54632",
565 "ssl-cacert": "example-ssl-cacert-val-45965",
566 "ssl-insecure": True,
567 "ip-address": "example-ip-address-val-19212",
568 "port": "example-port-val-57641",
569 "cloud-domain": "example-cloud-domain-val-26296",
570 "default-tenant": "example-default-tenant-val-87724"
575 r1 = [0, json.JSONEncoder().encode(vnfm_info_aai), '200']
576 mock_call_req.side_effect = [r1]
577 esr_system_info = ignore_case_get(ignore_case_get(vnfm_info_aai, "esr-system-info-list"), "esr-system-info")
579 "vnfmId": vnfm_info_aai["vnfm-id"],
580 "name": vnfm_info_aai["vnfm-id"],
581 "type": ignore_case_get(esr_system_info[0], "type"),
582 "vimId": vnfm_info_aai["vim-id"],
583 "vendor": ignore_case_get(esr_system_info[0], "vendor"),
584 "version": ignore_case_get(esr_system_info[0], "version"),
585 "description": "vnfm",
586 "certificateUrl": vnfm_info_aai["certificate-url"],
587 "url": ignore_case_get(esr_system_info[0], "service-url"),
588 "userName": ignore_case_get(esr_system_info[0], "user-name"),
589 "password": ignore_case_get(esr_system_info[0], "password"),
593 response = self.client.get("/api/nslcm/v1/vnfms/%s" % self.vnfm_id)
594 self.failUnlessEqual(status.HTTP_200_OK, response.status_code, response.content)
595 context = json.loads(response.content)
596 self.assertEqual(expect_data, context)
599 class TestGetVimInfoViews(TestCase):
601 self.client = Client()
602 self.vim_id = "zte_test"
607 @mock.patch.object(restcall, "call_req")
608 def test_get_vim_info(self, mock_call_req):
609 r1 = [0, json.JSONEncoder().encode(vim_info), '200']
610 mock_call_req.side_effect = [r1]
611 esr_system_info = ignore_case_get(ignore_case_get(vim_info, "esr-system-info-list"), "esr-system-info")
613 "vimId": self.vim_id,
615 "url": ignore_case_get(esr_system_info[0], "service-url"),
616 "userName": ignore_case_get(esr_system_info[0], "user-name"),
617 "password": ignore_case_get(esr_system_info[0], "password"),
618 # "tenant": ignore_case_get(tenants[0], "tenant-id"),
619 "tenant": ignore_case_get(esr_system_info[0], "default-tenant"),
620 "vendor": ignore_case_get(esr_system_info[0], "vendor"),
621 "version": ignore_case_get(esr_system_info[0], "version"),
622 "description": "vim",
624 "type": ignore_case_get(esr_system_info[0], "type"),
628 response = self.client.get("/api/nslcm/v1/vims/%s" % self.vim_id)
629 self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
630 context = json.loads(response.content)
631 self.assertEqual(expect_data["url"], context["url"])
634 class TestPlaceVnfViews(TestCase):
636 self.vnf_inst_id = "1234"
637 self.vnf_inst_name = "vG"
638 self.client = Client()
639 OOFDataModel.objects.all().delete()
640 OOFDataModel.objects.create(
642 transaction_id="1234",
643 request_status="init",
644 request_module_name=self.vnf_inst_name,
645 service_resource_id=self.vnf_inst_id,
653 OOFDataModel.objects.all().delete()
655 @mock.patch.object(restcall, 'call_req')
656 def test_place_vnf(self, mock_call_req):
659 "flavorName": "HPA.flavor.1",
662 PlaceVnfs(vnf_place_request).extract()
663 db_info = OOFDataModel.objects.filter(request_id=vnf_place_request.get("requestId"), transaction_id=vnf_place_request.get("transactionId"))
664 self.assertEqual(db_info[0].request_status, "completed")
665 self.assertEqual(db_info[0].vim_id, "CloudOwner1_DLLSTX1A")
666 self.assertEqual(db_info[0].cloud_owner, "CloudOwner1")
667 self.assertEqual(db_info[0].cloud_region_id, "DLLSTX1A")
668 self.assertEqual(db_info[0].vdu_info, json.dumps(vdu_info_json))
670 def test_place_vnf_with_invalid_response(self):
673 "transactionId": "1234",
674 "statusMessage": "xx",
675 "requestStatus": "pending",
677 "placementSolutions": [
680 "resourceModuleName": self.vnf_inst_name,
681 "serviceResourceId": self.vnf_inst_id,
683 "identifierType": "serviceInstanceId",
687 "cloudOwner": "CloudOwner1 "
693 "licenseSolutions": [
695 "resourceModuleName": "string",
696 "serviceResourceId": "string",
697 "entitlementPoolUUID": [
700 "licenseKeyGroupUUID": [
703 "entitlementPoolInvariantUUID": [
706 "licenseKeyGroupInvariantUUID": [
713 PlaceVnfs(resp).extract()
714 db_info = OOFDataModel.objects.filter(request_id=resp.get("requestId"), transaction_id=resp.get("transactionId"))
715 self.assertEqual(db_info[0].request_status, "pending")
716 self.assertEqual(db_info[0].vim_id, "none")
717 self.assertEqual(db_info[0].cloud_owner, "none")
718 self.assertEqual(db_info[0].cloud_region_id, "none")
719 self.assertEqual(db_info[0].vdu_info, "none")
721 def test_place_vnf_with_no_assignment_info(self):
724 "transactionId": "1234",
725 "statusMessage": "xx",
726 "requestStatus": "completed",
728 "placementSolutions": [
731 "resourceModuleName": self.vnf_inst_name,
732 "serviceResourceId": self.vnf_inst_id,
734 "identifierType": "serviceInstanceId",
738 "cloudOwner": "CloudOwner1 "
743 "licenseSolutions": [
745 "resourceModuleName": "string",
746 "serviceResourceId": "string",
747 "entitlementPoolUUID": [
750 "licenseKeyGroupUUID": [
753 "entitlementPoolInvariantUUID": [
756 "licenseKeyGroupInvariantUUID": [
763 PlaceVnfs(resp).extract()
764 db_info = OOFDataModel.objects.filter(request_id=resp.get("requestId"), transaction_id=resp.get("transactionId"))
765 self.assertEqual(db_info[0].request_status, "completed")
766 self.assertEqual(db_info[0].vim_id, "none")
767 self.assertEqual(db_info[0].cloud_owner, "none")
768 self.assertEqual(db_info[0].cloud_region_id, "none")
769 self.assertEqual(db_info[0].vdu_info, "none")
771 def test_place_vnf_no_directives(self):
774 "transactionId": "1234",
775 "statusMessage": "xx",
776 "requestStatus": "completed",
778 "placementSolutions": [
781 "resourceModuleName": self.vnf_inst_name,
782 "serviceResourceId": self.vnf_inst_id,
784 "identifierType": "serviceInstanceId",
788 "cloudOwner": "CloudOwner1 "
791 {"key": "locationId",
800 "resourceModuleName": "string",
801 "serviceResourceId": "string",
802 "entitlementPoolUUID": [
805 "licenseKeyGroupUUID": [
808 "entitlementPoolInvariantUUID": [
811 "licenseKeyGroupInvariantUUID": [
818 PlaceVnfs(resp).extract()
819 db_info = OOFDataModel.objects.filter(request_id=resp.get("requestId"), transaction_id=resp.get("transactionId"))
820 self.assertEqual(db_info[0].request_status, "completed")
821 self.assertEqual(db_info[0].vim_id, "none")
822 self.assertEqual(db_info[0].cloud_owner, "none")
823 self.assertEqual(db_info[0].cloud_region_id, "none")
824 self.assertEqual(db_info[0].vdu_info, "none")
826 def test_place_vnf_with_no_solution(self):
829 "transactionId": "1234",
830 "statusMessage": "xx",
831 "requestStatus": "completed",
833 "placementSolutions": [],
834 "licenseSoutions": []
837 PlaceVnfs(resp).extract()
838 db_info = OOFDataModel.objects.filter(request_id=resp.get("requestId"), transaction_id=resp.get("transactionId"))
839 self.assertEqual(db_info[0].request_status, "completed")
840 self.assertEqual(db_info[0].vim_id, "no-solution")
841 self.assertEqual(db_info[0].cloud_owner, "no-solution")
842 self.assertEqual(db_info[0].cloud_region_id, "no-solution")
843 self.assertEqual(db_info[0].vdu_info, "no-solution")
847 'local_storages': [],
860 'vdu_id': u'vdu_omm.001',
861 'image_file': u'opencos_sss_omm_img_release_20150723-1-disk1',
873 'support_scaling': False,
876 'storage_policy': '',
879 'availability_zone': '',
885 'inject_data_list': [
892 'local_affinity_antiaffinity_rule': {
895 'template_id': u'omm.001',
896 'manual_scale_select_vim': False
898 'description': u'singleommvm'
912 'image_file': u'sss',
924 'support_scaling': False,
927 'storage_policy': '',
930 'availability_zone': '',
936 'inject_data_list': [
943 'local_affinity_antiaffinity_rule': {
947 'manual_scale_select_vim': False
949 'description': u'ompvm'
963 'image_file': u'sss',
975 'support_scaling': False,
978 'storage_policy': '',
981 'availability_zone': '',
987 'inject_data_list': [
994 'local_affinity_antiaffinity_rule': {
998 'manual_scale_select_vim': False
1000 'description': u'ompvm'
1003 'volumn_storages': [
1014 'image_file': u'sss',
1026 'support_scaling': False,
1029 'storage_policy': '',
1032 'availability_zone': '',
1038 'inject_data_list': [
1045 'local_affinity_antiaffinity_rule': {
1048 'template_id': u'3',
1049 'manual_scale_select_vim': False
1051 'description': u'ompvm'
1054 'volumn_storages': [
1064 'vdu_id': u'vdu_10',
1065 'image_file': u'sss',
1077 'support_scaling': False,
1080 'storage_policy': '',
1083 'availability_zone': '',
1089 'inject_data_list': [
1096 'local_affinity_antiaffinity_rule': {
1099 'template_id': u'10',
1100 'manual_scale_select_vim': False
1102 'description': u'ppvm'
1105 'volumn_storages': [
1115 'vdu_id': u'vdu_11',
1116 'image_file': u'sss',
1128 'support_scaling': False,
1131 'storage_policy': '',
1134 'availability_zone': '',
1140 'inject_data_list': [
1147 'local_affinity_antiaffinity_rule': {
1150 'template_id': u'11',
1151 'manual_scale_select_vim': False
1153 'description': u'ppvm'
1156 'volumn_storages': [
1166 'vdu_id': u'vdu_12',
1167 'image_file': u'sss',
1179 'support_scaling': False,
1182 'storage_policy': '',
1185 'availability_zone': '',
1191 'inject_data_list': [
1198 'local_affinity_antiaffinity_rule': {
1201 'template_id': u'12',
1202 'manual_scale_select_vim': False
1204 'description': u'ppvm'
1207 'volumn_storages': [
1215 'policy_id': u'policy_scale_sss-vnf-template',
1217 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'
1226 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
1228 'disk_format': u'VMDK',
1229 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
1230 'container_type': 'vm',
1232 'hypervisor_type': 'kvm'
1234 'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'
1239 'name': u'sss.vmdk',
1241 'disk_format': u'VMDK',
1242 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
1243 'container_type': 'vm',
1245 'hypervisor_type': 'kvm'
1247 'image_file_id': u'sss'
1260 'domain_type': u'CN',
1261 'version': u'v4.14.10',
1262 'vmnumber_overquota_alarm': False,
1265 'vnfd_version': u'V00000001',
1266 'id': u'sss-vnf-template',
1267 'name': u'sss-vnf-template'
1276 "externalDataNetworkName": {
1300 "plugin_info": "vbrasplugin_1.0",
1302 "is_shared": "False",
1303 "request_reclassification": "False",
1304 "vnfd_version": "1.0.0",
1306 "nsh_aware": "True",
1307 "cross_dc": "False",
1308 "externalDataNetworkName": {
1309 "get_input": "externalDataNetworkName"
1331 "vl_id": "ext_mnet_network",
1334 "network_type": "vlan",
1335 "name": "externalMNetworkName",
1336 "dhcp_enabled": False,
1344 "end_ip": "190.168.100.100",
1345 "gateway_ip": "190.168.100.1",
1346 "start_ip": "190.168.100.2",
1347 "cidr": "190.168.100.0/24",
1349 "network_name": "sub_mnet",
1361 "invariant_id": "vbras_ns",
1362 "description": "vbras_ns",
1371 "vserver-id": "example-vserver-id-val-70924",
1372 "vserver-name": "example-vserver-name-val-61674",
1373 "vserver-name2": "example-vserver-name2-val-19234",
1374 "prov-status": "example-prov-status-val-94916",
1375 "vserver-selflink": "example-vserver-selflink-val-26562",
1377 "is-closed-loop-disabled": True,
1378 "resource-version": "1505465356263",
1382 "volume-id": "example-volume-id-val-71854",
1383 "volume-selflink": "example-volume-selflink-val-22433"
1390 "interface-name": "example-interface-name-val-24351",
1391 "interface-role": "example-interface-role-val-43242",
1392 "v6-wan-link-ip": "example-v6-wan-link-ip-val-4196",
1393 "selflink": "example-selflink-val-61295",
1394 "interface-id": "example-interface-id-val-95879",
1395 "macaddr": "example-macaddr-val-37302",
1396 "network-name": "example-network-name-val-44254",
1397 "management-option": "example-management-option-val-49009",
1398 "interface-description": "example-interface-description-val-99923",
1399 "is-port-mirrored": True,
1401 "prov-status": "example-prov-status-val-4698",
1402 "is-ip-unnumbered": True,
1403 "allowed-address-pairs": "example-allowed-address-pairs-val-5762",
1407 "vlan-interface": "example-vlan-interface-val-58193",
1408 "vlan-id-inner": 54452151,
1409 "vlan-id-outer": 70239293,
1410 "speed-value": "example-speed-value-val-18677",
1411 "speed-units": "example-speed-units-val-46185",
1412 "vlan-description": "example-vlan-description-val-81675",
1413 "backdoor-connection": "example-backdoor-connection-val-44608",
1414 "vpn-key": "example-vpn-key-val-7946",
1415 "orchestration-status": "example-orchestration-status-val-33611",
1417 "prov-status": "example-prov-status-val-8288",
1418 "is-ip-unnumbered": True,
1419 "l3-interface-ipv4-address-list": [
1421 "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-25520",
1422 "l3-interface-ipv4-prefix-length": 69931928,
1423 "vlan-id-inner": 86628520,
1424 "vlan-id-outer": 62729236,
1425 "is-floating": True,
1426 "neutron-network-id": "example-neutron-network-id-val-64021",
1427 "neutron-subnet-id": "example-neutron-subnet-id-val-95049"
1430 "l3-interface-ipv6-address-list": [
1432 "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-64310",
1433 "l3-interface-ipv6-prefix-length": 57919834,
1434 "vlan-id-inner": 79150122,
1435 "vlan-id-outer": 59789973,
1436 "is-floating": True,
1437 "neutron-network-id": "example-neutron-network-id-val-31713",
1438 "neutron-subnet-id": "example-neutron-subnet-id-val-89568"
1447 "pci-id": "example-pci-id-val-16747",
1448 "vf-vlan-filter": "example-vf-vlan-filter-val-4613",
1449 "vf-mac-filter": "example-vf-mac-filter-val-68168",
1450 "vf-vlan-strip": True,
1451 "vf-vlan-anti-spoof-check": True,
1452 "vf-mac-anti-spoof-check": True,
1453 "vf-mirrors": "example-vf-mirrors-val-6270",
1454 "vf-broadcast-allow": True,
1455 "vf-unknown-multicast-allow": True,
1456 "vf-unknown-unicast-allow": True,
1457 "vf-insert-stag": True,
1458 "vf-link-status": "example-vf-link-status-val-49266",
1459 "neutron-network-id": "example-neutron-network-id-val-29493"
1466 "interface-name": "example-interface-name-val-98222",
1467 "interface-role": "example-interface-role-val-78360",
1468 "v6-wan-link-ip": "example-v6-wan-link-ip-val-76921",
1469 "selflink": "example-selflink-val-27117",
1470 "interface-id": "example-interface-id-val-11260",
1471 "macaddr": "example-macaddr-val-60378",
1472 "network-name": "example-network-name-val-16258",
1473 "management-option": "example-management-option-val-35097",
1474 "interface-description": "example-interface-description-val-10475",
1475 "is-port-mirrored": True,
1477 "prov-status": "example-prov-status-val-65203",
1478 "is-ip-unnumbered": True,
1479 "allowed-address-pairs": "example-allowed-address-pairs-val-65028"
1483 "l3-interface-ipv4-address-list": [
1485 "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-72779",
1486 "l3-interface-ipv4-prefix-length": 55956636,
1487 "vlan-id-inner": 98174431,
1488 "vlan-id-outer": 20372128,
1489 "is-floating": True,
1490 "neutron-network-id": "example-neutron-network-id-val-39596",
1491 "neutron-subnet-id": "example-neutron-subnet-id-val-51109"
1494 "l3-interface-ipv6-address-list": [
1496 "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-95203",
1497 "l3-interface-ipv6-prefix-length": 57454747,
1498 "vlan-id-inner": 53421060,
1499 "vlan-id-outer": 16006050,
1500 "is-floating": True,
1501 "neutron-network-id": "example-neutron-network-id-val-54216",
1502 "neutron-subnet-id": "example-neutron-subnet-id-val-1841"
1512 "vnfm-id": "example-vnfm-id-val-97336",
1513 "vim-id": "zte_test",
1514 "certificate-url": "example-certificate-url-val-18046",
1515 "resource-version": "example-resource-version-val-42094",
1516 "esr-system-info-list": {
1517 "esr-system-info": [
1519 "esr-system-info-id": "example-esr-system-info-id-val-7713",
1520 "system-name": "example-system-name-val-19801",
1521 "type": "ztevnfmdriver",
1522 "vendor": "example-vendor-val-50079",
1523 "version": "example-version-val-93146",
1524 "service-url": "example-service-url-val-68090",
1525 "user-name": "example-user-name-val-14470",
1526 "password": "example-password-val-84190",
1527 "system-type": "example-system-type-val-42773",
1528 "protocal": "example-protocal-val-85736",
1529 "ssl-cacert": "example-ssl-cacert-val-33989",
1530 "ssl-insecure": True,
1531 "ip-address": "example-ip-address-val-99038",
1532 "port": "example-port-val-27323",
1533 "cloud-domain": "example-cloud-domain-val-55163",
1534 "default-tenant": "example-default-tenant-val-99383",
1535 "resource-version": "example-resource-version-val-15424"
1542 "cloud-owner": "example-cloud-owner-val-97336",
1543 "cloud-region-id": "example-cloud-region-id-val-35532",
1544 "cloud-type": "example-cloud-type-val-18046",
1545 "owner-defined-type": "example-owner-defined-type-val-9413",
1546 "cloud-region-version": "example-cloud-region-version-val-85706",
1547 "identity-url": "example-identity-url-val-71252",
1548 "cloud-zone": "example-cloud-zone-val-27112",
1549 "complex-name": "example-complex-name-val-85283",
1550 "sriov-automation": True,
1551 "cloud-extra-info": "example-cloud-extra-info-val-90854",
1552 "cloud-epa-caps": "example-cloud-epa-caps-val-2409",
1553 "resource-version": "example-resource-version-val-42094",
1554 "esr-system-info-list": {
1555 "esr-system-info": [
1557 "esr-system-info-id": "example-esr-system-info-id-val-7713",
1558 "system-name": "example-system-name-val-19801",
1559 "type": "example-type-val-24477",
1560 "vendor": "example-vendor-val-50079",
1561 "version": "example-version-val-93146",
1562 "service-url": "example-service-url-val-68090",
1563 "user-name": "example-user-name-val-14470",
1564 "password": "example-password-val-84190",
1565 "system-type": "example-system-type-val-42773",
1566 "protocal": "example-protocal-val-85736",
1567 "ssl-cacert": "example-ssl-cacert-val-33989",
1568 "ssl-insecure": True,
1569 "ip-address": "example-ip-address-val-99038",
1570 "port": "example-port-val-27323",
1571 "cloud-domain": "example-cloud-domain-val-55163",
1572 "default-tenant": "admin",
1573 "resource-version": "example-resource-version-val-15424"
1580 "csarId": "zte_vbras",
1583 "vnfPackageId": "zte_vbras",
1584 "vnfdProvider": "1",
1588 "vnfdModel": vnfd_model_dict,
1594 vnf_place_request = {
1595 "requestId": "1234",
1596 "transactionId": "1234",
1597 "statusMessage": "xx",
1598 "requestStatus": "completed",
1600 "placementSolutions": [
1603 "resourceModuleName": "vG",
1604 "serviceResourceId": "1234",
1606 "identifierType": "serviceInstanceId",
1610 "cloudOwner": "CloudOwner1"
1616 {"key": "locationId",
1619 {"key": "locationType",
1620 "value": "openstack-cloud"
1623 "value": "CloudOwner1_DLLSTX1A"
1625 {"key": "physicalLocationId",
1626 "value": "DLLSTX1223"
1628 {"key": "oofDirectives",
1633 "type": "tocsa.nodes.nfv.Vdu.Compute",
1636 "type": "flavor_directive",
1639 "attribute_name": "flavor_name",
1640 "attribute_value": "HPA.flavor.1"
1653 "attribute_name": " ",
1654 "attribute_value": " "
1667 "licenseSolutions": [
1669 "resourceModuleName": "string",
1670 "serviceResourceId": "string",
1671 "entitlementPoolUUID": [
1674 "licenseKeyGroupUUID": [
1677 "entitlementPoolInvariantUUID": [
1680 "licenseKeyGroupInvariantUUID": [