b71f75df4b4900845b28cafb87552cdd5c2b1660
[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/aai-esr-server/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/aai-esr-server/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         def side_effect(*args):
298             return mock_vals[args[4]]
299         mock_call_req.side_effect = side_effect
300
301         NFManualScaleService(self.nf_inst_id, req_data).run()
302         nsIns = NfInstModel.objects.filter(nfinstid=self.nf_inst_id)
303         if nsIns:
304             self.failUnlessEqual(1, 1)
305         else:
306             self.failUnlessEqual(1, 0)
307
308
309 class TestHealVnfViews(TestCase):
310     def setUp(self):
311         self.client = Client()
312         self.ns_inst_id = str(uuid.uuid4())
313         self.nf_inst_id = str(uuid.uuid4())
314         self.nf_uuid = '111'
315
316         self.job_id = JobUtil.create_job("VNF", JOB_TYPE.HEAL_VNF, self.nf_inst_id)
317
318         NSInstModel(id=self.ns_inst_id, name="ns_name").save()
319         NfInstModel.objects.create(nfinstid=self.nf_inst_id, nf_name='name_1', vnf_id='1',
320                                    vnfm_inst_id='1', ns_inst_id='111,2-2-2',
321                                    max_cpu='14', max_ram='12296', max_hd='101', max_shd="20", max_net=10,
322                                    status='active', mnfinstid=self.nf_uuid, package_id='pkg1',
323                                    vnfd_model='{"metadata": {"vnfdId": "1","vnfdName": "PGW001",'
324                                               '"vnfProvider": "zte","vnfdVersion": "V00001","vnfVersion": "V5.10.20",'
325                                               '"productType": "CN","vnfType": "PGW",'
326                                               '"description": "PGW VNFD description",'
327                                               '"isShared":true,"vnfExtendType":"driver"}}')
328
329     def tearDown(self):
330         NSInstModel.objects.all().delete()
331         NfInstModel.objects.all().delete()
332
333     @mock.patch.object(restcall, "call_req")
334     def test_heal_vnf(self, mock_call_req):
335
336
337         mock_vals = {
338             "/api/ztevmanagerdriver/v1/1/vnfs/111/heal":
339                 [0, json.JSONEncoder().encode({"jobId": self.job_id}), '200'],
340             "/api/aai-esr-server/v1/vnfms/1":
341                 [0, json.JSONEncoder().encode({"name": 'vnfm1', "type": 'ztevmanagerdriver'}), '200'],
342             "/api/resmgr/v1/vnf/1":
343                 [0, json.JSONEncoder().encode({"jobId": self.job_id}), '200'],
344             "/api/ztevmanagerdriver/v1/1/jobs/" + self.job_id + "?responseId=0":
345                 [0, json.JSONEncoder().encode({"jobId": self.job_id,
346                                                "responsedescriptor": {"progress": "100",
347                                                                       "status": JOB_MODEL_STATUS.FINISHED,
348                                                                       "responseid": "3",
349                                                                       "statusdescription": "creating",
350                                                                       "errorcode": "0",
351                                                                       "responsehistorylist": [
352                                                                           {"progress": "0",
353                                                                            "status": JOB_MODEL_STATUS.PROCESSING,
354                                                                            "responseid": "2",
355                                                                            "statusdescription": "creating",
356                                                                            "errorcode": "0"}]}}), '200']}
357
358         def side_effect(*args):
359             return mock_vals[args[4]]
360
361         mock_call_req.side_effect = side_effect
362
363         req_data = {
364             "action": "vmReset",
365             "affectedvm": {
366                 "vmid": "1",
367                 "vduid": "1",
368                 "vmname": "name",
369             }
370         }
371
372         NFHealService(self.nf_inst_id, req_data).run()
373
374         self.assertEqual(NfInstModel.objects.get(nfinstid=self.nf_inst_id).status, VNF_STATUS.ACTIVE)
375
376     @mock.patch.object(NFHealService, "run")
377     def test_heal_vnf_non_existing_vnf(self, mock_biz):
378         mock_biz.side_effect = NSLCMException("VNF Not Found")
379
380         nf_inst_id = "1"
381
382         req_data = {
383             "action": "vmReset",
384             "affectedvm": {
385                 "vmid": "1",
386                 "vduid": "1",
387                 "vmname": "name",
388             }
389         }
390
391         self.assertRaises(NSLCMException, NFHealService(nf_inst_id, req_data).run)
392         self.assertEqual(len(NfInstModel.objects.filter(nfinstid=nf_inst_id)), 0)
393
394 vnfd_model_dict = {
395     'local_storages': [],
396     'vdus': [
397         {
398             'volumn_storages': [],
399             'nfv_compute': {
400                 'mem_size': '',
401                 'num_cpus': u'2'},
402             'local_storages': [],
403             'vdu_id': u'vdu_omm.001',
404             'image_file': u'opencos_sss_omm_img_release_20150723-1-disk1',
405             'dependencies': [],
406             'vls': [],
407             'cps': [],
408             'properties': {
409                 'key_vdu': '',
410                 'support_scaling': False,
411                 'vdu_type': '',
412                 'name': '',
413                 'storage_policy': '',
414                 'location_info': {
415                     'vimId': '',
416                     'availability_zone': '',
417                     'region': '',
418                     'dc': '',
419                     'host': '',
420                     'tenant': ''},
421                 'inject_data_list': [],
422                 'watchdog': {
423                     'action': '',
424                     'enabledelay': ''},
425                 'local_affinity_antiaffinity_rule': {},
426                 'template_id': u'omm.001',
427                 'manual_scale_select_vim': False},
428             'description': u'singleommvm'},
429         {
430             'volumn_storages': [],
431             'nfv_compute': {
432                 'mem_size': '',
433                 'num_cpus': u'4'},
434             'local_storages': [],
435             'vdu_id': u'vdu_1',
436             'image_file': u'sss',
437             'dependencies': [],
438             'vls': [],
439             'cps': [],
440             'properties': {
441                 'key_vdu': '',
442                 'support_scaling': False,
443                 'vdu_type': '',
444                 'name': '',
445                 'storage_policy': '',
446                 'location_info': {
447                     'vimId': '',
448                     'availability_zone': '',
449                     'region': '',
450                     'dc': '',
451                     'host': '',
452                     'tenant': ''},
453                 'inject_data_list': [],
454                 'watchdog': {
455                     'action': '',
456                     'enabledelay': ''},
457                 'local_affinity_antiaffinity_rule': {},
458                 'template_id': u'1',
459                 'manual_scale_select_vim': False},
460             'description': u'ompvm'},
461         {
462             'volumn_storages': [],
463             'nfv_compute': {
464                 'mem_size': '',
465                 'num_cpus': u'14'},
466             'local_storages': [],
467             'vdu_id': u'vdu_2',
468             'image_file': u'sss',
469             'dependencies': [],
470             'vls': [],
471             'cps': [],
472             'properties': {
473                 'key_vdu': '',
474                 'support_scaling': False,
475                 'vdu_type': '',
476                 'name': '',
477                 'storage_policy': '',
478                 'location_info': {
479                     'vimId': '',
480                     'availability_zone': '',
481                     'region': '',
482                     'dc': '',
483                     'host': '',
484                     'tenant': ''},
485                 'inject_data_list': [],
486                 'watchdog': {
487                     'action': '',
488                     'enabledelay': ''},
489                 'local_affinity_antiaffinity_rule': {},
490                 'template_id': u'2',
491                 'manual_scale_select_vim': False},
492             'description': u'ompvm'},
493         {
494             'volumn_storages': [],
495             'nfv_compute': {
496                 'mem_size': '',
497                 'num_cpus': u'14'},
498             'local_storages': [],
499             'vdu_id': u'vdu_3',
500             'image_file': u'sss',
501             'dependencies': [],
502             'vls': [],
503             'cps': [],
504             'properties': {
505                 'key_vdu': '',
506                 'support_scaling': False,
507                 'vdu_type': '',
508                 'name': '',
509                 'storage_policy': '',
510                 'location_info': {
511                     'vimId': '',
512                     'availability_zone': '',
513                     'region': '',
514                     'dc': '',
515                     'host': '',
516                     'tenant': ''},
517                 'inject_data_list': [],
518                 'watchdog': {
519                     'action': '',
520                     'enabledelay': ''},
521                 'local_affinity_antiaffinity_rule': {},
522                 'template_id': u'3',
523                 'manual_scale_select_vim': False},
524             'description': u'ompvm'},
525         {
526             'volumn_storages': [],
527             'nfv_compute': {
528                 'mem_size': '',
529                 'num_cpus': u'4'},
530             'local_storages': [],
531             'vdu_id': u'vdu_10',
532             'image_file': u'sss',
533             'dependencies': [],
534             'vls': [],
535             'cps': [],
536             'properties': {
537                 'key_vdu': '',
538                 'support_scaling': False,
539                 'vdu_type': '',
540                 'name': '',
541                 'storage_policy': '',
542                 'location_info': {
543                     'vimId': '',
544                     'availability_zone': '',
545                     'region': '',
546                     'dc': '',
547                     'host': '',
548                     'tenant': ''},
549                 'inject_data_list': [],
550                 'watchdog': {
551                     'action': '',
552                     'enabledelay': ''},
553                 'local_affinity_antiaffinity_rule': {},
554                 'template_id': u'10',
555                 'manual_scale_select_vim': False},
556             'description': u'ppvm'},
557         {
558             'volumn_storages': [],
559             'nfv_compute': {
560                 'mem_size': '',
561                 'num_cpus': u'14'},
562             'local_storages': [],
563             'vdu_id': u'vdu_11',
564             'image_file': u'sss',
565             'dependencies': [],
566             'vls': [],
567             'cps': [],
568             'properties': {
569                 'key_vdu': '',
570                 'support_scaling': False,
571                 'vdu_type': '',
572                 'name': '',
573                 'storage_policy': '',
574                 'location_info': {
575                     'vimId': '',
576                     'availability_zone': '',
577                     'region': '',
578                     'dc': '',
579                     'host': '',
580                     'tenant': ''},
581                 'inject_data_list': [],
582                 'watchdog': {
583                     'action': '',
584                     'enabledelay': ''},
585                 'local_affinity_antiaffinity_rule': {},
586                 'template_id': u'11',
587                 'manual_scale_select_vim': False},
588             'description': u'ppvm'},
589         {
590             'volumn_storages': [],
591             'nfv_compute': {
592                 'mem_size': '',
593                 'num_cpus': u'14'},
594             'local_storages': [],
595             'vdu_id': u'vdu_12',
596             'image_file': u'sss',
597             'dependencies': [],
598             'vls': [],
599             'cps': [],
600             'properties': {
601                 'key_vdu': '',
602                 'support_scaling': False,
603                 'vdu_type': '',
604                 'name': '',
605                 'storage_policy': '',
606                 'location_info': {
607                     'vimId': '',
608                     'availability_zone': '',
609                     'region': '',
610                     'dc': '',
611                     'host': '',
612                     'tenant': ''},
613                 'inject_data_list': [],
614                 'watchdog': {
615                     'action': '',
616                     'enabledelay': ''},
617                 'local_affinity_antiaffinity_rule': {},
618                 'template_id': u'12',
619                 'manual_scale_select_vim': False},
620             'description': u'ppvm'}],
621     'volumn_storages': [],
622     'policies': {
623         'scaling': {
624             'targets': {},
625             'policy_id': u'policy_scale_sss-vnf-template',
626             'properties': {
627                 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'},
628             'description': ''}},
629     'image_files': [
630         {
631             'description': '',
632             'properties': {
633                 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
634                 'checksum': '',
635                 'disk_format': u'VMDK',
636                 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
637                 'container_type': 'vm',
638                 'version': '',
639                 'hypervisor_type': 'kvm'},
640             'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'},
641         {
642             'description': '',
643             'properties': {
644                 'name': u'sss.vmdk',
645                 'checksum': '',
646                 'disk_format': u'VMDK',
647                 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
648                 'container_type': 'vm',
649                 'version': '',
650                 'hypervisor_type': 'kvm'},
651             'image_file_id': u'sss'}],
652     'vls': [],
653     'cps': [],
654     'metadata': {
655         'vendor': u'zte',
656         'is_shared': False,
657         'description': '',
658         'domain_type': u'CN',
659         'version': u'v4.14.10',
660         'vmnumber_overquota_alarm': False,
661         'cross_dc': False,
662         'vnf_type': u'SSS',
663         'vnfd_version': u'V00000001',
664         'id': u'sss-vnf-template',
665         'name': u'sss-vnf-template'}}
666
667 nsd_model_dict = {
668     "vnffgs": [],
669     "inputs": {
670         "externalDataNetworkName": {
671             "default": "",
672             "type": "string",
673             "description": ""}},
674     "pnfs": [],
675     "fps": [],
676     "server_groups": [],
677     "ns_flavours": [],
678     "vnfs": [
679         {
680             "dependency": [],
681             "properties": {
682                 "plugin_info": "vbrasplugin_1.0",
683                 "vendor": "zte",
684                 "is_shared": "False",
685                 "request_reclassification": "False",
686                 "vnfd_version": "1.0.0",
687                 "version": "1.0",
688                 "nsh_aware": "True",
689                 "cross_dc": "False",
690                 "externalDataNetworkName": {
691                     "get_input": "externalDataNetworkName"},
692                 "id": "zte_vbras",
693                 "name": "vbras"},
694             "vnf_id": "VBras",
695             "networks": [],
696             "description": ""}],
697     "ns_exposed": {
698         "external_cps": [],
699         "forward_cps": []},
700     "vls": [
701         {
702             "vl_id": "ext_mnet_network",
703             "description": "",
704             "properties": {
705                 "network_type": "vlan",
706                 "name": "externalMNetworkName",
707                 "dhcp_enabled": False,
708                 "location_info": {
709                     "host": True,
710                     "vimid": 2,
711                     "region": True,
712                     "tenant": "admin",
713                     "dc": ""},
714                 "end_ip": "190.168.100.100",
715                 "gateway_ip": "190.168.100.1",
716                 "start_ip": "190.168.100.2",
717                 "cidr": "190.168.100.0/24",
718                 "mtu": 1500,
719                 "network_name": "sub_mnet",
720                 "ip_version": 4}}],
721     "cps": [],
722     "policies": [],
723     "metadata": {
724         "invariant_id": "vbras_ns",
725         "description": "vbras_ns",
726         "version": 1,
727         "vendor": "zte",
728         "id": "vbras_ns",
729         "name": "vbras_ns"}}