Merge "Fix errors in placeVnf and add test cases"
[vfc/nfvo/lcm.git] / lcm / ns_vnfs / tests / tests.py
1 # Copyright 2016-2017 ZTE Corporation.
2 #
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
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14 import json
15 import uuid
16
17 import mock
18 from django.test import TestCase, Client
19 from rest_framework import status
20
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
35
36
37 class TestGetVnfViews(TestCase):
38     def setUp(self):
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()
43
44     def tearDown(self):
45         NfInstModel.objects.all().delete()
46
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'])
52
53
54 class TestCreateVnfViews(TestCase):
55     def setUp(self):
56         self.ns_inst_id = str(uuid.uuid4())
57         self.job_id = str(uuid.uuid4())
58         self.data = {
59             "nsInstanceId": self.ns_inst_id,
60             "additionalParamForNs": {
61                 "inputs": json.dumps({
62
63                 })
64             },
65             "additionalParamForVnf": [
66                 {
67                     "vnfprofileid": "VBras",
68                     "additionalparam": {
69                         "inputs": json.dumps({
70                             "vnf_param1": "11",
71                             "vnf_param2": "22"
72                         }),
73                         "vnfminstanceid": "1",
74                         "vimId": "zte_test"
75                     }
76                 }
77             ],
78             "vnfIndex": "1"
79         }
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()
84
85     def tearDown(self):
86         NfInstModel.objects.all().delete()
87         JobModel.objects.all().delete()
88
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())
95
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()
99         mock_vals = {
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,
120                                                                       "responseid": "3",
121                                                                       "statusdescription": "creating",
122                                                                       "errorcode": "0",
123                                                                       "responsehistorylist": [
124                                                                           {"progress": "0",
125                                                                            "status": JOB_MODEL_STATUS.PROCESSING,
126                                                                            "responseid": "2",
127                                                                            "statusdescription": "creating",
128                                                                            "errorcode": "0"}]}}), '200']}
129
130         def side_effect(*args):
131             return mock_vals[args[4]]
132         mock_call_req.side_effect = side_effect
133         data = {
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')
138         }
139         CreateVnfs(data, nf_inst_id, job_id).run()
140         self.assertTrue(NfInstModel.objects.get(nfinstid=nf_inst_id).status, VNF_STATUS.ACTIVE)
141
142
143 class TestTerminateVnfViews(TestCase):
144     def setUp(self):
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())
151         self.nf_uuid = '111'
152         self.tenant = "tenantname"
153         self.vnfd_model = {
154             "metadata": {
155                 "vnfdId": "1",
156                 "vnfdName": "PGW001",
157                 "vnfProvider": "zte",
158                 "vnfdVersion": "V00001",
159                 "vnfVersion": "V5.10.20",
160                 "productType": "CN",
161                 "vnfType": "PGW",
162                 "description": "PGW VNFD description",
163                 "isShared": True,
164                 "vnfExtendType": "driver"
165             }
166         }
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,
172                                    nf_name='name_1',
173                                    vnf_id='1',
174                                    vnfm_inst_id='1',
175                                    ns_inst_id='111,2-2-2',
176                                    max_cpu='14',
177                                    max_ram='12296',
178                                    max_hd='101',
179                                    max_shd="20",
180                                    max_net=10,
181                                    status='active',
182                                    mnfinstid=self.nf_uuid,
183                                    package_id='pkg1',
184                                    vnfd_model=self.vnfd_model)
185         VmInstModel.objects.create(vmid="1",
186                                    vimid="zte_test",
187                                    resouceid="1",
188                                    insttype=INST_TYPE.VNF,
189                                    instid=self.nf_inst_id,
190                                    vmname="test",
191                                    hostid='1')
192
193     def tearDown(self):
194         NSInstModel.objects.all().delete()
195         NfInstModel.objects.all().delete()
196
197     @mock.patch.object(TerminateVnfs, 'run')
198     def test_terminate_vnf_url(self, mock_run):
199         req_data = {
200             "terminationType": "forceful",
201             "gracefulTerminationTimeout": "600"}
202
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)
205
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)
209
210         nfinst = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
211         if nfinst:
212             self.failUnlessEqual(1, 1)
213         else:
214             self.failUnlessEqual(1, 0)
215
216         vnf_info = {
217             "vnf-id": "vnf-id-test111",
218             "vnf-name": "vnf-name-test111",
219             "vnf-type": "vnf-type-test111",
220             "in-maint": True,
221             "is-closed-loop-disabled": False,
222             "resource-version": "1505465356262"
223         }
224         job_info = {
225             "jobId": job_id,
226             "responsedescriptor": {
227                 "progress": "100",
228                 "status": JOB_MODEL_STATUS.FINISHED,
229                 "responseid": "3",
230                 "statusdescription": "creating",
231                 "errorcode": "0",
232                 "responsehistorylist": [
233                     {
234                         "progress": "0",
235                         "status": JOB_MODEL_STATUS.PROCESSING,
236                         "responseid": "2",
237                         "statusdescription": "creating",
238                         "errorcode": "0"
239                     }
240                 ]
241             }
242         }
243
244         mock_vals = {
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']
263         }
264
265         def side_effect(*args):
266             return mock_vals[args[4]]
267         mock_call_req.side_effect = side_effect
268
269         req_data = {
270             "terminationType": "forceful",
271             "gracefulTerminationTimeout": "600"
272         }
273
274         TerminateVnfs(req_data, self.nf_inst_id, job_id).run()
275         nfinst = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
276         if nfinst:
277             self.failUnlessEqual(1, 0)
278         else:
279             self.failUnlessEqual(1, 1)
280
281
282 class TestScaleVnfViews(TestCase):
283     def setUp(self):
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())
290         self.nf_uuid = '111'
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"}}')
302
303     def tearDown(self):
304         NSInstModel.objects.all().delete()
305         NfInstModel.objects.all().delete()
306
307     def test_scale_vnf(self):
308         vnfd_info = {
309             "vnf_flavours": [{
310                 "flavour_id": "flavour1",
311                 "description": "",
312                 "vdu_profiles": [
313                     {
314                         "vdu_id": "vdu1Id",
315                         "instances_minimum_number": 1,
316                         "instances_maximum_number": 4,
317                         "local_affinity_antiaffinity_rule": [
318                             {
319                                 "affinity_antiaffinity": "affinity",
320                                 "scope": "node",
321                             }
322                         ]
323                     }
324                 ],
325                 "scaling_aspects": [
326                     {
327                         "id": "demo_aspect",
328                         "name": "demo_aspect",
329                         "description": "demo_aspect",
330                         "associated_group": "elementGroup1",
331                         "max_scale_level": 5
332                     }
333                 ]
334             }],
335             "element_groups": [{
336                 "group_id": "elementGroup1",
337                 "description": "",
338                 "properties": {
339                     "name": "elementGroup1",
340                 },
341                 "members": ["gsu_vm", "pfu_vm"]
342             }]
343         }
344
345         req_data = {
346             "scaleVnfData": [
347                 {
348                     "type": "SCALE_OUT",
349                     "aspectId": "demo_aspect1",
350                     "numberOfSteps": 1,
351                     "additionalParam": vnfd_info
352                 },
353                 {
354                     "type": "SCALE_OUT",
355                     "aspectId": "demo_aspect2",
356                     "numberOfSteps": 1,
357                     "additionalParam": vnfd_info
358                 }
359             ]
360         }
361
362         NFManualScaleService(self.nf_inst_id, req_data).run()
363         nsIns = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
364         self.assertIsNotNone(nsIns)
365
366     @mock.patch.object(NFManualScaleService, "send_nf_scaling_request")
367     def test_scale_vnf_success(self, mock_send_nf_scaling_request):
368         vnfd_info = {
369             "vnf_flavours": [{
370                 "flavour_id": "flavour1",
371                 "description": "",
372                 "vdu_profiles": [
373                     {
374                         "vdu_id": "vdu1Id",
375                         "instances_minimum_number": 1,
376                         "instances_maximum_number": 4,
377                         "local_affinity_antiaffinity_rule": [
378                             {
379                                 "affinity_antiaffinity": "affinity",
380                                 "scope": "node",
381                             }
382                         ]
383                     }
384                 ],
385                 "scaling_aspects": [
386                     {
387                         "id": "demo_aspect",
388                         "name": "demo_aspect",
389                         "description": "demo_aspect",
390                         "associated_group": "elementGroup1",
391                         "max_scale_level": 5
392                     }
393                 ]
394             }],
395             "element_groups": [{
396                 "group_id": "elementGroup1",
397                 "description": "",
398                 "properties": {
399                     "name": "elementGroup1",
400                 },
401                 "members": ["gsu_vm", "pfu_vm"]
402             }]
403         }
404
405         req_data = {
406             "scaleVnfData": [
407                 {
408                     "type": "SCALE_OUT",
409                     "aspectId": "demo_aspect1",
410                     "numberOfSteps": 1,
411                     "additionalParam": vnfd_info
412                 },
413                 {
414                     "type": "SCALE_OUT",
415                     "aspectId": "demo_aspect2",
416                     "numberOfSteps": 1,
417                     "additionalParam": vnfd_info
418                 }
419             ]
420         }
421         scale_service = NFManualScaleService(self.nf_inst_id, req_data)
422         scale_service.run()
423         nsIns = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
424         self.assertIsNotNone(nsIns)
425
426         jobs = JobModel.objects.filter(jobid=scale_service.job_id)
427         self.assertIsNotNone(100, jobs[0].progress)
428
429
430 class TestHealVnfViews(TestCase):
431     def setUp(self):
432         self.client = Client()
433         self.ns_inst_id = str(uuid.uuid4())
434         self.nf_inst_id = str(uuid.uuid4())
435         self.nf_uuid = '111'
436
437         self.job_id = JobUtil.create_job("VNF", JOB_TYPE.HEAL_VNF, self.nf_inst_id)
438
439         NSInstModel(id=self.ns_inst_id, name="ns_name").save()
440         NfInstModel.objects.create(nfinstid=self.nf_inst_id,
441                                    nf_name='name_1',
442                                    vnf_id='1',
443                                    vnfm_inst_id='1',
444                                    ns_inst_id='111,2-2-2',
445                                    max_cpu='14',
446                                    max_ram='12296',
447                                    max_hd='101',
448                                    max_shd="20",
449                                    max_net=10,
450                                    status='active',
451                                    mnfinstid=self.nf_uuid,
452                                    package_id='pkg1',
453                                    vnfd_model=json.dumps({
454                                        "metadata": {
455                                            "vnfdId": "1",
456                                            "vnfdName": "PGW001",
457                                            "vnfProvider": "zte",
458                                            "vnfdVersion": "V00001",
459                                            "vnfVersion": "V5.10.20",
460                                            "productType": "CN",
461                                            "vnfType": "PGW",
462                                            "description": "PGW VNFD description",
463                                            "isShared": True,
464                                            "vnfExtendType": "driver"
465                                        }
466                                    }))
467
468     def tearDown(self):
469         NSInstModel.objects.all().delete()
470         NfInstModel.objects.all().delete()
471
472     @mock.patch.object(restcall, "call_req")
473     def test_heal_vnf(self, mock_call_req):
474
475         mock_vals = {
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": {
486                         "progress": "100",
487                         "status": JOB_MODEL_STATUS.FINISHED,
488                         "responseid": "3",
489                         "statusdescription": "creating",
490                         "errorcode": "0",
491                         "responsehistorylist": [{
492                             "progress": "0",
493                             "status": JOB_MODEL_STATUS.PROCESSING,
494                             "responseid": "2",
495                             "statusdescription": "creating",
496                             "errorcode": "0"
497                         }]
498                     }
499                 }), '200']}
500
501         def side_effect(*args):
502             return mock_vals[args[4]]
503
504         mock_call_req.side_effect = side_effect
505
506         req_data = {
507             "action": "vmReset",
508             "affectedvm": {
509                 "vmid": "1",
510                 "vduid": "1",
511                 "vmname": "name",
512             }
513         }
514
515         NFHealService(self.nf_inst_id, req_data).run()
516
517         self.assertEqual(NfInstModel.objects.get(nfinstid=self.nf_inst_id).status, VNF_STATUS.ACTIVE)
518
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")
522
523         nf_inst_id = "1"
524
525         req_data = {
526             "action": "vmReset",
527             "affectedvm": {
528                 "vmid": "1",
529                 "vduid": "1",
530                 "vmname": "name",
531             }
532         }
533
534         self.assertRaises(NSLCMException, NFHealService(nf_inst_id, req_data).run)
535         self.assertEqual(len(NfInstModel.objects.filter(nfinstid=nf_inst_id)), 0)
536
537
538 class TestGetVnfmInfoViews(TestCase):
539     def setUp(self):
540         self.client = Client()
541         self.vnfm_id = str(uuid.uuid4())
542
543     def tearDown(self):
544         pass
545
546     @mock.patch.object(restcall, "call_req")
547     def test_get_vnfm_info(self, mock_call_req):
548         vnfm_info_aai = {
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": {
553                 "esr-system-info": [
554                     {
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"
571                     }
572                 ]
573             }
574         }
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")
578         expect_data = {
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"),
590             "createTime": ""
591         }
592
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)
597
598
599 class TestGetVimInfoViews(TestCase):
600     def setUp(self):
601         self.client = Client()
602         self.vim_id = "zte_test"
603
604     def tearDown(self):
605         pass
606
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")
612         expect_data = {
613             "vimId": self.vim_id,
614             "name": 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",
623             "domain": "",
624             "type": ignore_case_get(esr_system_info[0], "type"),
625             "createTime": ""
626         }
627
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"])
632
633
634 class TestPlaceVnfViews(TestCase):
635     def setUp(self):
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(
641             request_id="1234",
642             transaction_id="1234",
643             request_status="init",
644             request_module_name=self.vnf_inst_name,
645             service_resource_id=self.vnf_inst_id,
646             vim_id="",
647             cloud_owner="",
648             cloud_region_id="",
649             vdu_info="",
650         )
651
652     def tearDown(self):
653         OOFDataModel.objects.all().delete()
654
655     @mock.patch.object(restcall, 'call_req')
656     def test_place_vnf(self, mock_call_req):
657         vdu_info_json = [{
658             "vduName": "vG_0",
659             "flavorName": "HPA.flavor.1",
660             "directive": []
661         }]
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))
669
670     def test_place_vnf_with_invalid_response(self):
671         resp = {
672             "requestId": "1234",
673             "transactionId": "1234",
674             "statusMessage": "xx",
675             "requestStatus": "pending",
676             "solutions": {
677                 "placementSolutions": [
678                     [
679                         {
680                             "resourceModuleName": self.vnf_inst_name,
681                             "serviceResourceId": self.vnf_inst_id,
682                             "solution": {
683                                 "identifierType": "serviceInstanceId",
684                                 "identifiers": [
685                                     "xx"
686                                 ],
687                                 "cloudOwner": "CloudOwner1 "
688                             },
689                             "assignmentInfo": []
690                         }
691                     ]
692                 ],
693                 "licenseSolutions": [
694                     {
695                         "resourceModuleName": "string",
696                         "serviceResourceId": "string",
697                         "entitlementPoolUUID": [
698                             "string"
699                         ],
700                         "licenseKeyGroupUUID": [
701                             "string"
702                         ],
703                         "entitlementPoolInvariantUUID": [
704                             "string"
705                         ],
706                         "licenseKeyGroupInvariantUUID": [
707                             "string"
708                         ]
709                     }
710                 ]
711             }
712         }
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")
720
721     def test_place_vnf_with_no_assignment_info(self):
722         resp = {
723             "requestId": "1234",
724             "transactionId": "1234",
725             "statusMessage": "xx",
726             "requestStatus": "completed",
727             "solutions": {
728                 "placementSolutions": [
729                     [
730                         {
731                             "resourceModuleName": self.vnf_inst_name,
732                             "serviceResourceId": self.vnf_inst_id,
733                             "solution": {
734                                 "identifierType": "serviceInstanceId",
735                                 "identifiers": [
736                                     "xx"
737                                 ],
738                                 "cloudOwner": "CloudOwner1 "
739                             }
740                         }
741                     ]
742                 ],
743                 "licenseSolutions": [
744                     {
745                         "resourceModuleName": "string",
746                         "serviceResourceId": "string",
747                         "entitlementPoolUUID": [
748                             "string"
749                         ],
750                         "licenseKeyGroupUUID": [
751                             "string"
752                         ],
753                         "entitlementPoolInvariantUUID": [
754                             "string"
755                         ],
756                         "licenseKeyGroupInvariantUUID": [
757                             "string"
758                         ]
759                     }
760                 ]
761             }
762         }
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")
770
771     def test_place_vnf_no_directives(self):
772         resp = {
773             "requestId": "1234",
774             "transactionId": "1234",
775             "statusMessage": "xx",
776             "requestStatus": "completed",
777             "solutions": {
778                 "placementSolutions": [
779                     [
780                         {
781                             "resourceModuleName": self.vnf_inst_name,
782                             "serviceResourceId": self.vnf_inst_id,
783                             "solution": {
784                                 "identifierType": "serviceInstanceId",
785                                 "identifiers": [
786                                     "xx"
787                                 ],
788                                 "cloudOwner": "CloudOwner1 "
789                             },
790                             "assignmentInfo": [
791                                 {"key": "locationId",
792                                  "value": "DLLSTX1A"
793                                  }
794                             ]
795                         }
796                     ]
797                 ],
798                 "licenseSoutions": [
799                     {
800                         "resourceModuleName": "string",
801                         "serviceResourceId": "string",
802                         "entitlementPoolUUID": [
803                             "string"
804                         ],
805                         "licenseKeyGroupUUID": [
806                             "string"
807                         ],
808                         "entitlementPoolInvariantUUID": [
809                             "string"
810                         ],
811                         "licenseKeyGroupInvariantUUID": [
812                             "string"
813                         ]
814                     }
815                 ]
816             }
817         }
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")
825
826     def test_place_vnf_with_no_solution(self):
827         resp = {
828             "requestId": "1234",
829             "transactionId": "1234",
830             "statusMessage": "xx",
831             "requestStatus": "completed",
832             "solutions": {
833                 "placementSolutions": [],
834                 "licenseSoutions": []
835             }
836         }
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")
844
845
846 vnfd_model_dict = {
847     'local_storages': [],
848     'vdus': [
849         {
850             'volumn_storages': [
851
852             ],
853             'nfv_compute': {
854                 'mem_size': '',
855                 'num_cpus': u'2'
856             },
857             'local_storages': [
858
859             ],
860             'vdu_id': u'vdu_omm.001',
861             'image_file': u'opencos_sss_omm_img_release_20150723-1-disk1',
862             'dependencies': [
863
864             ],
865             'vls': [
866
867             ],
868             'cps': [
869
870             ],
871             'properties': {
872                 'key_vdu': '',
873                 'support_scaling': False,
874                 'vdu_type': '',
875                 'name': '',
876                 'storage_policy': '',
877                 'location_info': {
878                     'vimId': '',
879                     'availability_zone': '',
880                     'region': '',
881                     'dc': '',
882                     'host': '',
883                     'tenant': ''
884                 },
885                 'inject_data_list': [
886
887                 ],
888                 'watchdog': {
889                     'action': '',
890                     'enabledelay': ''
891                 },
892                 'local_affinity_antiaffinity_rule': {
893
894                 },
895                 'template_id': u'omm.001',
896                 'manual_scale_select_vim': False
897             },
898             'description': u'singleommvm'
899         },
900         {
901             'volumn_storages': [
902
903             ],
904             'nfv_compute': {
905                 'mem_size': '',
906                 'num_cpus': u'4'
907             },
908             'local_storages': [
909
910             ],
911             'vdu_id': u'vdu_1',
912             'image_file': u'sss',
913             'dependencies': [
914
915             ],
916             'vls': [
917
918             ],
919             'cps': [
920
921             ],
922             'properties': {
923                 'key_vdu': '',
924                 'support_scaling': False,
925                 'vdu_type': '',
926                 'name': '',
927                 'storage_policy': '',
928                 'location_info': {
929                     'vimId': '',
930                     'availability_zone': '',
931                     'region': '',
932                     'dc': '',
933                     'host': '',
934                     'tenant': ''
935                 },
936                 'inject_data_list': [
937
938                 ],
939                 'watchdog': {
940                     'action': '',
941                     'enabledelay': ''
942                 },
943                 'local_affinity_antiaffinity_rule': {
944
945                 },
946                 'template_id': u'1',
947                 'manual_scale_select_vim': False
948             },
949             'description': u'ompvm'
950         },
951         {
952             'volumn_storages': [
953
954             ],
955             'nfv_compute': {
956                 'mem_size': '',
957                 'num_cpus': u'14'
958             },
959             'local_storages': [
960
961             ],
962             'vdu_id': u'vdu_2',
963             'image_file': u'sss',
964             'dependencies': [
965
966             ],
967             'vls': [
968
969             ],
970             'cps': [
971
972             ],
973             'properties': {
974                 'key_vdu': '',
975                 'support_scaling': False,
976                 'vdu_type': '',
977                 'name': '',
978                 'storage_policy': '',
979                 'location_info': {
980                     'vimId': '',
981                     'availability_zone': '',
982                     'region': '',
983                     'dc': '',
984                     'host': '',
985                     'tenant': ''
986                 },
987                 'inject_data_list': [
988
989                 ],
990                 'watchdog': {
991                     'action': '',
992                     'enabledelay': ''
993                 },
994                 'local_affinity_antiaffinity_rule': {
995
996                 },
997                 'template_id': u'2',
998                 'manual_scale_select_vim': False
999             },
1000             'description': u'ompvm'
1001         },
1002         {
1003             'volumn_storages': [
1004
1005             ],
1006             'nfv_compute': {
1007                 'mem_size': '',
1008                 'num_cpus': u'14'
1009             },
1010             'local_storages': [
1011
1012             ],
1013             'vdu_id': u'vdu_3',
1014             'image_file': u'sss',
1015             'dependencies': [
1016
1017             ],
1018             'vls': [
1019
1020             ],
1021             'cps': [
1022
1023             ],
1024             'properties': {
1025                 'key_vdu': '',
1026                 'support_scaling': False,
1027                 'vdu_type': '',
1028                 'name': '',
1029                 'storage_policy': '',
1030                 'location_info': {
1031                     'vimId': '',
1032                     'availability_zone': '',
1033                     'region': '',
1034                     'dc': '',
1035                     'host': '',
1036                     'tenant': ''
1037                 },
1038                 'inject_data_list': [
1039
1040                 ],
1041                 'watchdog': {
1042                     'action': '',
1043                     'enabledelay': ''
1044                 },
1045                 'local_affinity_antiaffinity_rule': {
1046
1047                 },
1048                 'template_id': u'3',
1049                 'manual_scale_select_vim': False
1050             },
1051             'description': u'ompvm'
1052         },
1053         {
1054             'volumn_storages': [
1055
1056             ],
1057             'nfv_compute': {
1058                 'mem_size': '',
1059                 'num_cpus': u'4'
1060             },
1061             'local_storages': [
1062
1063             ],
1064             'vdu_id': u'vdu_10',
1065             'image_file': u'sss',
1066             'dependencies': [
1067
1068             ],
1069             'vls': [
1070
1071             ],
1072             'cps': [
1073
1074             ],
1075             'properties': {
1076                 'key_vdu': '',
1077                 'support_scaling': False,
1078                 'vdu_type': '',
1079                 'name': '',
1080                 'storage_policy': '',
1081                 'location_info': {
1082                     'vimId': '',
1083                     'availability_zone': '',
1084                     'region': '',
1085                     'dc': '',
1086                     'host': '',
1087                     'tenant': ''
1088                 },
1089                 'inject_data_list': [
1090
1091                 ],
1092                 'watchdog': {
1093                     'action': '',
1094                     'enabledelay': ''
1095                 },
1096                 'local_affinity_antiaffinity_rule': {
1097
1098                 },
1099                 'template_id': u'10',
1100                 'manual_scale_select_vim': False
1101             },
1102             'description': u'ppvm'
1103         },
1104         {
1105             'volumn_storages': [
1106
1107             ],
1108             'nfv_compute': {
1109                 'mem_size': '',
1110                 'num_cpus': u'14'
1111             },
1112             'local_storages': [
1113
1114             ],
1115             'vdu_id': u'vdu_11',
1116             'image_file': u'sss',
1117             'dependencies': [
1118
1119             ],
1120             'vls': [
1121
1122             ],
1123             'cps': [
1124
1125             ],
1126             'properties': {
1127                 'key_vdu': '',
1128                 'support_scaling': False,
1129                 'vdu_type': '',
1130                 'name': '',
1131                 'storage_policy': '',
1132                 'location_info': {
1133                     'vimId': '',
1134                     'availability_zone': '',
1135                     'region': '',
1136                     'dc': '',
1137                     'host': '',
1138                     'tenant': ''
1139                 },
1140                 'inject_data_list': [
1141
1142                 ],
1143                 'watchdog': {
1144                     'action': '',
1145                     'enabledelay': ''
1146                 },
1147                 'local_affinity_antiaffinity_rule': {
1148
1149                 },
1150                 'template_id': u'11',
1151                 'manual_scale_select_vim': False
1152             },
1153             'description': u'ppvm'
1154         },
1155         {
1156             'volumn_storages': [
1157
1158             ],
1159             'nfv_compute': {
1160                 'mem_size': '',
1161                 'num_cpus': u'14'
1162             },
1163             'local_storages': [
1164
1165             ],
1166             'vdu_id': u'vdu_12',
1167             'image_file': u'sss',
1168             'dependencies': [
1169
1170             ],
1171             'vls': [
1172
1173             ],
1174             'cps': [
1175
1176             ],
1177             'properties': {
1178                 'key_vdu': '',
1179                 'support_scaling': False,
1180                 'vdu_type': '',
1181                 'name': '',
1182                 'storage_policy': '',
1183                 'location_info': {
1184                     'vimId': '',
1185                     'availability_zone': '',
1186                     'region': '',
1187                     'dc': '',
1188                     'host': '',
1189                     'tenant': ''
1190                 },
1191                 'inject_data_list': [
1192
1193                 ],
1194                 'watchdog': {
1195                     'action': '',
1196                     'enabledelay': ''
1197                 },
1198                 'local_affinity_antiaffinity_rule': {
1199
1200                 },
1201                 'template_id': u'12',
1202                 'manual_scale_select_vim': False
1203             },
1204             'description': u'ppvm'
1205         }
1206     ],
1207     'volumn_storages': [
1208
1209     ],
1210     'policies': {
1211         'scaling': {
1212             'targets': {
1213
1214             },
1215             'policy_id': u'policy_scale_sss-vnf-template',
1216             'properties': {
1217                 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'
1218             },
1219             'description': ''
1220         }
1221     },
1222     'image_files': [
1223         {
1224             'description': '',
1225             'properties': {
1226                 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
1227                 'checksum': '',
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',
1231                 'version': '',
1232                 'hypervisor_type': 'kvm'
1233             },
1234             'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'
1235         },
1236         {
1237             'description': '',
1238             'properties': {
1239                 'name': u'sss.vmdk',
1240                 'checksum': '',
1241                 'disk_format': u'VMDK',
1242                 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
1243                 'container_type': 'vm',
1244                 'version': '',
1245                 'hypervisor_type': 'kvm'
1246             },
1247             'image_file_id': u'sss'
1248         }
1249     ],
1250     'vls': [
1251
1252     ],
1253     'cps': [
1254
1255     ],
1256     'metadata': {
1257         'vendor': u'zte',
1258         'is_shared': False,
1259         'description': '',
1260         'domain_type': u'CN',
1261         'version': u'v4.14.10',
1262         'vmnumber_overquota_alarm': False,
1263         'cross_dc': False,
1264         'vnf_type': u'SSS',
1265         'vnfd_version': u'V00000001',
1266         'id': u'sss-vnf-template',
1267         'name': u'sss-vnf-template'
1268     }
1269 }
1270
1271 nsd_model_dict = {
1272     "vnffgs": [
1273
1274     ],
1275     "inputs": {
1276         "externalDataNetworkName": {
1277             "default": "",
1278             "type": "string",
1279             "description": ""
1280         }
1281     },
1282     "pnfs": [
1283
1284     ],
1285     "fps": [
1286
1287     ],
1288     "server_groups": [
1289
1290     ],
1291     "ns_flavours": [
1292
1293     ],
1294     "vnfs": [
1295         {
1296             "dependency": [
1297
1298             ],
1299             "properties": {
1300                 "plugin_info": "vbrasplugin_1.0",
1301                 "vendor": "zte",
1302                 "is_shared": "False",
1303                 "request_reclassification": "False",
1304                 "vnfd_version": "1.0.0",
1305                 "version": "1.0",
1306                 "nsh_aware": "True",
1307                 "cross_dc": "False",
1308                 "externalDataNetworkName": {
1309                     "get_input": "externalDataNetworkName"
1310                 },
1311                 "id": "zte_vbras",
1312                 "name": "vbras"
1313             },
1314             "vnf_id": "VBras",
1315             "networks": [
1316
1317             ],
1318             "description": ""
1319         }
1320     ],
1321     "ns_exposed": {
1322         "external_cps": [
1323
1324         ],
1325         "forward_cps": [
1326
1327         ]
1328     },
1329     "vls": [
1330         {
1331             "vl_id": "ext_mnet_network",
1332             "description": "",
1333             "properties": {
1334                 "network_type": "vlan",
1335                 "name": "externalMNetworkName",
1336                 "dhcp_enabled": False,
1337                 "location_info": {
1338                     "host": True,
1339                     "vimid": 2,
1340                     "region": True,
1341                     "tenant": "admin",
1342                     "dc": ""
1343                 },
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",
1348                 "mtu": 1500,
1349                 "network_name": "sub_mnet",
1350                 "ip_version": 4
1351             }
1352         }
1353     ],
1354     "cps": [
1355
1356     ],
1357     "policies": [
1358
1359     ],
1360     "metadata": {
1361         "invariant_id": "vbras_ns",
1362         "description": "vbras_ns",
1363         "version": 1,
1364         "vendor": "zte",
1365         "id": "vbras_ns",
1366         "name": "vbras_ns"
1367     }
1368 }
1369
1370 vserver_info = {
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",
1376     "in-maint": True,
1377     "is-closed-loop-disabled": True,
1378     "resource-version": "1505465356263",
1379     "volumes": {
1380         "volume": [
1381             {
1382                 "volume-id": "example-volume-id-val-71854",
1383                 "volume-selflink": "example-volume-selflink-val-22433"
1384             }
1385         ]
1386     },
1387     "l-interfaces": {
1388         "l-interface": [
1389             {
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,
1400                 "in-maint": True,
1401                 "prov-status": "example-prov-status-val-4698",
1402                 "is-ip-unnumbered": True,
1403                 "allowed-address-pairs": "example-allowed-address-pairs-val-5762",
1404                 "vlans": {
1405                     "vlan": [
1406                         {
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",
1416                             "in-maint": True,
1417                             "prov-status": "example-prov-status-val-8288",
1418                             "is-ip-unnumbered": True,
1419                             "l3-interface-ipv4-address-list": [
1420                                 {
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"
1428                                 }
1429                             ],
1430                             "l3-interface-ipv6-address-list": [
1431                                 {
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"
1439                                 }
1440                             ]
1441                         }
1442                     ]
1443                 },
1444                 "sriov-vfs": {
1445                     "sriov-vf": [
1446                         {
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"
1460                         }
1461                     ]
1462                 },
1463                 "l-interfaces": {
1464                     "l-interface": [
1465                         {
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,
1476                             "in-maint": True,
1477                             "prov-status": "example-prov-status-val-65203",
1478                             "is-ip-unnumbered": True,
1479                             "allowed-address-pairs": "example-allowed-address-pairs-val-65028"
1480                         }
1481                     ]
1482                 },
1483                 "l3-interface-ipv4-address-list": [
1484                     {
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"
1492                     }
1493                 ],
1494                 "l3-interface-ipv6-address-list": [
1495                     {
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"
1503                     }
1504                 ]
1505             }
1506         ]
1507     }
1508 }
1509
1510
1511 vnfm_info = {
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": [
1518             {
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"
1536             }
1537         ]
1538     }
1539 }
1540
1541 vim_info = {
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": [
1556             {
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"
1574             }
1575         ]
1576     }
1577 }
1578
1579 nf_package_info = {
1580     "csarId": "zte_vbras",
1581     "packageInfo": {
1582         "vnfdId": "1",
1583         "vnfPackageId": "zte_vbras",
1584         "vnfdProvider": "1",
1585         "vnfdVersion": "1",
1586         "vnfVersion": "1",
1587         "csarName": "1",
1588         "vnfdModel": vnfd_model_dict,
1589         "downloadUrl": "1"
1590     },
1591     "imageInfo": []
1592 }
1593
1594 vnf_place_request = {
1595     "requestId": "1234",
1596     "transactionId": "1234",
1597     "statusMessage": "xx",
1598     "requestStatus": "completed",
1599     "solutions": {
1600         "placementSolutions": [
1601             [
1602                 {
1603                     "resourceModuleName": "vG",
1604                     "serviceResourceId": "1234",
1605                     "solution": {
1606                         "identifierType": "serviceInstanceId",
1607                         "identifiers": [
1608                             "xx"
1609                         ],
1610                         "cloudOwner": "CloudOwner1"
1611                     },
1612                     "assignmentInfo": [
1613                         {"key": "isRehome",
1614                          "value": "false"
1615                          },
1616                         {"key": "locationId",
1617                          "value": "DLLSTX1A"
1618                          },
1619                         {"key": "locationType",
1620                          "value": "openstack-cloud"
1621                          },
1622                         {"key": "vimId",
1623                          "value": "CloudOwner1_DLLSTX1A"
1624                          },
1625                         {"key": "physicalLocationId",
1626                          "value": "DLLSTX1223"
1627                          },
1628                         {"key": "oofDirectives",
1629                          "value": {
1630                              "directives": [
1631                                  {
1632                                      "id": "vG_0",
1633                                      "type": "tocsa.nodes.nfv.Vdu.Compute",
1634                                      "directives": [
1635                                          {
1636                                              "type": "flavor_directive",
1637                                              "attributes": [
1638                                                  {
1639                                                      "attribute_name": "flavor_name",
1640                                                      "attribute_value": "HPA.flavor.1"
1641                                                  }
1642                                              ]
1643                                          }
1644                                      ]
1645                                  },
1646                                  {
1647                                      "id": "",
1648                                      "type": "vnf",
1649                                      "directives": [
1650                                          {"type": " ",
1651                                           "attributes": [
1652                                               {
1653                                                   "attribute_name": " ",
1654                                                   "attribute_value": " "
1655                                               }
1656                                           ]
1657                                           }
1658                                      ]
1659                                  }
1660                              ]
1661                          }
1662                          }
1663                     ]
1664                 }
1665             ]
1666         ],
1667         "licenseSolutions": [
1668             {
1669                 "resourceModuleName": "string",
1670                 "serviceResourceId": "string",
1671                 "entitlementPoolUUID": [
1672                     "string"
1673                 ],
1674                 "licenseKeyGroupUUID": [
1675                     "string"
1676                 ],
1677                 "entitlementPoolInvariantUUID": [
1678                     "string"
1679                 ],
1680                 "licenseKeyGroupInvariantUUID": [
1681                     "string"
1682                 ]
1683             }
1684         ]
1685     }
1686 }