7070c3885d54ad7a71ccfb1b197fa180403d89e3
[vfc/gvnfm/vnflcm.git] / lcm / lcm / nf / vnfs / tests / test_vnf_create.py
1 # Copyright 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.nf.vnfs.vnf_create.inst_vnf import InstVnf
22 from lcm.pub.database.models import NfInstModel, JobStatusModel, VmInstModel, NetworkInstModel, \
23     SubNetworkInstModel, PortInstModel
24 from lcm.pub.utils import restcall
25 from lcm.pub.utils.jobutil import JobUtil
26 from lcm.pub.utils.timeutil import now_time
27
28
29 class TestNFInstantiate(TestCase):
30     def setUp(self):
31         self.client = Client()
32         VmInstModel.objects.create(vmid="1", vimid="1", resouceid="11", insttype=0, instid="1", vmname="test_01",
33                                    operationalstate=1)
34         VmInstModel.objects.create(vmid="2", vimid="2", resouceid="22", insttype=0, instid="2",
35                                    vmname="test_02", operationalstate=1)
36         NetworkInstModel.objects.create(networkid='1', vimid='1', resouceid='1', name='pnet_network',
37                                         tenant='admin', insttype=0, instid='1')
38         SubNetworkInstModel.objects.create(subnetworkid='1', vimid='1', resouceid='1', networkid='1',
39                                            name='sub_pnet', tenant='admin', insttype=0, instid='1')
40         PortInstModel.objects.create(portid='1', networkid='1', subnetworkid='1', vimid='1', resouceid='1',
41                                      name='aaa_pnet_cp', tenant='admin', insttype=0, instid='1')
42
43     def tearDown(self):
44         pass
45         VmInstModel.objects.all().delete()
46         NetworkInstModel.objects.all().delete()
47         SubNetworkInstModel.objects.all().delete()
48         PortInstModel.objects.all().delete()
49
50     def assert_job_result(self, job_id, job_progress, job_detail):
51         jobs = JobStatusModel.objects.filter(
52             jobid=job_id,
53             progress=job_progress,
54             descp=job_detail)
55         self.assertEqual(1, len(jobs))
56
57     def test_swagger_ok(self):
58         response = self.client.get("/openoapi/vnflcm/v1/swagger.json", format='json')
59         self.assertEqual(response.status_code, status.HTTP_200_OK)
60
61     @mock.patch.object(restcall, 'call_req')
62     def test_create_vnf_identifier(self, mock_call_req):
63         r1 = [0, json.JSONEncoder().encode({'package_id':'222', 'csar_id':'2222'}), '200']  # get csar_id from nslcm by vnfd_id
64         r2 = [0, json.JSONEncoder().encode(vnfd_raw_data), '200']
65         mock_call_req.side_effect = [r1, r2]
66         data = {
67             "vnfdId": "111",
68             "vnfInstanceName": "vFW_01",
69             "vnfInstanceDescription": "vFW in Nanjing TIC Edge"}
70         response = self.client.post("/openoapi/vnflcm/v1/vnf_instances", data=data, format='json')
71         self.failUnlessEqual(status.HTTP_201_CREATED, response.status_code)
72         context = json.loads(response.content)
73         self.assertTrue(NfInstModel.objects.filter(nfinstid=context['vnfInstanceId']).exists())
74
75     @mock.patch.object(InstVnf, 'run')
76     def test_instantiate_vnf(self, mock_run):
77         mock_run.re.return_value = None
78         response = self.client.post("/openoapi/vnflcm/v1/vnf_instances/12/instantiate", data={}, format='json')
79         self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code)
80
81     def test_instantiate_vnf_when_inst_id_not_exist(self):
82         self.nf_inst_id = str(uuid.uuid4())
83         self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id)
84         JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY")
85         data = inst_req_data
86         InstVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
87         self.assert_job_result(self.job_id, 255, "VNF nf_inst_id is not exist.")
88
89     @mock.patch.object(restcall, 'call_req')
90     def test_instantiate_vnf_when_get_package_info_by_vnfdid_failed(self, mock_call_req):
91         NfInstModel.objects.create(nfinstid='1111', nf_name='vFW_01', package_id='222',
92                                    version='', vendor='', netype='', vnfd_model='', status='NOT_INSTANTIATED',
93                                    nf_desc='vFW in Nanjing TIC Edge', vnfdid='111', create_time=now_time())
94         r1 = [1, json.JSONEncoder().encode({'package_id':'222', 'csar_id':'2222'}), '200']  # get csar_id from nslcm by vnfd_id
95         mock_call_req.side_effect = [r1]
96         self.nf_inst_id = '1111'
97         self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id)
98         JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY")
99         data = inst_req_data
100         InstVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
101         self.assert_job_result(self.job_id, 255, "Failed to query package_info of vnfdid(111) from nslcm.")
102
103     @mock.patch.object(restcall, 'call_req')
104     def test_instantiate_vnf_when_get_rawdata_by_csarid_failed(self, mock_call_req):
105         NfInstModel.objects.create(nfinstid='1111', nf_name='vFW_01', package_id='222',
106                                    version='', vendor='', netype='', vnfd_model='', status='NOT_INSTANTIATED',
107                                    nf_desc='vFW in Nanjing TIC Edge', vnfdid='111', create_time=now_time())
108         r1 = [0, json.JSONEncoder().encode({'package_id':'222', 'csar_id':'2222'}), '200']  # get csar_id from nslcm by vnfd_id
109         r2 = [1, json.JSONEncoder().encode(vnfd_raw_data), '200']
110         mock_call_req.side_effect = [r1, r2]
111         self.nf_inst_id = '1111'
112         self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id)
113         JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY")
114         data = inst_req_data
115         InstVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
116         self.assert_job_result(self.job_id, 255, "Failed to query rawdata of CSAR(2222) from catalog.")
117
118     # @mock.patch.object(restcall, 'call_req')
119     # def test_instantiate_vnf_when_get_rawdata_by_csarid_failed(self, mock_call_req):
120     #     NfInstModel.objects.create(nfinstid='1111', nf_name='vFW_01', package_id='222',
121     #                                version='', vendor='', netype='', vnfd_model='', status='NOT_INSTANTIATED',
122     #                                nf_desc='vFW in Nanjing TIC Edge', vnfdid='111', create_time=now_time())
123     #     r1 = [0, json.JSONEncoder().encode({'package_id': '222', 'csar_id': '2222'}), '200']  # get csar_id from nslcm by vnfd_id
124     #     r2 = [0, json.JSONEncoder().encode(vnfd_raw_data), '200']
125     #     mock_call_req.side_effect = [r1, r2]
126     #     self.nf_inst_id = '1111'
127     #     self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id)
128     #     JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY")
129     #     data = inst_req_data
130     #     InstVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
131     #     self.assert_job_result(self.job_id, 255, "Failed to query rawdata of CSAR(2222) from catalog.")
132
133     # @mock.patch.object(restcall, 'call_req')
134     # def test_instantiate_vnf_when_input_para_not_define_in_vnfd(self, mock_call_req):
135     #     r1 = [0, json.JSONEncoder().encode(vnfd_model_dict), '200']
136     #     r2 = [0, json.JSONEncoder().encode(''), '200']
137     #     mock_call_req.side_effect = [r1, r2]
138     #     create_data = {
139     #         "vnfdId": "111",
140     #         "vnfInstanceName": "vFW_01",
141     #         "vnfInstanceDescription": " vFW in Nanjing TIC Edge"}
142     #     self.nf_inst_id = CreateVnf(create_data).do_biz()
143     #     self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id)
144     #     JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY")
145     #     data = inst_req_data
146     #     InstVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
147     #     self.assert_job_result(self.job_id, 255, "Input parameter is not defined in vnfd_info.")
148     #
149     # @mock.patch.object(restcall, 'call_req')
150     # def test_instantiate_vnf_when_get_nfvo_config_failed(self, mock_call_req):
151     #     r1 = [0, json.JSONEncoder().encode(vnfd_model_dict), '200']
152     #     r2 = [0, json.JSONEncoder().encode(vnfd_model_dict), '200']
153     #     mock_call_req.side_effect = [r1, r2]
154     #     create_data = {
155     #         "vnfdId": "111",
156     #         "vnfInstanceName": "vFW_01",
157     #         "vnfInstanceDescription": " vFW in Nanjing TIC Edge"}
158     #     self.nf_inst_id = CreateVnf(create_data).do_biz()
159     #     self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id)
160     #     JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY")
161     #     data = inst_req_data
162     #     InstVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
163     #     self.assert_job_result(self.job_id, 255, "Nfvo was not registered")
164     #
165     # @mock.patch.object(restcall, 'call_req')
166     # def test_instantiate_vnf_when_applay_grant_failed(self, mock_call_req):
167     #     NfvoRegInfoModel.objects.create(nfvoid='nfvo111', vnfminstid='vnfm111', apiurl='http://10.74.44.11',
168     #                                     nfvouser='root', nfvopassword='root123')
169     #     r1 = [0, json.JSONEncoder().encode(vnfd_model_dict), '200']
170     #     r2 = [0, json.JSONEncoder().encode(vnfd_model_dict), '200']
171     #     r3 = [1, json.JSONEncoder().encode(''), '200']
172     #     mock_call_req.side_effect = [r1, r2, r3]
173     #     create_data = {
174     #         "vnfdId": "111",
175     #         "vnfInstanceName": "vFW_01",
176     #         "vnfInstanceDescription": " vFW in Nanjing TIC Edge"}
177     #     self.nf_inst_id = CreateVnf(create_data).do_biz()
178     #     self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id)
179     #     JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY")
180     #     data = inst_req_data
181     #     InstVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
182     #     self.assert_job_result(self.job_id, 255, "Nf instancing apply grant exception")
183
184     # @mock.patch.object(restcall, 'call_req')
185     # # @mock.patch.object(adaptor, 'create_vim_res')
186     # def test_instantiate_vnf_when_create_res_failed(self, mock_call_req):
187     #     NfvoRegInfoModel.objects.create(nfvoid='nfvo111', vnfminstid='vnfm111', apiurl='http://10.74.44.11',
188     #                                     nfvouser='root', nfvopassword='root123')
189     #     r1 = [0, json.JSONEncoder().encode(vnfd_model_dict), '200']
190     #     r2 = [0, json.JSONEncoder().encode(vnfd_model_dict), '200']
191     #     r3 = [0, json.JSONEncoder().encode('Nf instancing apply grant'), '200']
192     #     # r4 = [0, json.JSONEncoder().encode('Nf instancing apply resource'), '200']
193     #     mock_call_req.side_effect = [r1, r2, r3]
194     #     # mock_create_vim_res.re.return_value = None
195     #     create_data = {
196     #         "vnfdId": "111",
197     #         "vnfInstanceName": "vFW_01",
198     #         "vnfInstanceDescription": " vFW in Nanjing TIC Edge"}
199     #     self.nf_inst_id = CreateVnf(create_data).do_biz()
200     #     self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id)
201     #     JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY")
202     #     data = inst_req_data
203     #     InstVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
204     #     self.assert_job_result(self.job_id, 255, "Create resource failed")
205
206     # @mock.patch.object(restcall, 'call_req')
207     # # @mock.patch.object(adaptor, 'create_vim_res')
208     # def test_instantiate_vnf_success(self, mock_call_req):
209     #     NfvoRegInfoModel.objects.create(nfvoid='nfvo111', vnfminstid='vnfm111', apiurl='http://10.74.44.11',
210     #                                     nfvouser='root', nfvopassword='root123')
211     #     r1 = [0, json.JSONEncoder().encode(vnfd_model_dict), '200']
212     #     r2 = [0, json.JSONEncoder().encode(vnfd_model_dict), '200']
213     #     r3 = [0, json.JSONEncoder().encode('Nf instancing apply grant'), '200']
214     #     r4 = [0, json.JSONEncoder().encode('None'), '200']
215     #     mock_call_req.side_effect = [r1, r2, r3, r4]
216     #     # mock_create_vim_res.re.return_value = None
217     #     create_data = {
218     #         "vnfdId": "111",
219     #         "vnfInstanceName": "vFW_01",
220     #         "vnfInstanceDescription": " vFW in Nanjing TIC Edge"}
221     #     self.nf_inst_id = CreateVnf(create_data).do_biz()
222     #     self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id)
223     #     JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY")
224     #     data = inst_req_data
225     #     InstVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
226     #     self.assert_job_result(self.job_id, 100, "Instantiate Vnf success.")
227
228 inst_req_data = {
229     "flavourId": "flavour_1",
230     "instantiationLevelId": "instantiationLevel_1",
231     "extVirtualLinks": [
232         {
233             "vlInstanceId": "1",
234             "vim": {
235                 "vimInfoId": "1",
236                 "vimId": "1",
237                 "interfaceInfo": {
238                     "vimType": "vim",
239                     "apiVersion": "v2",
240                     "protocolType": "http"
241                 },
242                 "accessInfo": {
243                     "tenant": "tenant_vCPE",
244                     "username": "vCPE",
245                     "password": "vCPE_321"
246                 },
247                 "interfaceEndpoint": "http://10.43.21.105:80/"
248             },
249             "resourceId": "1246",
250             "extCps": [
251                 {
252                     "cpdId": "11",
253                     "addresses": [
254                         {
255                             "addressType": "MAC",
256                             "l2AddressData": "00:f3:43:20:a2:a3"
257                         },
258                         {
259                             "addressType": "IP",
260                             "l3AddressData": {
261                                 "iPAddressType": "IPv4",
262                                 "iPAddress": "192.168.104.2"
263                             }
264                         }
265                     ],
266                     "numDynamicAddresses": 0
267                 }
268             ]
269         }
270     ],
271     "localizationLanguage": "en_US",
272     "additionalParams": {}
273 }
274
275 vnfd_model_dict = {
276     'local_storages': [],
277     'vdus': [
278         {
279             'volumn_storages': [],
280             'nfv_compute': {
281                 'mem_size': '',
282                 'num_cpus': u'2'},
283             'local_storages': [],
284             'vdu_id': u'vdu_omm.001',
285             'image_file': u'opencos_sss_omm_img_release_20150723-1-disk1',
286             'dependencies': [],
287             'vls': [],
288             'cps': [],
289             'properties': {
290                 'key_vdu': '',
291                 'support_scaling': False,
292                 'vdu_type': '',
293                 'name': '',
294                 'storage_policy': '',
295                 'location_info': {
296                     'vimId': '',
297                     'availability_zone': '',
298                     'region': '',
299                     'dc': '',
300                     'host': '',
301                     'tenant': ''},
302                 'inject_data_list': [],
303                 'watchdog': {
304                     'action': '',
305                     'enabledelay': ''},
306                 'local_affinity_antiaffinity_rule': {},
307                 'template_id': u'omm.001',
308                 'manual_scale_select_vim': False},
309             'description': u'singleommvm'},
310         {
311             'volumn_storages': [],
312             'nfv_compute': {
313                 'mem_size': '',
314                 'num_cpus': u'4'},
315             'local_storages': [],
316             'vdu_id': u'vdu_1',
317             'image_file': u'sss',
318             'dependencies': [],
319             'vls': [],
320             'cps': [],
321             'properties': {
322                 'key_vdu': '',
323                 'support_scaling': False,
324                 'vdu_type': '',
325                 'name': '',
326                 'storage_policy': '',
327                 'location_info': {
328                     'vimId': '',
329                     'availability_zone': '',
330                     'region': '',
331                     'dc': '',
332                     'host': '',
333                     'tenant': ''},
334                 'inject_data_list': [],
335                 'watchdog': {
336                     'action': '',
337                     'enabledelay': ''},
338                 'local_affinity_antiaffinity_rule': {},
339                 'template_id': u'1',
340                 'manual_scale_select_vim': False},
341             'description': u'ompvm'},
342         {
343             'volumn_storages': [],
344             'nfv_compute': {
345                 'mem_size': '',
346                 'num_cpus': u'14'},
347             'local_storages': [],
348             'vdu_id': u'vdu_2',
349             'image_file': u'sss',
350             'dependencies': [],
351             'vls': [],
352             'cps': [],
353             'properties': {
354                 'key_vdu': '',
355                 'support_scaling': False,
356                 'vdu_type': '',
357                 'name': '',
358                 'storage_policy': '',
359                 'location_info': {
360                     'vimId': '',
361                     'availability_zone': '',
362                     'region': '',
363                     'dc': '',
364                     'host': '',
365                     'tenant': ''},
366                 'inject_data_list': [],
367                 'watchdog': {
368                     'action': '',
369                     'enabledelay': ''},
370                 'local_affinity_antiaffinity_rule': {},
371                 'template_id': u'2',
372                 'manual_scale_select_vim': False},
373             'description': u'ompvm'},
374         {
375             'volumn_storages': [],
376             'nfv_compute': {
377                 'mem_size': '',
378                 'num_cpus': u'14'},
379             'local_storages': [],
380             'vdu_id': u'vdu_3',
381             'image_file': u'sss',
382             'dependencies': [],
383             'vls': [],
384             'cps': [],
385             'properties': {
386                 'key_vdu': '',
387                 'support_scaling': False,
388                 'vdu_type': '',
389                 'name': '',
390                 'storage_policy': '',
391                 'location_info': {
392                     'vimId': '',
393                     'availability_zone': '',
394                     'region': '',
395                     'dc': '',
396                     'host': '',
397                     'tenant': ''},
398                 'inject_data_list': [],
399                 'watchdog': {
400                     'action': '',
401                     'enabledelay': ''},
402                 'local_affinity_antiaffinity_rule': {},
403                 'template_id': u'3',
404                 'manual_scale_select_vim': False},
405             'description': u'ompvm'},
406         {
407             'volumn_storages': [],
408             'nfv_compute': {
409                 'mem_size': '',
410                 'num_cpus': u'4'},
411             'local_storages': [],
412             'vdu_id': u'vdu_10',
413             'image_file': u'sss',
414             'dependencies': [],
415             'vls': [],
416             'cps': [],
417             'properties': {
418                 'key_vdu': '',
419                 'support_scaling': False,
420                 'vdu_type': '',
421                 'name': '',
422                 'storage_policy': '',
423                 'location_info': {
424                     'vimId': '',
425                     'availability_zone': '',
426                     'region': '',
427                     'dc': '',
428                     'host': '',
429                     'tenant': ''},
430                 'inject_data_list': [],
431                 'watchdog': {
432                     'action': '',
433                     'enabledelay': ''},
434                 'local_affinity_antiaffinity_rule': {},
435                 'template_id': u'10',
436                 'manual_scale_select_vim': False},
437             'description': u'ppvm'},
438         {
439             'volumn_storages': [],
440             'nfv_compute': {
441                 'mem_size': '',
442                 'num_cpus': u'14'},
443             'local_storages': [],
444             'vdu_id': u'vdu_11',
445             'image_file': u'sss',
446             'dependencies': [],
447             'vls': [],
448             'cps': [],
449             'properties': {
450                 'key_vdu': '',
451                 'support_scaling': False,
452                 'vdu_type': '',
453                 'name': '',
454                 'storage_policy': '',
455                 'location_info': {
456                     'vimId': '',
457                     'availability_zone': '',
458                     'region': '',
459                     'dc': '',
460                     'host': '',
461                     'tenant': ''},
462                 'inject_data_list': [],
463                 'watchdog': {
464                     'action': '',
465                     'enabledelay': ''},
466                 'local_affinity_antiaffinity_rule': {},
467                 'template_id': u'11',
468                 'manual_scale_select_vim': False},
469             'description': u'ppvm'},
470         {
471             'volumn_storages': [],
472             'nfv_compute': {
473                 'mem_size': '',
474                 'num_cpus': u'14'},
475             'local_storages': [],
476             'vdu_id': u'vdu_12',
477             'image_file': u'sss',
478             'dependencies': [],
479             'vls': [],
480             'cps': [],
481             'properties': {
482                 'key_vdu': '',
483                 'support_scaling': False,
484                 'vdu_type': '',
485                 'name': '',
486                 'storage_policy': '',
487                 'location_info': {
488                     'vimId': '',
489                     'availability_zone': '',
490                     'region': '',
491                     'dc': '',
492                     'host': '',
493                     'tenant': ''},
494                 'inject_data_list': [],
495                 'watchdog': {
496                     'action': '',
497                     'enabledelay': ''},
498                 'local_affinity_antiaffinity_rule': {},
499                 'template_id': u'12',
500                 'manual_scale_select_vim': False},
501             'description': u'ppvm'}],
502     'volumn_storages': [],
503     'policies': {
504         'scaling': {
505             'targets': {},
506             'policy_id': u'policy_scale_sss-vnf-template',
507             'properties': {
508                 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'},
509             'description': ''}},
510     'image_files': [
511         {
512             'description': '',
513             'properties': {
514                 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
515                 'checksum': '',
516                 'disk_format': u'VMDK',
517                 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
518                 'container_type': 'vm',
519                 'version': '',
520                 'hypervisor_type': 'kvm'},
521             'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'},
522         {
523             'description': '',
524             'properties': {
525                 'name': u'sss.vmdk',
526                 'checksum': '',
527                 'disk_format': u'VMDK',
528                 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
529                 'container_type': 'vm',
530                 'version': '',
531                 'hypervisor_type': 'kvm'},
532             'image_file_id': u'sss'}],
533     'vls': [],
534     'cps': [],
535     'metadata': {
536         'vendor': u'zte',
537         'is_shared': False,
538         'description': '',
539         'domain_type': u'CN',
540         'version': u'v4.14.10',
541         'vmnumber_overquota_alarm': False,
542         'cross_dc': False,
543         'vnf_type': u'SSS',
544         'vnfd_version': u'V00000001',
545         'id': u'sss-vnf-template',
546         'name': u'sss-vnf-template'},
547     "flavourId": "flavour_1",
548     "instantiationLevelId": "instantiationLevel_1",
549     "extVirtualLinks": [
550         {
551             "vlInstanceId": "1",
552             "vim": {
553                 "vimInfoId": "1",
554                 "vimId": "1",
555                 "interfaceInfo": {
556                     "vimType": "vim",
557                     "apiVersion": "v2",
558                     "protocolType": "http"
559                 },
560                 "accessInfo": {
561                     "tenant": "tenant_vCPE",
562                     "username": "vCPE",
563                     "password": "vCPE_321"
564                 },
565                 "interfaceEndpoint": "http://10.43.21.105:80/"
566             },
567             "resourceId": "1246",
568             "extCps": [
569                 {
570                     "cpdId": "11",
571                     "addresses": [
572                         {
573                             "addressType": "MAC",
574                             "l2AddressData": "00:f3:43:20:a2:a3"
575                         },
576                         {
577                             "addressType": "IP",
578                             "l3AddressData": {
579                                 "iPAddressType": "IPv4",
580                                 "iPAddress": "192.168.104.2"
581                             }
582                         }
583                     ],
584                     "numDynamicAddresses": 0
585                 }
586             ]
587         }
588     ],
589     "localizationLanguage": "en_US",
590     "additionalParams": {}
591 }
592
593 vnfd_raw_data = {
594     "rawData": {
595         "instance": {
596             "metadata": {
597                 "is_shared": False,
598                 "plugin_info": "vbrasplugin_1.0",
599                 "vendor": "zte",
600                 "request_reclassification": False,
601                 "name": "vbras",
602                 "version": 1,
603                 "vnf_type": "vbras",
604                 "cross_dc": False,
605                 "vnfd_version": "1.0.0",
606                 "id": "zte_vbras_1.0",
607                 "nsh_aware": True
608             },
609             "nodes": [
610                 {
611                     "id": "aaa_dnet_cp_0xu2j5sbigxc8h1ega3if0ld1",
612                     "type_name": "tosca.nodes.nfv.ext.zte.CP",
613                     "template_name": "aaa_dnet_cp",
614                     "properties": {
615                         "bandwidth": {
616                             "type_name": "integer",
617                             "value": 0
618                         },
619                         "direction": {
620                             "type_name": "string",
621                             "value": "bidirectional"
622                         },
623                         "vnic_type": {
624                             "type_name": "string",
625                             "value": "normal"
626                         },
627                         "sfc_encapsulation": {
628                             "type_name": "string",
629                             "value": "mac"
630                         },
631                         "order": {
632                             "type_name": "integer",
633                             "value": 2
634                         }
635                     },
636                     "relationships": [
637                         {
638                             "name": "guest_os",
639                             "source_requirement_index": 0,
640                             "target_node_id": "AAA_image_d8aseebr120nbm7bo1ohkj194",
641                             "target_capability_name": "feature"
642                         }
643                     ]
644                 },
645                 {
646                     "id": "LB_Image_oj5l2ay8l2g6vcq6fsswzduha",
647                     "type_name": "tosca.nodes.nfv.ext.ImageFile",
648                     "template_name": "LB_Image",
649                     "properties": {
650                         "disk_format": {
651                             "type_name": "string",
652                             "value": "qcow2"
653                         },
654                         "file_url": {
655                             "type_name": "string",
656                             "value": "/SoftwareImages/image-lb"
657                         },
658                         "name": {
659                             "type_name": "string",
660                             "value": "image-lb"
661                         }
662                     }
663                 }
664             ]
665         },
666         "model": {
667             "metadata": {
668                 "is_shared": False,
669                 "plugin_info": "vbrasplugin_1.0",
670                 "vendor": "zte",
671                 "request_reclassification": False,
672                 "name": "vbras",
673                 "version": 1,
674                 "vnf_type": "vbras",
675                 "cross_dc": False,
676                 "vnfd_version": "1.0.0",
677                 "id": "zte_vbras_1.0",
678                 "nsh_aware": True
679             },
680             "node_templates": [
681                 {
682                     "name": "aaa_dnet_cp",
683                     "type_name": "tosca.nodes.nfv.ext.zte.CP",
684                     "default_instances": 1,
685                     "min_instances": 0,
686                     "properties": {
687                         "bandwidth": {
688                             "type_name": "integer",
689                             "value": 0
690                         }
691                     },
692                     "requirement_templates": [
693                         {
694                             "name": "virtualbinding",
695                             "target_node_template_name": "AAA",
696                             "target_capability_name": "virtualbinding"
697                         }
698                     ]
699                 }
700             ]
701         }
702     }
703 }