Send homing request to OOF
[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     @mock.patch.object(restcall, 'call_req')
143     @mock.patch.object(CreateVnfs, 'build_homing_request')
144     def test_send_homing_request(self, mock_build_req, mock_call_req):
145         nf_inst_id, job_id = create_vnfs.prepare_create_params()
146         OOFDataModel.objects.all().delete()
147         resp = {
148             "requestId": "1234",
149             "transactionId": "1234",
150             "requestStatus": "accepted"
151         }
152         mock_build_req.return_value = {
153             "requestInfo": {
154                 "transactionId": "1234",
155                 "requestId": "1234",
156                 "callbackUrl": "xx",
157                 "sourceId": "vfc",
158                 "requestType": "create",
159                 "numSolutions": 1,
160                 "optimizers": ["placement"],
161                 "timeout": 600
162             },
163             "placementInfo": {
164                 "placementDemands": [
165                     {
166                         "resourceModuleName": "vG",
167                         "serviceResourceId": "1234",
168                         "resourceModelInfo": {
169                             "modelInvariantId": "1234",
170                             "modelVersionId": "1234"
171                         }
172                     }
173                 ]
174             },
175             "serviceInfo": {
176                 "serviceInstanceId": "1234",
177                 "serviceName": "1234",
178                 "modelInfo": {
179                     "modelInvariantId": "5678",
180                     "modelVersionId": "7890"
181                 }
182             }
183         }
184         mock_call_req.return_value = [0, json.JSONEncoder().encode(resp), '202']
185         data = {
186             'ns_instance_id': ignore_case_get(self.data, 'nsInstanceId'),
187             'additional_param_for_ns': ignore_case_get(self.data, 'additionalParamForNs'),
188             'additional_param_for_vnf': ignore_case_get(self.data, 'additionalParamForVnf'),
189             'vnf_index': ignore_case_get(self.data, 'vnfIndex')
190         }
191         CreateVnfs(data, nf_inst_id, job_id).send_homing_request_to_OOF()
192         ret = OOFDataModel.objects.filter(request_id="1234", transaction_id="1234")
193         self.assertIsNotNone(ret)
194
195
196 class TestTerminateVnfViews(TestCase):
197     def setUp(self):
198         self.client = Client()
199         self.ns_inst_id = str(uuid.uuid4())
200         self.nf_inst_id = '1'
201         self.vnffg_id = str(uuid.uuid4())
202         self.vim_id = str(uuid.uuid4())
203         self.job_id = str(uuid.uuid4())
204         self.nf_uuid = '111'
205         self.tenant = "tenantname"
206         self.vnfd_model = {
207             "metadata": {
208                 "vnfdId": "1",
209                 "vnfdName": "PGW001",
210                 "vnfProvider": "zte",
211                 "vnfdVersion": "V00001",
212                 "vnfVersion": "V5.10.20",
213                 "productType": "CN",
214                 "vnfType": "PGW",
215                 "description": "PGW VNFD description",
216                 "isShared": True,
217                 "vnfExtendType": "driver"
218             }
219         }
220         NSInstModel.objects.all().delete()
221         NfInstModel.objects.all().delete()
222         VmInstModel.objects.all().delete()
223         NSInstModel(id=self.ns_inst_id, name="ns_name").save()
224         NfInstModel.objects.create(nfinstid=self.nf_inst_id,
225                                    nf_name='name_1',
226                                    vnf_id='1',
227                                    vnfm_inst_id='1',
228                                    ns_inst_id='111,2-2-2',
229                                    max_cpu='14',
230                                    max_ram='12296',
231                                    max_hd='101',
232                                    max_shd="20",
233                                    max_net=10,
234                                    status='active',
235                                    mnfinstid=self.nf_uuid,
236                                    package_id='pkg1',
237                                    vnfd_model=self.vnfd_model)
238         VmInstModel.objects.create(vmid="1",
239                                    vimid="zte_test",
240                                    resouceid="1",
241                                    insttype=INST_TYPE.VNF,
242                                    instid=self.nf_inst_id,
243                                    vmname="test",
244                                    hostid='1')
245
246     def tearDown(self):
247         NSInstModel.objects.all().delete()
248         NfInstModel.objects.all().delete()
249
250     @mock.patch.object(TerminateVnfs, 'run')
251     def test_terminate_vnf_url(self, mock_run):
252         req_data = {
253             "terminationType": "forceful",
254             "gracefulTerminationTimeout": "600"}
255
256         response = self.client.post("/api/nslcm/v1/ns/terminatevnf/%s" % self.nf_inst_id, data=req_data)
257         self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code)
258
259     @mock.patch.object(restcall, 'call_req')
260     def test_terminate_vnf(self, mock_call_req):
261         job_id = JobUtil.create_job("VNF", JOB_TYPE.TERMINATE_VNF, self.nf_inst_id)
262
263         nfinst = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
264         if nfinst:
265             self.failUnlessEqual(1, 1)
266         else:
267             self.failUnlessEqual(1, 0)
268
269         vnf_info = {
270             "vnf-id": "vnf-id-test111",
271             "vnf-name": "vnf-name-test111",
272             "vnf-type": "vnf-type-test111",
273             "in-maint": True,
274             "is-closed-loop-disabled": False,
275             "resource-version": "1505465356262"
276         }
277         job_info = {
278             "jobId": job_id,
279             "responsedescriptor": {
280                 "progress": "100",
281                 "status": JOB_MODEL_STATUS.FINISHED,
282                 "responseid": "3",
283                 "statusdescription": "creating",
284                 "errorcode": "0",
285                 "responsehistorylist": [
286                     {
287                         "progress": "0",
288                         "status": JOB_MODEL_STATUS.PROCESSING,
289                         "responseid": "2",
290                         "statusdescription": "creating",
291                         "errorcode": "0"
292                     }
293                 ]
294             }
295         }
296
297         mock_vals = {
298             "/external-system/esr-vnfm-list/esr-vnfm/1?depth=all":
299                 [0, json.JSONEncoder().encode(vnfm_info), '200'],
300             "/api/ztevnfmdriver/v1/1/vnfs/111/terminate":
301                 [0, json.JSONEncoder().encode({"jobId": job_id}), '200'],
302             "/api/resmgr/v1/vnf/1":
303                 [0, json.JSONEncoder().encode({"jobId": job_id}), '200'],
304             "/cloud-infrastructure/cloud-regions/cloud-region/zte/test?depth=all":
305                 [0, json.JSONEncoder().encode(vim_info), '201'],
306             "/cloud-infrastructure/cloud-regions/cloud-region/zte/test/tenants/tenant/admin/vservers/vserver/1?depth=all":
307                 [0, json.JSONEncoder().encode(vserver_info), '201'],
308             "/cloud-infrastructure/cloud-regions/cloud-region/zte/test/tenants/tenant/admin/vservers/vserver/1?resource-version=1505465356263":
309                 [0, json.JSONEncoder().encode({}), '200'],
310             "/api/ztevnfmdriver/v1/1/jobs/" + job_id + "?responseId=0":
311                 [0, json.JSONEncoder().encode(job_info), '200'],
312             "/network/generic-vnfs/generic-vnf/1?depth=all":
313             [0, json.JSONEncoder().encode(vnf_info), '200'],
314             "/network/generic-vnfs/generic-vnf/1?resource-version=1505465356262":
315             [0, json.JSONEncoder().encode({}), '200']
316         }
317
318         def side_effect(*args):
319             return mock_vals[args[4]]
320         mock_call_req.side_effect = side_effect
321
322         req_data = {
323             "terminationType": "forceful",
324             "gracefulTerminationTimeout": "600"
325         }
326
327         TerminateVnfs(req_data, self.nf_inst_id, job_id).run()
328         nfinst = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
329         if nfinst:
330             self.failUnlessEqual(1, 0)
331         else:
332             self.failUnlessEqual(1, 1)
333
334
335 class TestScaleVnfViews(TestCase):
336     def setUp(self):
337         self.client = Client()
338         self.ns_inst_id = str(uuid.uuid4())
339         self.nf_inst_id = str(uuid.uuid4())
340         self.vnffg_id = str(uuid.uuid4())
341         self.vim_id = str(uuid.uuid4())
342         self.job_id = str(uuid.uuid4())
343         self.nf_uuid = '111'
344         self.tenant = "tenantname"
345         NSInstModel(id=self.ns_inst_id, name="ns_name").save()
346         NfInstModel.objects.create(nfinstid=self.nf_inst_id, nf_name='name_1', vnf_id='1',
347                                    vnfm_inst_id='1', ns_inst_id='111,2-2-2',
348                                    max_cpu='14', max_ram='12296', max_hd='101', max_shd="20", max_net=10,
349                                    status='active', mnfinstid=self.nf_uuid, package_id='pkg1',
350                                    vnfd_model='{"metadata": {"vnfdId": "1","vnfdName": "PGW001",'
351                                               '"vnfProvider": "zte","vnfdVersion": "V00001","vnfVersion": "V5.10.20",'
352                                               '"productType": "CN","vnfType": "PGW",'
353                                               '"description": "PGW VNFD description",'
354                                               '"isShared":true,"vnfExtendType":"driver"}}')
355
356     def tearDown(self):
357         NSInstModel.objects.all().delete()
358         NfInstModel.objects.all().delete()
359
360     def test_scale_vnf(self):
361         vnfd_info = {
362             "vnf_flavours": [{
363                 "flavour_id": "flavour1",
364                 "description": "",
365                 "vdu_profiles": [
366                     {
367                         "vdu_id": "vdu1Id",
368                         "instances_minimum_number": 1,
369                         "instances_maximum_number": 4,
370                         "local_affinity_antiaffinity_rule": [
371                             {
372                                 "affinity_antiaffinity": "affinity",
373                                 "scope": "node",
374                             }
375                         ]
376                     }
377                 ],
378                 "scaling_aspects": [
379                     {
380                         "id": "demo_aspect",
381                         "name": "demo_aspect",
382                         "description": "demo_aspect",
383                         "associated_group": "elementGroup1",
384                         "max_scale_level": 5
385                     }
386                 ]
387             }],
388             "element_groups": [{
389                 "group_id": "elementGroup1",
390                 "description": "",
391                 "properties": {
392                     "name": "elementGroup1",
393                 },
394                 "members": ["gsu_vm", "pfu_vm"]
395             }]
396         }
397
398         req_data = {
399             "scaleVnfData": [
400                 {
401                     "type": "SCALE_OUT",
402                     "aspectId": "demo_aspect1",
403                     "numberOfSteps": 1,
404                     "additionalParam": vnfd_info
405                 },
406                 {
407                     "type": "SCALE_OUT",
408                     "aspectId": "demo_aspect2",
409                     "numberOfSteps": 1,
410                     "additionalParam": vnfd_info
411                 }
412             ]
413         }
414
415         NFManualScaleService(self.nf_inst_id, req_data).run()
416         nsIns = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
417         self.assertIsNotNone(nsIns)
418
419     @mock.patch.object(NFManualScaleService, "send_nf_scaling_request")
420     def test_scale_vnf_success(self, mock_send_nf_scaling_request):
421         vnfd_info = {
422             "vnf_flavours": [{
423                 "flavour_id": "flavour1",
424                 "description": "",
425                 "vdu_profiles": [
426                     {
427                         "vdu_id": "vdu1Id",
428                         "instances_minimum_number": 1,
429                         "instances_maximum_number": 4,
430                         "local_affinity_antiaffinity_rule": [
431                             {
432                                 "affinity_antiaffinity": "affinity",
433                                 "scope": "node",
434                             }
435                         ]
436                     }
437                 ],
438                 "scaling_aspects": [
439                     {
440                         "id": "demo_aspect",
441                         "name": "demo_aspect",
442                         "description": "demo_aspect",
443                         "associated_group": "elementGroup1",
444                         "max_scale_level": 5
445                     }
446                 ]
447             }],
448             "element_groups": [{
449                 "group_id": "elementGroup1",
450                 "description": "",
451                 "properties": {
452                     "name": "elementGroup1",
453                 },
454                 "members": ["gsu_vm", "pfu_vm"]
455             }]
456         }
457
458         req_data = {
459             "scaleVnfData": [
460                 {
461                     "type": "SCALE_OUT",
462                     "aspectId": "demo_aspect1",
463                     "numberOfSteps": 1,
464                     "additionalParam": vnfd_info
465                 },
466                 {
467                     "type": "SCALE_OUT",
468                     "aspectId": "demo_aspect2",
469                     "numberOfSteps": 1,
470                     "additionalParam": vnfd_info
471                 }
472             ]
473         }
474         scale_service = NFManualScaleService(self.nf_inst_id, req_data)
475         scale_service.run()
476         nsIns = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
477         self.assertIsNotNone(nsIns)
478
479         jobs = JobModel.objects.filter(jobid=scale_service.job_id)
480         self.assertIsNotNone(100, jobs[0].progress)
481
482
483 class TestHealVnfViews(TestCase):
484     def setUp(self):
485         self.client = Client()
486         self.ns_inst_id = str(uuid.uuid4())
487         self.nf_inst_id = str(uuid.uuid4())
488         self.nf_uuid = '111'
489
490         self.job_id = JobUtil.create_job("VNF", JOB_TYPE.HEAL_VNF, self.nf_inst_id)
491
492         NSInstModel(id=self.ns_inst_id, name="ns_name").save()
493         NfInstModel.objects.create(nfinstid=self.nf_inst_id,
494                                    nf_name='name_1',
495                                    vnf_id='1',
496                                    vnfm_inst_id='1',
497                                    ns_inst_id='111,2-2-2',
498                                    max_cpu='14',
499                                    max_ram='12296',
500                                    max_hd='101',
501                                    max_shd="20",
502                                    max_net=10,
503                                    status='active',
504                                    mnfinstid=self.nf_uuid,
505                                    package_id='pkg1',
506                                    vnfd_model=json.dumps({
507                                        "metadata": {
508                                            "vnfdId": "1",
509                                            "vnfdName": "PGW001",
510                                            "vnfProvider": "zte",
511                                            "vnfdVersion": "V00001",
512                                            "vnfVersion": "V5.10.20",
513                                            "productType": "CN",
514                                            "vnfType": "PGW",
515                                            "description": "PGW VNFD description",
516                                            "isShared": True,
517                                            "vnfExtendType": "driver"
518                                        }
519                                    }))
520
521     def tearDown(self):
522         NSInstModel.objects.all().delete()
523         NfInstModel.objects.all().delete()
524
525     @mock.patch.object(restcall, "call_req")
526     def test_heal_vnf(self, mock_call_req):
527
528         mock_vals = {
529             "/api/ztevnfmdriver/v1/1/vnfs/111/heal":
530                 [0, json.JSONEncoder().encode({"jobId": self.job_id}), '200'],
531             "/external-system/esr-vnfm-list/esr-vnfm/1":
532                 [0, json.JSONEncoder().encode(vnfm_info), '200'],
533             "/api/resmgr/v1/vnf/1":
534                 [0, json.JSONEncoder().encode({"jobId": self.job_id}), '200'],
535             "/api/ztevnfmdriver/v1/1/jobs/" + self.job_id + "?responseId=0":
536                 [0, json.JSONEncoder().encode({
537                     "jobId": self.job_id,
538                     "responsedescriptor": {
539                         "progress": "100",
540                         "status": JOB_MODEL_STATUS.FINISHED,
541                         "responseid": "3",
542                         "statusdescription": "creating",
543                         "errorcode": "0",
544                         "responsehistorylist": [{
545                             "progress": "0",
546                             "status": JOB_MODEL_STATUS.PROCESSING,
547                             "responseid": "2",
548                             "statusdescription": "creating",
549                             "errorcode": "0"
550                         }]
551                     }
552                 }), '200']}
553
554         def side_effect(*args):
555             return mock_vals[args[4]]
556
557         mock_call_req.side_effect = side_effect
558
559         req_data = {
560             "action": "vmReset",
561             "affectedvm": {
562                 "vmid": "1",
563                 "vduid": "1",
564                 "vmname": "name",
565             }
566         }
567
568         NFHealService(self.nf_inst_id, req_data).run()
569
570         self.assertEqual(NfInstModel.objects.get(nfinstid=self.nf_inst_id).status, VNF_STATUS.ACTIVE)
571
572     @mock.patch.object(NFHealService, "run")
573     def test_heal_vnf_non_existing_vnf(self, mock_biz):
574         mock_biz.side_effect = NSLCMException("VNF Not Found")
575
576         nf_inst_id = "1"
577
578         req_data = {
579             "action": "vmReset",
580             "affectedvm": {
581                 "vmid": "1",
582                 "vduid": "1",
583                 "vmname": "name",
584             }
585         }
586
587         self.assertRaises(NSLCMException, NFHealService(nf_inst_id, req_data).run)
588         self.assertEqual(len(NfInstModel.objects.filter(nfinstid=nf_inst_id)), 0)
589
590
591 class TestGetVnfmInfoViews(TestCase):
592     def setUp(self):
593         self.client = Client()
594         self.vnfm_id = str(uuid.uuid4())
595
596     def tearDown(self):
597         pass
598
599     @mock.patch.object(restcall, "call_req")
600     def test_get_vnfm_info(self, mock_call_req):
601         vnfm_info_aai = {
602             "vnfm-id": "example-vnfm-id-val-62576",
603             "vim-id": "example-vim-id-val-35114",
604             "certificate-url": "example-certificate-url-val-90242",
605             "esr-system-info-list": {
606                 "esr-system-info": [
607                     {
608                         "esr-system-info-id": "example-esr-system-info-id-val-78484",
609                         "system-name": "example-system-name-val-23790",
610                         "type": "example-type-val-52596",
611                         "vendor": "example-vendor-val-47399",
612                         "version": "example-version-val-42051",
613                         "service-url": "example-service-url-val-10731",
614                         "user-name": "example-user-name-val-65946",
615                         "password": "example-password-val-22505",
616                         "system-type": "example-system-type-val-27221",
617                         "protocal": "example-protocal-val-54632",
618                         "ssl-cacert": "example-ssl-cacert-val-45965",
619                         "ssl-insecure": True,
620                         "ip-address": "example-ip-address-val-19212",
621                         "port": "example-port-val-57641",
622                         "cloud-domain": "example-cloud-domain-val-26296",
623                         "default-tenant": "example-default-tenant-val-87724"
624                     }
625                 ]
626             }
627         }
628         r1 = [0, json.JSONEncoder().encode(vnfm_info_aai), '200']
629         mock_call_req.side_effect = [r1]
630         esr_system_info = ignore_case_get(ignore_case_get(vnfm_info_aai, "esr-system-info-list"), "esr-system-info")
631         expect_data = {
632             "vnfmId": vnfm_info_aai["vnfm-id"],
633             "name": vnfm_info_aai["vnfm-id"],
634             "type": ignore_case_get(esr_system_info[0], "type"),
635             "vimId": vnfm_info_aai["vim-id"],
636             "vendor": ignore_case_get(esr_system_info[0], "vendor"),
637             "version": ignore_case_get(esr_system_info[0], "version"),
638             "description": "vnfm",
639             "certificateUrl": vnfm_info_aai["certificate-url"],
640             "url": ignore_case_get(esr_system_info[0], "service-url"),
641             "userName": ignore_case_get(esr_system_info[0], "user-name"),
642             "password": ignore_case_get(esr_system_info[0], "password"),
643             "createTime": ""
644         }
645
646         response = self.client.get("/api/nslcm/v1/vnfms/%s" % self.vnfm_id)
647         self.failUnlessEqual(status.HTTP_200_OK, response.status_code, response.content)
648         context = json.loads(response.content)
649         self.assertEqual(expect_data, context)
650
651
652 class TestGetVimInfoViews(TestCase):
653     def setUp(self):
654         self.client = Client()
655         self.vim_id = "zte_test"
656
657     def tearDown(self):
658         pass
659
660     @mock.patch.object(restcall, "call_req")
661     def test_get_vim_info(self, mock_call_req):
662         r1 = [0, json.JSONEncoder().encode(vim_info), '200']
663         mock_call_req.side_effect = [r1]
664         esr_system_info = ignore_case_get(ignore_case_get(vim_info, "esr-system-info-list"), "esr-system-info")
665         expect_data = {
666             "vimId": self.vim_id,
667             "name": self.vim_id,
668             "url": ignore_case_get(esr_system_info[0], "service-url"),
669             "userName": ignore_case_get(esr_system_info[0], "user-name"),
670             "password": ignore_case_get(esr_system_info[0], "password"),
671             # "tenant": ignore_case_get(tenants[0], "tenant-id"),
672             "tenant": ignore_case_get(esr_system_info[0], "default-tenant"),
673             "vendor": ignore_case_get(esr_system_info[0], "vendor"),
674             "version": ignore_case_get(esr_system_info[0], "version"),
675             "description": "vim",
676             "domain": "",
677             "type": ignore_case_get(esr_system_info[0], "type"),
678             "createTime": ""
679         }
680
681         response = self.client.get("/api/nslcm/v1/vims/%s" % self.vim_id)
682         self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
683         context = json.loads(response.content)
684         self.assertEqual(expect_data["url"], context["url"])
685
686
687 class TestPlaceVnfViews(TestCase):
688     def setUp(self):
689         self.vnf_inst_id = "1234"
690         self.vnf_inst_name = "vG"
691         self.client = Client()
692         OOFDataModel.objects.all().delete()
693         OOFDataModel.objects.create(
694             request_id="1234",
695             transaction_id="1234",
696             request_status="init",
697             request_module_name=self.vnf_inst_name,
698             service_resource_id=self.vnf_inst_id,
699             vim_id="",
700             cloud_owner="",
701             cloud_region_id="",
702             vdu_info="",
703         )
704
705     def tearDown(self):
706         OOFDataModel.objects.all().delete()
707
708     @mock.patch.object(restcall, 'call_req')
709     def test_place_vnf(self, mock_call_req):
710         vdu_info_json = [{
711             "vduName": "vG_0",
712             "flavorName": "HPA.flavor.1",
713             "directive": []
714         }]
715         PlaceVnfs(vnf_place_request).extract()
716         db_info = OOFDataModel.objects.filter(request_id=vnf_place_request.get("requestId"), transaction_id=vnf_place_request.get("transactionId"))
717         self.assertEqual(db_info[0].request_status, "completed")
718         self.assertEqual(db_info[0].vim_id, "CloudOwner1_DLLSTX1A")
719         self.assertEqual(db_info[0].cloud_owner, "CloudOwner1")
720         self.assertEqual(db_info[0].cloud_region_id, "DLLSTX1A")
721         self.assertEqual(db_info[0].vdu_info, json.dumps(vdu_info_json))
722
723     def test_place_vnf_with_invalid_response(self):
724         resp = {
725             "requestId": "1234",
726             "transactionId": "1234",
727             "statusMessage": "xx",
728             "requestStatus": "pending",
729             "solutions": {
730                 "placementSolutions": [
731                     [
732                         {
733                             "resourceModuleName": self.vnf_inst_name,
734                             "serviceResourceId": self.vnf_inst_id,
735                             "solution": {
736                                 "identifierType": "serviceInstanceId",
737                                 "identifiers": [
738                                     "xx"
739                                 ],
740                                 "cloudOwner": "CloudOwner1 "
741                             },
742                             "assignmentInfo": []
743                         }
744                     ]
745                 ],
746                 "licenseSolutions": [
747                     {
748                         "resourceModuleName": "string",
749                         "serviceResourceId": "string",
750                         "entitlementPoolUUID": [
751                             "string"
752                         ],
753                         "licenseKeyGroupUUID": [
754                             "string"
755                         ],
756                         "entitlementPoolInvariantUUID": [
757                             "string"
758                         ],
759                         "licenseKeyGroupInvariantUUID": [
760                             "string"
761                         ]
762                     }
763                 ]
764             }
765         }
766         PlaceVnfs(resp).extract()
767         db_info = OOFDataModel.objects.filter(request_id=resp.get("requestId"), transaction_id=resp.get("transactionId"))
768         self.assertEqual(db_info[0].request_status, "pending")
769         self.assertEqual(db_info[0].vim_id, "none")
770         self.assertEqual(db_info[0].cloud_owner, "none")
771         self.assertEqual(db_info[0].cloud_region_id, "none")
772         self.assertEqual(db_info[0].vdu_info, "none")
773
774     def test_place_vnf_with_no_assignment_info(self):
775         resp = {
776             "requestId": "1234",
777             "transactionId": "1234",
778             "statusMessage": "xx",
779             "requestStatus": "completed",
780             "solutions": {
781                 "placementSolutions": [
782                     [
783                         {
784                             "resourceModuleName": self.vnf_inst_name,
785                             "serviceResourceId": self.vnf_inst_id,
786                             "solution": {
787                                 "identifierType": "serviceInstanceId",
788                                 "identifiers": [
789                                     "xx"
790                                 ],
791                                 "cloudOwner": "CloudOwner1 "
792                             }
793                         }
794                     ]
795                 ],
796                 "licenseSolutions": [
797                     {
798                         "resourceModuleName": "string",
799                         "serviceResourceId": "string",
800                         "entitlementPoolUUID": [
801                             "string"
802                         ],
803                         "licenseKeyGroupUUID": [
804                             "string"
805                         ],
806                         "entitlementPoolInvariantUUID": [
807                             "string"
808                         ],
809                         "licenseKeyGroupInvariantUUID": [
810                             "string"
811                         ]
812                     }
813                 ]
814             }
815         }
816         PlaceVnfs(resp).extract()
817         db_info = OOFDataModel.objects.filter(request_id=resp.get("requestId"), transaction_id=resp.get("transactionId"))
818         self.assertEqual(db_info[0].request_status, "completed")
819         self.assertEqual(db_info[0].vim_id, "none")
820         self.assertEqual(db_info[0].cloud_owner, "none")
821         self.assertEqual(db_info[0].cloud_region_id, "none")
822         self.assertEqual(db_info[0].vdu_info, "none")
823
824     def test_place_vnf_no_directives(self):
825         resp = {
826             "requestId": "1234",
827             "transactionId": "1234",
828             "statusMessage": "xx",
829             "requestStatus": "completed",
830             "solutions": {
831                 "placementSolutions": [
832                     [
833                         {
834                             "resourceModuleName": self.vnf_inst_name,
835                             "serviceResourceId": self.vnf_inst_id,
836                             "solution": {
837                                 "identifierType": "serviceInstanceId",
838                                 "identifiers": [
839                                     "xx"
840                                 ],
841                                 "cloudOwner": "CloudOwner1 "
842                             },
843                             "assignmentInfo": [
844                                 {"key": "locationId",
845                                  "value": "DLLSTX1A"
846                                  }
847                             ]
848                         }
849                     ]
850                 ],
851                 "licenseSoutions": [
852                     {
853                         "resourceModuleName": "string",
854                         "serviceResourceId": "string",
855                         "entitlementPoolUUID": [
856                             "string"
857                         ],
858                         "licenseKeyGroupUUID": [
859                             "string"
860                         ],
861                         "entitlementPoolInvariantUUID": [
862                             "string"
863                         ],
864                         "licenseKeyGroupInvariantUUID": [
865                             "string"
866                         ]
867                     }
868                 ]
869             }
870         }
871         PlaceVnfs(resp).extract()
872         db_info = OOFDataModel.objects.filter(request_id=resp.get("requestId"), transaction_id=resp.get("transactionId"))
873         self.assertEqual(db_info[0].request_status, "completed")
874         self.assertEqual(db_info[0].vim_id, "none")
875         self.assertEqual(db_info[0].cloud_owner, "none")
876         self.assertEqual(db_info[0].cloud_region_id, "none")
877         self.assertEqual(db_info[0].vdu_info, "none")
878
879     def test_place_vnf_with_no_solution(self):
880         resp = {
881             "requestId": "1234",
882             "transactionId": "1234",
883             "statusMessage": "xx",
884             "requestStatus": "completed",
885             "solutions": {
886                 "placementSolutions": [],
887                 "licenseSoutions": []
888             }
889         }
890         PlaceVnfs(resp).extract()
891         db_info = OOFDataModel.objects.filter(request_id=resp.get("requestId"), transaction_id=resp.get("transactionId"))
892         self.assertEqual(db_info[0].request_status, "completed")
893         self.assertEqual(db_info[0].vim_id, "no-solution")
894         self.assertEqual(db_info[0].cloud_owner, "no-solution")
895         self.assertEqual(db_info[0].cloud_region_id, "no-solution")
896         self.assertEqual(db_info[0].vdu_info, "no-solution")
897
898
899 vnfd_model_dict = {
900     'local_storages': [],
901     'vdus': [
902         {
903             'volumn_storages': [
904
905             ],
906             'nfv_compute': {
907                 'mem_size': '',
908                 'num_cpus': u'2'
909             },
910             'local_storages': [
911
912             ],
913             'vdu_id': u'vdu_omm.001',
914             'image_file': u'opencos_sss_omm_img_release_20150723-1-disk1',
915             'dependencies': [
916
917             ],
918             'vls': [
919
920             ],
921             'cps': [
922
923             ],
924             'properties': {
925                 'key_vdu': '',
926                 'support_scaling': False,
927                 'vdu_type': '',
928                 'name': '',
929                 'storage_policy': '',
930                 'location_info': {
931                     'vimId': '',
932                     'availability_zone': '',
933                     'region': '',
934                     'dc': '',
935                     'host': '',
936                     'tenant': ''
937                 },
938                 'inject_data_list': [
939
940                 ],
941                 'watchdog': {
942                     'action': '',
943                     'enabledelay': ''
944                 },
945                 'local_affinity_antiaffinity_rule': {
946
947                 },
948                 'template_id': u'omm.001',
949                 'manual_scale_select_vim': False
950             },
951             'description': u'singleommvm'
952         },
953         {
954             'volumn_storages': [
955
956             ],
957             'nfv_compute': {
958                 'mem_size': '',
959                 'num_cpus': u'4'
960             },
961             'local_storages': [
962
963             ],
964             'vdu_id': u'vdu_1',
965             'image_file': u'sss',
966             'dependencies': [
967
968             ],
969             'vls': [
970
971             ],
972             'cps': [
973
974             ],
975             'properties': {
976                 'key_vdu': '',
977                 'support_scaling': False,
978                 'vdu_type': '',
979                 'name': '',
980                 'storage_policy': '',
981                 'location_info': {
982                     'vimId': '',
983                     'availability_zone': '',
984                     'region': '',
985                     'dc': '',
986                     'host': '',
987                     'tenant': ''
988                 },
989                 'inject_data_list': [
990
991                 ],
992                 'watchdog': {
993                     'action': '',
994                     'enabledelay': ''
995                 },
996                 'local_affinity_antiaffinity_rule': {
997
998                 },
999                 'template_id': u'1',
1000                 'manual_scale_select_vim': False
1001             },
1002             'description': u'ompvm'
1003         },
1004         {
1005             'volumn_storages': [
1006
1007             ],
1008             'nfv_compute': {
1009                 'mem_size': '',
1010                 'num_cpus': u'14'
1011             },
1012             'local_storages': [
1013
1014             ],
1015             'vdu_id': u'vdu_2',
1016             'image_file': u'sss',
1017             'dependencies': [
1018
1019             ],
1020             'vls': [
1021
1022             ],
1023             'cps': [
1024
1025             ],
1026             'properties': {
1027                 'key_vdu': '',
1028                 'support_scaling': False,
1029                 'vdu_type': '',
1030                 'name': '',
1031                 'storage_policy': '',
1032                 'location_info': {
1033                     'vimId': '',
1034                     'availability_zone': '',
1035                     'region': '',
1036                     'dc': '',
1037                     'host': '',
1038                     'tenant': ''
1039                 },
1040                 'inject_data_list': [
1041
1042                 ],
1043                 'watchdog': {
1044                     'action': '',
1045                     'enabledelay': ''
1046                 },
1047                 'local_affinity_antiaffinity_rule': {
1048
1049                 },
1050                 'template_id': u'2',
1051                 'manual_scale_select_vim': False
1052             },
1053             'description': u'ompvm'
1054         },
1055         {
1056             'volumn_storages': [
1057
1058             ],
1059             'nfv_compute': {
1060                 'mem_size': '',
1061                 'num_cpus': u'14'
1062             },
1063             'local_storages': [
1064
1065             ],
1066             'vdu_id': u'vdu_3',
1067             'image_file': u'sss',
1068             'dependencies': [
1069
1070             ],
1071             'vls': [
1072
1073             ],
1074             'cps': [
1075
1076             ],
1077             'properties': {
1078                 'key_vdu': '',
1079                 'support_scaling': False,
1080                 'vdu_type': '',
1081                 'name': '',
1082                 'storage_policy': '',
1083                 'location_info': {
1084                     'vimId': '',
1085                     'availability_zone': '',
1086                     'region': '',
1087                     'dc': '',
1088                     'host': '',
1089                     'tenant': ''
1090                 },
1091                 'inject_data_list': [
1092
1093                 ],
1094                 'watchdog': {
1095                     'action': '',
1096                     'enabledelay': ''
1097                 },
1098                 'local_affinity_antiaffinity_rule': {
1099
1100                 },
1101                 'template_id': u'3',
1102                 'manual_scale_select_vim': False
1103             },
1104             'description': u'ompvm'
1105         },
1106         {
1107             'volumn_storages': [
1108
1109             ],
1110             'nfv_compute': {
1111                 'mem_size': '',
1112                 'num_cpus': u'4'
1113             },
1114             'local_storages': [
1115
1116             ],
1117             'vdu_id': u'vdu_10',
1118             'image_file': u'sss',
1119             'dependencies': [
1120
1121             ],
1122             'vls': [
1123
1124             ],
1125             'cps': [
1126
1127             ],
1128             'properties': {
1129                 'key_vdu': '',
1130                 'support_scaling': False,
1131                 'vdu_type': '',
1132                 'name': '',
1133                 'storage_policy': '',
1134                 'location_info': {
1135                     'vimId': '',
1136                     'availability_zone': '',
1137                     'region': '',
1138                     'dc': '',
1139                     'host': '',
1140                     'tenant': ''
1141                 },
1142                 'inject_data_list': [
1143
1144                 ],
1145                 'watchdog': {
1146                     'action': '',
1147                     'enabledelay': ''
1148                 },
1149                 'local_affinity_antiaffinity_rule': {
1150
1151                 },
1152                 'template_id': u'10',
1153                 'manual_scale_select_vim': False
1154             },
1155             'description': u'ppvm'
1156         },
1157         {
1158             'volumn_storages': [
1159
1160             ],
1161             'nfv_compute': {
1162                 'mem_size': '',
1163                 'num_cpus': u'14'
1164             },
1165             'local_storages': [
1166
1167             ],
1168             'vdu_id': u'vdu_11',
1169             'image_file': u'sss',
1170             'dependencies': [
1171
1172             ],
1173             'vls': [
1174
1175             ],
1176             'cps': [
1177
1178             ],
1179             'properties': {
1180                 'key_vdu': '',
1181                 'support_scaling': False,
1182                 'vdu_type': '',
1183                 'name': '',
1184                 'storage_policy': '',
1185                 'location_info': {
1186                     'vimId': '',
1187                     'availability_zone': '',
1188                     'region': '',
1189                     'dc': '',
1190                     'host': '',
1191                     'tenant': ''
1192                 },
1193                 'inject_data_list': [
1194
1195                 ],
1196                 'watchdog': {
1197                     'action': '',
1198                     'enabledelay': ''
1199                 },
1200                 'local_affinity_antiaffinity_rule': {
1201
1202                 },
1203                 'template_id': u'11',
1204                 'manual_scale_select_vim': False
1205             },
1206             'description': u'ppvm'
1207         },
1208         {
1209             'volumn_storages': [
1210
1211             ],
1212             'nfv_compute': {
1213                 'mem_size': '',
1214                 'num_cpus': u'14'
1215             },
1216             'local_storages': [
1217
1218             ],
1219             'vdu_id': u'vdu_12',
1220             'image_file': u'sss',
1221             'dependencies': [
1222
1223             ],
1224             'vls': [
1225
1226             ],
1227             'cps': [
1228
1229             ],
1230             'properties': {
1231                 'key_vdu': '',
1232                 'support_scaling': False,
1233                 'vdu_type': '',
1234                 'name': '',
1235                 'storage_policy': '',
1236                 'location_info': {
1237                     'vimId': '',
1238                     'availability_zone': '',
1239                     'region': '',
1240                     'dc': '',
1241                     'host': '',
1242                     'tenant': ''
1243                 },
1244                 'inject_data_list': [
1245
1246                 ],
1247                 'watchdog': {
1248                     'action': '',
1249                     'enabledelay': ''
1250                 },
1251                 'local_affinity_antiaffinity_rule': {
1252
1253                 },
1254                 'template_id': u'12',
1255                 'manual_scale_select_vim': False
1256             },
1257             'description': u'ppvm'
1258         }
1259     ],
1260     'volumn_storages': [
1261
1262     ],
1263     'policies': {
1264         'scaling': {
1265             'targets': {
1266
1267             },
1268             'policy_id': u'policy_scale_sss-vnf-template',
1269             'properties': {
1270                 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'
1271             },
1272             'description': ''
1273         }
1274     },
1275     'image_files': [
1276         {
1277             'description': '',
1278             'properties': {
1279                 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
1280                 'checksum': '',
1281                 'disk_format': u'VMDK',
1282                 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
1283                 'container_type': 'vm',
1284                 'version': '',
1285                 'hypervisor_type': 'kvm'
1286             },
1287             'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'
1288         },
1289         {
1290             'description': '',
1291             'properties': {
1292                 'name': u'sss.vmdk',
1293                 'checksum': '',
1294                 'disk_format': u'VMDK',
1295                 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
1296                 'container_type': 'vm',
1297                 'version': '',
1298                 'hypervisor_type': 'kvm'
1299             },
1300             'image_file_id': u'sss'
1301         }
1302     ],
1303     'vls': [
1304
1305     ],
1306     'cps': [
1307
1308     ],
1309     'metadata': {
1310         'vendor': u'zte',
1311         'is_shared': False,
1312         'description': '',
1313         'domain_type': u'CN',
1314         'version': u'v4.14.10',
1315         'vmnumber_overquota_alarm': False,
1316         'cross_dc': False,
1317         'vnf_type': u'SSS',
1318         'vnfd_version': u'V00000001',
1319         'id': u'sss-vnf-template',
1320         'name': u'sss-vnf-template'
1321     }
1322 }
1323
1324 nsd_model_dict = {
1325     "vnffgs": [
1326
1327     ],
1328     "inputs": {
1329         "externalDataNetworkName": {
1330             "default": "",
1331             "type": "string",
1332             "description": ""
1333         }
1334     },
1335     "pnfs": [
1336
1337     ],
1338     "fps": [
1339
1340     ],
1341     "server_groups": [
1342
1343     ],
1344     "ns_flavours": [
1345
1346     ],
1347     "vnfs": [
1348         {
1349             "dependency": [
1350
1351             ],
1352             "properties": {
1353                 "plugin_info": "vbrasplugin_1.0",
1354                 "vendor": "zte",
1355                 "is_shared": "False",
1356                 "request_reclassification": "False",
1357                 "vnfd_version": "1.0.0",
1358                 "version": "1.0",
1359                 "nsh_aware": "True",
1360                 "cross_dc": "False",
1361                 "externalDataNetworkName": {
1362                     "get_input": "externalDataNetworkName"
1363                 },
1364                 "id": "zte_vbras",
1365                 "name": "vbras"
1366             },
1367             "vnf_id": "VBras",
1368             "networks": [
1369
1370             ],
1371             "description": ""
1372         }
1373     ],
1374     "ns_exposed": {
1375         "external_cps": [
1376
1377         ],
1378         "forward_cps": [
1379
1380         ]
1381     },
1382     "vls": [
1383         {
1384             "vl_id": "ext_mnet_network",
1385             "description": "",
1386             "properties": {
1387                 "network_type": "vlan",
1388                 "name": "externalMNetworkName",
1389                 "dhcp_enabled": False,
1390                 "location_info": {
1391                     "host": True,
1392                     "vimid": 2,
1393                     "region": True,
1394                     "tenant": "admin",
1395                     "dc": ""
1396                 },
1397                 "end_ip": "190.168.100.100",
1398                 "gateway_ip": "190.168.100.1",
1399                 "start_ip": "190.168.100.2",
1400                 "cidr": "190.168.100.0/24",
1401                 "mtu": 1500,
1402                 "network_name": "sub_mnet",
1403                 "ip_version": 4
1404             }
1405         }
1406     ],
1407     "cps": [
1408
1409     ],
1410     "policies": [
1411
1412     ],
1413     "metadata": {
1414         "invariant_id": "vbras_ns",
1415         "description": "vbras_ns",
1416         "version": 1,
1417         "vendor": "zte",
1418         "id": "vbras_ns",
1419         "name": "vbras_ns"
1420     }
1421 }
1422
1423 vserver_info = {
1424     "vserver-id": "example-vserver-id-val-70924",
1425     "vserver-name": "example-vserver-name-val-61674",
1426     "vserver-name2": "example-vserver-name2-val-19234",
1427     "prov-status": "example-prov-status-val-94916",
1428     "vserver-selflink": "example-vserver-selflink-val-26562",
1429     "in-maint": True,
1430     "is-closed-loop-disabled": True,
1431     "resource-version": "1505465356263",
1432     "volumes": {
1433         "volume": [
1434             {
1435                 "volume-id": "example-volume-id-val-71854",
1436                 "volume-selflink": "example-volume-selflink-val-22433"
1437             }
1438         ]
1439     },
1440     "l-interfaces": {
1441         "l-interface": [
1442             {
1443                 "interface-name": "example-interface-name-val-24351",
1444                 "interface-role": "example-interface-role-val-43242",
1445                 "v6-wan-link-ip": "example-v6-wan-link-ip-val-4196",
1446                 "selflink": "example-selflink-val-61295",
1447                 "interface-id": "example-interface-id-val-95879",
1448                 "macaddr": "example-macaddr-val-37302",
1449                 "network-name": "example-network-name-val-44254",
1450                 "management-option": "example-management-option-val-49009",
1451                 "interface-description": "example-interface-description-val-99923",
1452                 "is-port-mirrored": True,
1453                 "in-maint": True,
1454                 "prov-status": "example-prov-status-val-4698",
1455                 "is-ip-unnumbered": True,
1456                 "allowed-address-pairs": "example-allowed-address-pairs-val-5762",
1457                 "vlans": {
1458                     "vlan": [
1459                         {
1460                             "vlan-interface": "example-vlan-interface-val-58193",
1461                             "vlan-id-inner": 54452151,
1462                             "vlan-id-outer": 70239293,
1463                             "speed-value": "example-speed-value-val-18677",
1464                             "speed-units": "example-speed-units-val-46185",
1465                             "vlan-description": "example-vlan-description-val-81675",
1466                             "backdoor-connection": "example-backdoor-connection-val-44608",
1467                             "vpn-key": "example-vpn-key-val-7946",
1468                             "orchestration-status": "example-orchestration-status-val-33611",
1469                             "in-maint": True,
1470                             "prov-status": "example-prov-status-val-8288",
1471                             "is-ip-unnumbered": True,
1472                             "l3-interface-ipv4-address-list": [
1473                                 {
1474                                     "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-25520",
1475                                     "l3-interface-ipv4-prefix-length": 69931928,
1476                                     "vlan-id-inner": 86628520,
1477                                     "vlan-id-outer": 62729236,
1478                                     "is-floating": True,
1479                                     "neutron-network-id": "example-neutron-network-id-val-64021",
1480                                     "neutron-subnet-id": "example-neutron-subnet-id-val-95049"
1481                                 }
1482                             ],
1483                             "l3-interface-ipv6-address-list": [
1484                                 {
1485                                     "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-64310",
1486                                     "l3-interface-ipv6-prefix-length": 57919834,
1487                                     "vlan-id-inner": 79150122,
1488                                     "vlan-id-outer": 59789973,
1489                                     "is-floating": True,
1490                                     "neutron-network-id": "example-neutron-network-id-val-31713",
1491                                     "neutron-subnet-id": "example-neutron-subnet-id-val-89568"
1492                                 }
1493                             ]
1494                         }
1495                     ]
1496                 },
1497                 "sriov-vfs": {
1498                     "sriov-vf": [
1499                         {
1500                             "pci-id": "example-pci-id-val-16747",
1501                             "vf-vlan-filter": "example-vf-vlan-filter-val-4613",
1502                             "vf-mac-filter": "example-vf-mac-filter-val-68168",
1503                             "vf-vlan-strip": True,
1504                             "vf-vlan-anti-spoof-check": True,
1505                             "vf-mac-anti-spoof-check": True,
1506                             "vf-mirrors": "example-vf-mirrors-val-6270",
1507                             "vf-broadcast-allow": True,
1508                             "vf-unknown-multicast-allow": True,
1509                             "vf-unknown-unicast-allow": True,
1510                             "vf-insert-stag": True,
1511                             "vf-link-status": "example-vf-link-status-val-49266",
1512                             "neutron-network-id": "example-neutron-network-id-val-29493"
1513                         }
1514                     ]
1515                 },
1516                 "l-interfaces": {
1517                     "l-interface": [
1518                         {
1519                             "interface-name": "example-interface-name-val-98222",
1520                             "interface-role": "example-interface-role-val-78360",
1521                             "v6-wan-link-ip": "example-v6-wan-link-ip-val-76921",
1522                             "selflink": "example-selflink-val-27117",
1523                             "interface-id": "example-interface-id-val-11260",
1524                             "macaddr": "example-macaddr-val-60378",
1525                             "network-name": "example-network-name-val-16258",
1526                             "management-option": "example-management-option-val-35097",
1527                             "interface-description": "example-interface-description-val-10475",
1528                             "is-port-mirrored": True,
1529                             "in-maint": True,
1530                             "prov-status": "example-prov-status-val-65203",
1531                             "is-ip-unnumbered": True,
1532                             "allowed-address-pairs": "example-allowed-address-pairs-val-65028"
1533                         }
1534                     ]
1535                 },
1536                 "l3-interface-ipv4-address-list": [
1537                     {
1538                         "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-72779",
1539                         "l3-interface-ipv4-prefix-length": 55956636,
1540                         "vlan-id-inner": 98174431,
1541                         "vlan-id-outer": 20372128,
1542                         "is-floating": True,
1543                         "neutron-network-id": "example-neutron-network-id-val-39596",
1544                         "neutron-subnet-id": "example-neutron-subnet-id-val-51109"
1545                     }
1546                 ],
1547                 "l3-interface-ipv6-address-list": [
1548                     {
1549                         "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-95203",
1550                         "l3-interface-ipv6-prefix-length": 57454747,
1551                         "vlan-id-inner": 53421060,
1552                         "vlan-id-outer": 16006050,
1553                         "is-floating": True,
1554                         "neutron-network-id": "example-neutron-network-id-val-54216",
1555                         "neutron-subnet-id": "example-neutron-subnet-id-val-1841"
1556                     }
1557                 ]
1558             }
1559         ]
1560     }
1561 }
1562
1563
1564 vnfm_info = {
1565     "vnfm-id": "example-vnfm-id-val-97336",
1566     "vim-id": "zte_test",
1567     "certificate-url": "example-certificate-url-val-18046",
1568     "resource-version": "example-resource-version-val-42094",
1569     "esr-system-info-list": {
1570         "esr-system-info": [
1571             {
1572                 "esr-system-info-id": "example-esr-system-info-id-val-7713",
1573                 "system-name": "example-system-name-val-19801",
1574                 "type": "ztevnfmdriver",
1575                 "vendor": "example-vendor-val-50079",
1576                 "version": "example-version-val-93146",
1577                 "service-url": "example-service-url-val-68090",
1578                 "user-name": "example-user-name-val-14470",
1579                 "password": "example-password-val-84190",
1580                 "system-type": "example-system-type-val-42773",
1581                 "protocal": "example-protocal-val-85736",
1582                 "ssl-cacert": "example-ssl-cacert-val-33989",
1583                 "ssl-insecure": True,
1584                 "ip-address": "example-ip-address-val-99038",
1585                 "port": "example-port-val-27323",
1586                 "cloud-domain": "example-cloud-domain-val-55163",
1587                 "default-tenant": "example-default-tenant-val-99383",
1588                 "resource-version": "example-resource-version-val-15424"
1589             }
1590         ]
1591     }
1592 }
1593
1594 vim_info = {
1595     "cloud-owner": "example-cloud-owner-val-97336",
1596     "cloud-region-id": "example-cloud-region-id-val-35532",
1597     "cloud-type": "example-cloud-type-val-18046",
1598     "owner-defined-type": "example-owner-defined-type-val-9413",
1599     "cloud-region-version": "example-cloud-region-version-val-85706",
1600     "identity-url": "example-identity-url-val-71252",
1601     "cloud-zone": "example-cloud-zone-val-27112",
1602     "complex-name": "example-complex-name-val-85283",
1603     "sriov-automation": True,
1604     "cloud-extra-info": "example-cloud-extra-info-val-90854",
1605     "cloud-epa-caps": "example-cloud-epa-caps-val-2409",
1606     "resource-version": "example-resource-version-val-42094",
1607     "esr-system-info-list": {
1608         "esr-system-info": [
1609             {
1610                 "esr-system-info-id": "example-esr-system-info-id-val-7713",
1611                 "system-name": "example-system-name-val-19801",
1612                 "type": "example-type-val-24477",
1613                 "vendor": "example-vendor-val-50079",
1614                 "version": "example-version-val-93146",
1615                 "service-url": "example-service-url-val-68090",
1616                 "user-name": "example-user-name-val-14470",
1617                 "password": "example-password-val-84190",
1618                 "system-type": "example-system-type-val-42773",
1619                 "protocal": "example-protocal-val-85736",
1620                 "ssl-cacert": "example-ssl-cacert-val-33989",
1621                 "ssl-insecure": True,
1622                 "ip-address": "example-ip-address-val-99038",
1623                 "port": "example-port-val-27323",
1624                 "cloud-domain": "example-cloud-domain-val-55163",
1625                 "default-tenant": "admin",
1626                 "resource-version": "example-resource-version-val-15424"
1627             }
1628         ]
1629     }
1630 }
1631
1632 nf_package_info = {
1633     "csarId": "zte_vbras",
1634     "packageInfo": {
1635         "vnfdId": "1",
1636         "vnfPackageId": "zte_vbras",
1637         "vnfdProvider": "1",
1638         "vnfdVersion": "1",
1639         "vnfVersion": "1",
1640         "csarName": "1",
1641         "vnfdModel": vnfd_model_dict,
1642         "downloadUrl": "1"
1643     },
1644     "imageInfo": []
1645 }
1646
1647 vnf_place_request = {
1648     "requestId": "1234",
1649     "transactionId": "1234",
1650     "statusMessage": "xx",
1651     "requestStatus": "completed",
1652     "solutions": {
1653         "placementSolutions": [
1654             [
1655                 {
1656                     "resourceModuleName": "vG",
1657                     "serviceResourceId": "1234",
1658                     "solution": {
1659                         "identifierType": "serviceInstanceId",
1660                         "identifiers": [
1661                             "xx"
1662                         ],
1663                         "cloudOwner": "CloudOwner1"
1664                     },
1665                     "assignmentInfo": [
1666                         {"key": "isRehome",
1667                          "value": "false"
1668                          },
1669                         {"key": "locationId",
1670                          "value": "DLLSTX1A"
1671                          },
1672                         {"key": "locationType",
1673                          "value": "openstack-cloud"
1674                          },
1675                         {"key": "vimId",
1676                          "value": "CloudOwner1_DLLSTX1A"
1677                          },
1678                         {"key": "physicalLocationId",
1679                          "value": "DLLSTX1223"
1680                          },
1681                         {"key": "oofDirectives",
1682                          "value": {
1683                              "directives": [
1684                                  {
1685                                      "id": "vG_0",
1686                                      "type": "tocsa.nodes.nfv.Vdu.Compute",
1687                                      "directives": [
1688                                          {
1689                                              "type": "flavor_directive",
1690                                              "attributes": [
1691                                                  {
1692                                                      "attribute_name": "flavor_name",
1693                                                      "attribute_value": "HPA.flavor.1"
1694                                                  }
1695                                              ]
1696                                          }
1697                                      ]
1698                                  },
1699                                  {
1700                                      "id": "",
1701                                      "type": "vnf",
1702                                      "directives": [
1703                                          {"type": " ",
1704                                           "attributes": [
1705                                               {
1706                                                   "attribute_name": " ",
1707                                                   "attribute_value": " "
1708                                               }
1709                                           ]
1710                                           }
1711                                      ]
1712                                  }
1713                              ]
1714                          }
1715                          }
1716                     ]
1717                 }
1718             ]
1719         ],
1720         "licenseSolutions": [
1721             {
1722                 "resourceModuleName": "string",
1723                 "serviceResourceId": "string",
1724                 "entitlementPoolUUID": [
1725                     "string"
1726                 ],
1727                 "licenseKeyGroupUUID": [
1728                     "string"
1729                 ],
1730                 "entitlementPoolInvariantUUID": [
1731                     "string"
1732                 ],
1733                 "licenseKeyGroupInvariantUUID": [
1734                     "string"
1735                 ]
1736             }
1737         ]
1738     }
1739 }