73cecd963bbe99b40226a58e7f19719cf100d3cf
[vfc/nfvo/lcm.git] / lcm / ns / tests / vnfs / 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.ns.vnfs import create_vnfs
22 from lcm.ns.vnfs.const import VNF_STATUS
23 from lcm.ns.vnfs.create_vnfs import CreateVnfs
24 from lcm.pub.database.models import NfInstModel, JobModel, NfPackageModel, NSInstModel
25 from lcm.pub.utils import restcall
26 from lcm.pub.utils.jobutil import JOB_MODEL_STATUS
27 from lcm.pub.utils.timeutil import now_time
28 from lcm.pub.utils.values import ignore_case_get
29 from lcm.ns.vnfs.terminate_nfs import TerminateVnfs
30 from lcm.ns.vnfs.scale_vnfs import NFManualScaleService
31 from lcm.ns.vnfs.heal_vnfs import NFHealService
32 from lcm.pub.utils.jobutil import JobUtil, JOB_TYPE
33 from lcm.pub.exceptions import NSLCMException
34
35
36 class TestGetVnfViews(TestCase):
37     def setUp(self):
38         self.client = Client()
39         self.nf_inst_id = str(uuid.uuid4())
40         NfInstModel(nfinstid=self.nf_inst_id, nf_name='vnf1', vnfm_inst_id='1', vnf_id='vnf_id1',
41                     status=VNF_STATUS.ACTIVE, create_time=now_time(), lastuptime=now_time()).save()
42
43     def tearDown(self):
44         NfInstModel.objects.all().delete()
45
46     def test_get_vnf(self):
47         response = self.client.get("/api/nslcm/v1/ns/vnfs/%s" % self.nf_inst_id)
48         self.failUnlessEqual(status.HTTP_200_OK, response.status_code)
49         context = json.loads(response.content)
50         self.failUnlessEqual(self.nf_inst_id, context['vnfInstId'])
51
52
53 class TestCreateVnfViews(TestCase):
54     def setUp(self):
55         self.ns_inst_id = str(uuid.uuid4())
56         self.job_id = str(uuid.uuid4())
57         self.data = {
58             'nsInstanceId': self.ns_inst_id,
59             'additionalParamForNs': {"inputs": json.dumps({})},
60             'additionalParamForVnf': [{
61                 'vnfprofileid': 'VBras',
62                 'additionalparam': {
63                     'inputs': json.dumps({'vnf_param1': '11', 'vnf_param2': '22'}),
64                     'vnfminstanceid': "1"}}],
65             'vnfIndex': '1'}
66         self.client = Client()
67         NfPackageModel(uuid=str(uuid.uuid4()), nfpackageid='package_id1', vnfdid='zte_vbras', vendor='zte',
68                        vnfdversion='1.0.0', vnfversion='1.0.0', vnfdmodel=json.dumps(vnfd_model_dict)).save()
69         NSInstModel(id=self.ns_inst_id, name='ns', nspackage_id='1', nsd_id='nsd_id', description='description',
70                     status='instantiating', nsd_model=json.dumps(nsd_model_dict), create_time=now_time(),
71                     lastuptime=now_time()).save()
72
73     def tearDown(self):
74         NfInstModel.objects.all().delete()
75         JobModel.objects.all().delete()
76
77     @mock.patch.object(CreateVnfs, 'run')
78     def test_create_vnf(self, mock_run):
79         response = self.client.post("/api/nslcm/v1/ns/vnfs", data=self.data)
80         self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code)
81         context = json.loads(response.content)
82         self.assertTrue(NfInstModel.objects.filter(nfinstid=context['vnfInstId']).exists())
83
84     @mock.patch.object(restcall, 'call_req')
85     def test_create_vnf_thread(self, mock_call_req):
86         mock_vals = {
87             "/api/ztevmanagerdriver/v1/1/vnfs":
88                 [0, json.JSONEncoder().encode({"jobId": self.job_id, "vnfInstanceId": 3}), '200'],
89             "/api/extsys/v1/vnfms/1":
90                 [0, json.JSONEncoder().encode({"name": 'vnfm1'}), '200'],
91             "/api/resmgr/v1/vnf":
92                 [0, json.JSONEncoder().encode({}), '200'],
93             "/api/resmgr/v1/vnfinfo":
94                 [0, json.JSONEncoder().encode({}), '200'],
95             "/api/ztevmanagerdriver/v1/jobs/" + self.job_id + "&responseId=0":
96                 [0, json.JSONEncoder().encode({"jobid": self.job_id,
97                                                "responsedescriptor": {"progress": "100",
98                                                                       "status": JOB_MODEL_STATUS.FINISHED,
99                                                                       "responseid": "3",
100                                                                       "statusdescription": "creating",
101                                                                       "errorcode": "0",
102                                                                       "responsehistorylist": [
103                                                                           {"progress": "0",
104                                                                            "status": JOB_MODEL_STATUS.PROCESSING,
105                                                                            "responseid": "2",
106                                                                            "statusdescription": "creating",
107                                                                            "errorcode": "0"}]}}), '200']}
108
109         def side_effect(*args):
110             return mock_vals[args[4]]
111         mock_call_req.side_effect = side_effect
112         data = {'ns_instance_id': ignore_case_get(self.data, 'nsInstanceId'),
113                 'additional_param_for_ns': ignore_case_get(self.data, 'additionalParamForNs'),
114                 'additional_param_for_vnf': ignore_case_get(self.data, 'additionalParamForVnf'),
115                 'vnf_index': ignore_case_get(self.data, 'vnfIndex')}
116         nf_inst_id, job_id = create_vnfs.prepare_create_params()
117         CreateVnfs(data, nf_inst_id, job_id).run()
118         self.assertTrue(NfInstModel.objects.get(nfinstid=nf_inst_id).status, VNF_STATUS.ACTIVE)
119
120
121 class TestTerminateVnfViews(TestCase):
122     def setUp(self):
123         self.client = Client()
124         self.ns_inst_id = str(uuid.uuid4())
125         self.nf_inst_id = '1'
126         self.vnffg_id = str(uuid.uuid4())
127         self.vim_id = str(uuid.uuid4())
128         self.job_id = str(uuid.uuid4())
129         self.nf_uuid = '111'
130         self.tenant = "tenantname"
131         NSInstModel.objects.all().delete()
132         NfInstModel.objects.all().delete()
133         NSInstModel(id=self.ns_inst_id, name="ns_name").save()
134         NfInstModel.objects.create(nfinstid=self.nf_inst_id, nf_name='name_1', vnf_id='1',
135                                    vnfm_inst_id='1', ns_inst_id='111,2-2-2',
136                                    max_cpu='14', max_ram='12296', max_hd='101', max_shd="20", max_net=10,
137                                    status='active', mnfinstid=self.nf_uuid, package_id='pkg1',
138                                    vnfd_model='{"metadata": {"vnfdId": "1","vnfdName": "PGW001",'
139                                               '"vnfProvider": "zte","vnfdVersion": "V00001","vnfVersion": "V5.10.20",'
140                                               '"productType": "CN","vnfType": "PGW",'
141                                               '"description": "PGW VNFD description",'
142                                               '"isShared":true,"vnfExtendType":"driver"}}')
143
144     def tearDown(self):
145         NSInstModel.objects.all().delete()
146         NfInstModel.objects.all().delete()
147
148     @mock.patch.object(TerminateVnfs, 'run')
149     def test_terminate_vnf_url(self, mock_run):
150         req_data = {
151             "terminationType": "forceful",
152             "gracefulTerminationTimeout": "600"}
153
154         response = self.client.post("/api/nslcm/v1/ns/vnfs/%s" % self.nf_inst_id, data=req_data)
155         self.failUnlessEqual(status.HTTP_201_CREATED, response.status_code)
156
157     @mock.patch.object(restcall, "call_req")
158     def test_terminate_vnf(self, mock_call_req):
159         job_id = JobUtil.create_job("VNF", JOB_TYPE.TERMINATE_VNF, self.nf_inst_id)
160
161         nfinst = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
162         if nfinst:
163             self.failUnlessEqual(1, 1)
164         else:
165             self.failUnlessEqual(1, 0)
166
167         mock_vals = {
168             "/api/ztevmanagerdriver/v1/1/vnfs/111/terminate":
169                 [0, json.JSONEncoder().encode({"jobId": job_id}), '200'],
170             "/api/extsys/v1/vnfms/1":
171                 [0, json.JSONEncoder().encode({"name": 'vnfm1', "type": 'ztevmanagerdriver'}), '200'],
172             "/api/resmgr/v1/vnf/1":
173                 [0, json.JSONEncoder().encode({"jobId": job_id}), '200'],
174             "/api/ztevmanagerdriver/v1/1/jobs/" + job_id + "?responseId=0":
175                 [0, json.JSONEncoder().encode({"jobId": job_id,
176                                                "responsedescriptor": {"progress": "100",
177                                                                       "status": JOB_MODEL_STATUS.FINISHED,
178                                                                       "responseid": "3",
179                                                                       "statusdescription": "creating",
180                                                                       "errorcode": "0",
181                                                                       "responsehistorylist": [
182                                                                           {"progress": "0",
183                                                                            "status": JOB_MODEL_STATUS.PROCESSING,
184                                                                            "responseid": "2",
185                                                                            "statusdescription": "creating",
186                                                                            "errorcode": "0"}]}}), '200']}
187
188         req_data = {
189             "terminationType": "forceful",
190             "gracefulTerminationTimeout": "600"}
191
192         def side_effect(*args):
193             return mock_vals[args[4]]
194         mock_call_req.side_effect = side_effect
195
196         TerminateVnfs(req_data, self.nf_inst_id, job_id).run()
197         nfinst = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
198         if nfinst:
199             self.failUnlessEqual(1, 0)
200         else:
201             self.failUnlessEqual(1, 1)
202
203 class TestScaleVnfViews(TestCase):
204     def setUp(self):
205         self.client = Client()
206         self.ns_inst_id = str(uuid.uuid4())
207         self.nf_inst_id = str(uuid.uuid4())
208         self.vnffg_id = str(uuid.uuid4())
209         self.vim_id = str(uuid.uuid4())
210         self.job_id = str(uuid.uuid4())
211         self.nf_uuid = '111'
212         self.tenant = "tenantname"
213         NSInstModel(id=self.ns_inst_id, name="ns_name").save()
214         NfInstModel.objects.create(nfinstid=self.nf_inst_id, nf_name='name_1', vnf_id='1',
215                                    vnfm_inst_id='1', ns_inst_id='111,2-2-2',
216                                    max_cpu='14', max_ram='12296', max_hd='101', max_shd="20", max_net=10,
217                                    status='active', mnfinstid=self.nf_uuid, package_id='pkg1',
218                                    vnfd_model='{"metadata": {"vnfdId": "1","vnfdName": "PGW001",'
219                                               '"vnfProvider": "zte","vnfdVersion": "V00001","vnfVersion": "V5.10.20",'
220                                               '"productType": "CN","vnfType": "PGW",'
221                                               '"description": "PGW VNFD description",'
222                                               '"isShared":true,"vnfExtendType":"driver"}}')
223
224     def tearDown(self):
225         NSInstModel.objects.all().delete()
226         NfInstModel.objects.all().delete()
227
228     @mock.patch.object(restcall, "call_req")
229     def test_scale_vnf(self, mock_call_req):
230         job_id = JobUtil.create_job("VNF", JOB_TYPE.TERMINATE_VNF, self.nf_inst_id)
231
232         vnfd_info = {
233             "vnf_flavours":[
234                 {
235                     "flavour_id":"flavour1",
236                     "description":"",
237                     "vdu_profiles":[
238                         {
239                             "vdu_id":"vdu1Id",
240                             "instances_minimum_number": 1,
241                             "instances_maximum_number": 4,
242                             "local_affinity_antiaffinity_rule":[
243                                 {
244                                     "affinity_antiaffinity":"affinity",
245                                     "scope":"node",
246                                 }
247                             ]
248                         }
249                     ],
250                     "scaling_aspects":[
251                         {
252                             "id": "demo_aspect",
253                             "name": "demo_aspect",
254                             "description": "demo_aspect",
255                             "associated_group": "elementGroup1",
256                             "max_scale_level": 5
257                         }
258                     ]
259                 }
260             ],
261             "element_groups": [
262                   {
263                       "group_id": "elementGroup1",
264                       "description": "",
265                       "properties":{
266                           "name": "elementGroup1",
267                       },
268                       "members": ["gsu_vm","pfu_vm"],
269                   }
270             ]
271         }
272
273         req_data = {
274             "scaleVnfData": [
275                 {
276                     "type":"SCALE_OUT",
277                     "aspectId":"demo_aspect1",
278                     "numberOfSteps":1,
279                     "additionalParam":vnfd_info
280                 },
281                 {
282                     "type":"SCALE_OUT",
283                     "aspectId":"demo_aspect2",
284                     "numberOfSteps":1,
285                     "additionalParam":vnfd_info
286                 }
287             ]
288         }
289
290
291         mock_vals = {
292             "/api/ztevmanagerdriver/v1/1/vnfs/111/terminate":
293                 [0, json.JSONEncoder().encode({"jobId": job_id}), '200'],
294             "/api/ztevmanagerdriver/v1/1/vnfs/111/terminate":
295                 [0, json.JSONEncoder().encode({"jobId": job_id}), '200']
296         }
297         NFManualScaleService(self.nf_inst_id, req_data).run()
298         nsIns = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
299         if nsIns:
300             self.failUnlessEqual(1, 1)
301         else:
302             self.failUnlessEqual(1, 0)
303
304
305 class TestHealVnfViews(TestCase):
306     def setUp(self):
307         self.client = Client()
308         self.ns_inst_id = str(uuid.uuid4())
309         self.nf_inst_id = str(uuid.uuid4())
310         self.nf_uuid = '111'
311
312         self.job_id = JobUtil.create_job("VNF", JOB_TYPE.HEAL_VNF, self.nf_inst_id)
313
314         NSInstModel(id=self.ns_inst_id, name="ns_name").save()
315         NfInstModel.objects.create(nfinstid=self.nf_inst_id, nf_name='name_1', vnf_id='1',
316                                    vnfm_inst_id='1', ns_inst_id='111,2-2-2',
317                                    max_cpu='14', max_ram='12296', max_hd='101', max_shd="20", max_net=10,
318                                    status='active', mnfinstid=self.nf_uuid, package_id='pkg1',
319                                    vnfd_model='{"metadata": {"vnfdId": "1","vnfdName": "PGW001",'
320                                               '"vnfProvider": "zte","vnfdVersion": "V00001","vnfVersion": "V5.10.20",'
321                                               '"productType": "CN","vnfType": "PGW",'
322                                               '"description": "PGW VNFD description",'
323                                               '"isShared":true,"vnfExtendType":"driver"}}')
324
325     def tearDown(self):
326         NSInstModel.objects.all().delete()
327         NfInstModel.objects.all().delete()
328
329     @mock.patch.object(restcall, "call_req")
330     def test_heal_vnf(self, mock_call_req):
331
332
333         mock_vals = {
334             "/api/ztevmanagerdriver/v1/1/vnfs/111/heal":
335                 [0, json.JSONEncoder().encode({"jobId": self.job_id}), '200'],
336             "/api/extsys/v1/vnfms/1":
337                 [0, json.JSONEncoder().encode({"name": 'vnfm1', "type": 'ztevmanagerdriver'}), '200'],
338             "/api/resmgr/v1/vnf/1":
339                 [0, json.JSONEncoder().encode({"jobId": self.job_id}), '200'],
340             "/api/ztevmanagerdriver/v1/1/jobs/" + self.job_id + "?responseId=0":
341                 [0, json.JSONEncoder().encode({"jobId": self.job_id,
342                                                "responsedescriptor": {"progress": "100",
343                                                                       "status": JOB_MODEL_STATUS.FINISHED,
344                                                                       "responseid": "3",
345                                                                       "statusdescription": "creating",
346                                                                       "errorcode": "0",
347                                                                       "responsehistorylist": [
348                                                                           {"progress": "0",
349                                                                            "status": JOB_MODEL_STATUS.PROCESSING,
350                                                                            "responseid": "2",
351                                                                            "statusdescription": "creating",
352                                                                            "errorcode": "0"}]}}), '200']}
353
354         def side_effect(*args):
355             return mock_vals[args[4]]
356
357         mock_call_req.side_effect = side_effect
358
359         req_data = {
360             "action": "vmReset",
361             "affectedvm": {
362                 "vmid": "1",
363                 "vduid": "1",
364                 "vmname": "name",
365             }
366         }
367
368         NFHealService(self.nf_inst_id, req_data).run()
369
370         self.assertEqual(NfInstModel.objects.get(nfinstid=self.nf_inst_id).status, VNF_STATUS.ACTIVE)
371
372     @mock.patch.object(NFHealService, "run")
373     def test_heal_vnf_non_existing_vnf(self, mock_biz):
374         mock_biz.side_effect = NSLCMException("VNF Not Found")
375
376         nf_inst_id = "1"
377
378         req_data = {
379             "action": "vmReset",
380             "affectedvm": {
381                 "vmid": "1",
382                 "vduid": "1",
383                 "vmname": "name",
384             }
385         }
386
387         self.assertRaises(NSLCMException, NFHealService(nf_inst_id, req_data).run)
388         self.assertEqual(len(NfInstModel.objects.filter(nfinstid=nf_inst_id)), 0)
389
390 vnfd_model_dict = {
391     'local_storages': [],
392     'vdus': [
393         {
394             'volumn_storages': [],
395             'nfv_compute': {
396                 'mem_size': '',
397                 'num_cpus': u'2'},
398             'local_storages': [],
399             'vdu_id': u'vdu_omm.001',
400             'image_file': u'opencos_sss_omm_img_release_20150723-1-disk1',
401             'dependencies': [],
402             'vls': [],
403             'cps': [],
404             'properties': {
405                 'key_vdu': '',
406                 'support_scaling': False,
407                 'vdu_type': '',
408                 'name': '',
409                 'storage_policy': '',
410                 'location_info': {
411                     'vimId': '',
412                     'availability_zone': '',
413                     'region': '',
414                     'dc': '',
415                     'host': '',
416                     'tenant': ''},
417                 'inject_data_list': [],
418                 'watchdog': {
419                     'action': '',
420                     'enabledelay': ''},
421                 'local_affinity_antiaffinity_rule': {},
422                 'template_id': u'omm.001',
423                 'manual_scale_select_vim': False},
424             'description': u'singleommvm'},
425         {
426             'volumn_storages': [],
427             'nfv_compute': {
428                 'mem_size': '',
429                 'num_cpus': u'4'},
430             'local_storages': [],
431             'vdu_id': u'vdu_1',
432             'image_file': u'sss',
433             'dependencies': [],
434             'vls': [],
435             'cps': [],
436             'properties': {
437                 'key_vdu': '',
438                 'support_scaling': False,
439                 'vdu_type': '',
440                 'name': '',
441                 'storage_policy': '',
442                 'location_info': {
443                     'vimId': '',
444                     'availability_zone': '',
445                     'region': '',
446                     'dc': '',
447                     'host': '',
448                     'tenant': ''},
449                 'inject_data_list': [],
450                 'watchdog': {
451                     'action': '',
452                     'enabledelay': ''},
453                 'local_affinity_antiaffinity_rule': {},
454                 'template_id': u'1',
455                 'manual_scale_select_vim': False},
456             'description': u'ompvm'},
457         {
458             'volumn_storages': [],
459             'nfv_compute': {
460                 'mem_size': '',
461                 'num_cpus': u'14'},
462             'local_storages': [],
463             'vdu_id': u'vdu_2',
464             'image_file': u'sss',
465             'dependencies': [],
466             'vls': [],
467             'cps': [],
468             'properties': {
469                 'key_vdu': '',
470                 'support_scaling': False,
471                 'vdu_type': '',
472                 'name': '',
473                 'storage_policy': '',
474                 'location_info': {
475                     'vimId': '',
476                     'availability_zone': '',
477                     'region': '',
478                     'dc': '',
479                     'host': '',
480                     'tenant': ''},
481                 'inject_data_list': [],
482                 'watchdog': {
483                     'action': '',
484                     'enabledelay': ''},
485                 'local_affinity_antiaffinity_rule': {},
486                 'template_id': u'2',
487                 'manual_scale_select_vim': False},
488             'description': u'ompvm'},
489         {
490             'volumn_storages': [],
491             'nfv_compute': {
492                 'mem_size': '',
493                 'num_cpus': u'14'},
494             'local_storages': [],
495             'vdu_id': u'vdu_3',
496             'image_file': u'sss',
497             'dependencies': [],
498             'vls': [],
499             'cps': [],
500             'properties': {
501                 'key_vdu': '',
502                 'support_scaling': False,
503                 'vdu_type': '',
504                 'name': '',
505                 'storage_policy': '',
506                 'location_info': {
507                     'vimId': '',
508                     'availability_zone': '',
509                     'region': '',
510                     'dc': '',
511                     'host': '',
512                     'tenant': ''},
513                 'inject_data_list': [],
514                 'watchdog': {
515                     'action': '',
516                     'enabledelay': ''},
517                 'local_affinity_antiaffinity_rule': {},
518                 'template_id': u'3',
519                 'manual_scale_select_vim': False},
520             'description': u'ompvm'},
521         {
522             'volumn_storages': [],
523             'nfv_compute': {
524                 'mem_size': '',
525                 'num_cpus': u'4'},
526             'local_storages': [],
527             'vdu_id': u'vdu_10',
528             'image_file': u'sss',
529             'dependencies': [],
530             'vls': [],
531             'cps': [],
532             'properties': {
533                 'key_vdu': '',
534                 'support_scaling': False,
535                 'vdu_type': '',
536                 'name': '',
537                 'storage_policy': '',
538                 'location_info': {
539                     'vimId': '',
540                     'availability_zone': '',
541                     'region': '',
542                     'dc': '',
543                     'host': '',
544                     'tenant': ''},
545                 'inject_data_list': [],
546                 'watchdog': {
547                     'action': '',
548                     'enabledelay': ''},
549                 'local_affinity_antiaffinity_rule': {},
550                 'template_id': u'10',
551                 'manual_scale_select_vim': False},
552             'description': u'ppvm'},
553         {
554             'volumn_storages': [],
555             'nfv_compute': {
556                 'mem_size': '',
557                 'num_cpus': u'14'},
558             'local_storages': [],
559             'vdu_id': u'vdu_11',
560             'image_file': u'sss',
561             'dependencies': [],
562             'vls': [],
563             'cps': [],
564             'properties': {
565                 'key_vdu': '',
566                 'support_scaling': False,
567                 'vdu_type': '',
568                 'name': '',
569                 'storage_policy': '',
570                 'location_info': {
571                     'vimId': '',
572                     'availability_zone': '',
573                     'region': '',
574                     'dc': '',
575                     'host': '',
576                     'tenant': ''},
577                 'inject_data_list': [],
578                 'watchdog': {
579                     'action': '',
580                     'enabledelay': ''},
581                 'local_affinity_antiaffinity_rule': {},
582                 'template_id': u'11',
583                 'manual_scale_select_vim': False},
584             'description': u'ppvm'},
585         {
586             'volumn_storages': [],
587             'nfv_compute': {
588                 'mem_size': '',
589                 'num_cpus': u'14'},
590             'local_storages': [],
591             'vdu_id': u'vdu_12',
592             'image_file': u'sss',
593             'dependencies': [],
594             'vls': [],
595             'cps': [],
596             'properties': {
597                 'key_vdu': '',
598                 'support_scaling': False,
599                 'vdu_type': '',
600                 'name': '',
601                 'storage_policy': '',
602                 'location_info': {
603                     'vimId': '',
604                     'availability_zone': '',
605                     'region': '',
606                     'dc': '',
607                     'host': '',
608                     'tenant': ''},
609                 'inject_data_list': [],
610                 'watchdog': {
611                     'action': '',
612                     'enabledelay': ''},
613                 'local_affinity_antiaffinity_rule': {},
614                 'template_id': u'12',
615                 'manual_scale_select_vim': False},
616             'description': u'ppvm'}],
617     'volumn_storages': [],
618     'policies': {
619         'scaling': {
620             'targets': {},
621             'policy_id': u'policy_scale_sss-vnf-template',
622             'properties': {
623                 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'},
624             'description': ''}},
625     'image_files': [
626         {
627             'description': '',
628             'properties': {
629                 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
630                 'checksum': '',
631                 'disk_format': u'VMDK',
632                 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
633                 'container_type': 'vm',
634                 'version': '',
635                 'hypervisor_type': 'kvm'},
636             'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'},
637         {
638             'description': '',
639             'properties': {
640                 'name': u'sss.vmdk',
641                 'checksum': '',
642                 'disk_format': u'VMDK',
643                 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
644                 'container_type': 'vm',
645                 'version': '',
646                 'hypervisor_type': 'kvm'},
647             'image_file_id': u'sss'}],
648     'vls': [],
649     'cps': [],
650     'metadata': {
651         'vendor': u'zte',
652         'is_shared': False,
653         'description': '',
654         'domain_type': u'CN',
655         'version': u'v4.14.10',
656         'vmnumber_overquota_alarm': False,
657         'cross_dc': False,
658         'vnf_type': u'SSS',
659         'vnfd_version': u'V00000001',
660         'id': u'sss-vnf-template',
661         'name': u'sss-vnf-template'}}
662
663 nsd_model_dict = {
664     "vnffgs": [],
665     "inputs": {
666         "externalDataNetworkName": {
667             "default": "",
668             "type": "string",
669             "description": ""}},
670     "pnfs": [],
671     "fps": [],
672     "server_groups": [],
673     "ns_flavours": [],
674     "vnfs": [
675         {
676             "dependency": [],
677             "properties": {
678                 "plugin_info": "vbrasplugin_1.0",
679                 "vendor": "zte",
680                 "is_shared": "False",
681                 "request_reclassification": "False",
682                 "vnfd_version": "1.0.0",
683                 "version": "1.0",
684                 "nsh_aware": "True",
685                 "cross_dc": "False",
686                 "externalDataNetworkName": {
687                     "get_input": "externalDataNetworkName"},
688                 "id": "zte_vbras",
689                 "name": "vbras"},
690             "vnf_id": "VBras",
691             "networks": [],
692             "description": ""}],
693     "ns_exposed": {
694         "external_cps": [],
695         "forward_cps": []},
696     "vls": [
697         {
698             "vl_id": "ext_mnet_network",
699             "description": "",
700             "properties": {
701                 "network_type": "vlan",
702                 "name": "externalMNetworkName",
703                 "dhcp_enabled": False,
704                 "location_info": {
705                     "host": True,
706                     "vimid": 2,
707                     "region": True,
708                     "tenant": "admin",
709                     "dc": ""},
710                 "end_ip": "190.168.100.100",
711                 "gateway_ip": "190.168.100.1",
712                 "start_ip": "190.168.100.2",
713                 "cidr": "190.168.100.0/24",
714                 "mtu": 1500,
715                 "network_name": "sub_mnet",
716                 "ip_version": 4}}],
717     "cps": [],
718     "policies": [],
719     "metadata": {
720         "invariant_id": "vbras_ns",
721         "description": "vbras_ns",
722         "version": 1,
723         "vendor": "zte",
724         "id": "vbras_ns",
725         "name": "vbras_ns"}}