Fix bugs for ztevnfmdriver
[vfc/nfvo/driver/vnfm/svnfm.git] / zte / vmanager / driver / interfaces / 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
15 import json
16 import mock
17 from django.test import Client
18 from django.test import TestCase
19 from rest_framework import status
20 from driver.pub.utils import restcall
21
22
23 class InterfacesTest(TestCase):
24     def setUp(self):
25         self.client = Client()
26
27     def tearDown(self):
28         pass
29
30     @mock.patch.object(restcall, 'call_req')
31     def test_instantiate_vnf_001(self, mock_call_req):
32         vnfm_info = {
33             "userName": "admin",
34             "vendor": "ZTE",
35             "name": "ZTE_VNFM_237_62",
36             "vimId": "516cee95-e8ca-4d26-9268-38e343c2e31e",
37             "url": "http://192.168.237.165:2324",
38             "certificateUrl": "",
39             "version": "V1.0",
40             "vnfmId": "b0797c9b-3da9-459c-b25c-3813e9d8fd70",
41             "password": "admin",
42             "type": "ztevnfmdriver",
43             "createTime": "2016-10-31 11:08:39",
44             "description": ""
45         }
46         vnfd_info = {
47             "vnfInstanceInfo": [
48                 {
49                     "vnfInstanceId": "59b79a9f-9e37-4f6c-acaf-5f41d9cb3f76",
50                     "vnfInstanceName": "VFW_59b79a9f-9e37-4f6c-acaf-5f41d9cb3f76"
51                 },
52                 {
53                     "vnfInstanceId": "6c5e4bd3-e8a6-42d8-a7a4-53a8ef74c6ac",
54                     "vnfInstanceName": "VFW_6c5e4bd3-e8a6-42d8-a7a4-53a8ef74c6ac"
55                 },
56                 {
57                     "vnfInstanceId": "930de5c9-8043-41df-ace8-ede2262a3713",
58                     "vnfInstanceName": "VFW_930de5c9-8043-41df-ace8-ede2262a3713"
59                 },
60                 {
61                     "vnfInstanceId": "c677a305-a7bd-4baf-9eee-c383c588bb3c",
62                     "vnfInstanceName": "VFW_c677a305-a7bd-4baf-9eee-c383c588bb3c"
63                 },
64                 {
65                     "vnfInstanceId": "e708e5c5-bdf4-436a-b928-826887806d82",
66                     "vnfInstanceName": "VFW_e708e5c5-bdf4-436a-b928-826887806d82"
67                 }
68             ],
69             "csarId": "d852e1be-0aac-48f1-b1a4-cd825f6cdf9a",
70             "imageInfo": [
71                 {
72                     "status": "Enable",
73                     "index": "0",
74                     "vimId": "516cee95-e8ca-4d26-9268-38e343c2e31e",
75                     "fileName": "VFW_IMAGE_VCPE_ZTE",
76                     "vimUser": "admin",
77                     "imageId": "d2b73154-0414-466a-a1e6-51b9461b753a",
78                     "tenant": "admin"
79                 }
80             ],
81             "packageInfo": {
82                 "usageState": "NotInUse",
83                 "onBoardState": "onBoarded",
84                 "name": "VFW",
85                 "format": "yaml",
86                 "provider": "ZTE",
87                 "vnfdProvider": "zte",
88                 "vnfdId": "vcpe_vfw_zte_1_0",
89                 "deletionPending": False,
90                 "version": "v1.0",
91                 "vnfVersion": "1.0",
92                 "vnfdVersion": "1.0.0",
93                 "processState": "normal",
94                 "modifyTime": "2016-10-3116: 21: 32",
95                 "downloadUri": "http: //192.168.233.226: 80/",
96                 "operationalState": "Disabled",
97                 "createTime": "2016-10-3116: 21: 11",
98                 "size": "12.1MB"
99             }
100         }
101         packageInfo = {
102             "size": "12.1 MB",
103             "usageState": "NotInUse",
104             "onBoardState": "onBoarded",
105             "name": "VFW",
106             "format": "yaml",
107             "packageInfo": {
108                 "vnfdModel": json.dumps({"metadata": {"name": "ZTE-MME-FIX-VL"}})
109             },
110             "modifyTime": "2016-10-31 16:21:32",
111             "vnfdProvider": "zte",
112             "vnfdId": "vcpe_vfw_zte_1_0",
113             "deletionPending": False,
114             "version": "v1.0",
115             "vnfVersion": "1.0",
116             "vnfdVersion": "1.0.0",
117             "processState": "normal",
118             "provider": "ZTE",
119             "operationalState": "Disabled",
120             "createTime": "2016-10-31 16:21:11",
121             "downloadUri": "http://192.168.233.226:80/files/catalog-http/NFAR/ZTE/VFW/v1.0/VFW.csar"
122         }
123
124         inst_response = {
125             "vnfInstanceId": "8",
126             "jobid": "NF-CREATE-8-b384535c-9f45-11e6-8749-fa163e91c2f9"
127         }
128         ret = [0, json.JSONEncoder().encode(inst_response), '200']
129         r1 = [0, json.JSONEncoder().encode(vnfm_info), "200"]
130         r2 = [0, json.JSONEncoder().encode(vnfd_info), "200"]
131         r3 = [0, json.JSONEncoder().encode(packageInfo), "200"]
132         mock_call_req.side_effect = [r1, r2, r3, ret]
133         mock_call_req.side_effect = [r1, ret]
134
135         req_data = {
136             'vnfInstanceName': 'VFW_f88c0cb7-512a-44c4-bd09-891663f19367',
137             'vnfPackageId': 'd852e1be-0aac-48f1-b1a4-cd825f6cdf9a',
138             'vnfDescriptorId': 'vcpe_vfw_zte_1_0',
139             'additionalParam': {
140                 'sdncontroller': 'e4d637f1-a4ec-4c59-8b20-4e8ab34daba9',
141                 'NatIpRange': '192.167.0.10-192.168.0.20',
142                 'm6000_mng_ip': '192.168.11.11',
143                 'externalPluginManageNetworkName': 'plugin_net_2014',
144                 'location': '516cee95-e8ca-4d26-9268-38e343c2e31e',
145                 'externalManageNetworkName': 'mng_net_2017',
146                 'sfc_data_network': 'sfc_data_net_2016',
147                 'externalDataNetworkName': 'Flow_out_net',
148                 'inputs': {}
149             }
150         }
151
152         response = self.client.post(
153             "/api/ztevnfmdriver/v1/ztevnfmid/vnfs",
154             data=json.dumps(req_data),
155             content_type="application/json")
156         self.assertEqual(status.HTTP_200_OK, response.status_code)
157         expect_resp_data = {
158             "jobId": "NF-CREATE-8-b384535c-9f45-11e6-8749-fa163e91c2f9",
159             "vnfInstanceId": "8"}
160         self.assertEqual(expect_resp_data, response.data)
161
162     @mock.patch.object(restcall, 'call_req')
163     def test_terminate_vnf__002(self, mock_call_req):
164         r1 = [0, json.JSONEncoder().encode({
165             "vnfmId": "19ecbb3a-3242-4fa3-9926-8dfb7ddc29ee",
166             "name": "g_vnfm",
167             "type": "vnfm",
168             "vimId": "",
169             "vendor": "ZTE",
170             "version": "v1.0",
171             "description": "vnfm",
172             "certificateUrl": "",
173             "url": "http://10.74.44.11",
174             "userName": "admin",
175             "password": "admin",
176             "createTime": "2016-07-06 15:33:18"}), "200"]
177
178         r2 = [0, json.JSONEncoder().encode({"vnfInstanceId": "1", "jobId": "1"}), "200"]
179         mock_call_req.side_effect = [r1, r2]
180         req_data = {
181             "terminationType": "GRACEFUL",
182             "gracefulTerminationTimeout": 120
183         }
184         response = self.client.post(
185             "/api/ztevnfmdriver/v1/ztevnfmid/vnfs/1/terminate", data=req_data)
186
187         self.assertEqual(status.HTTP_200_OK, response.status_code)
188         expect_resp_data = {"jobId": "1", "vnfInstanceId": "1"}
189         self.assertEqual(expect_resp_data, response.data)
190
191     @mock.patch.object(restcall, 'call_req')
192     def test_query_vnf_003(self, mock_call_req):
193         r1 = [0, json.JSONEncoder().encode({
194             "vnfmId": "19ecbb3a-3242-4fa3-9926-8dfb7ddc29ee",
195             "name": "g_vnfm",
196             "type": "vnfm",
197             "vimId": "",
198             "vendor": "ZTE",
199             "version": "v1.0",
200             "description": "vnfm",
201             "certificateUrl": "",
202             "url": "http://10.74.44.11",
203             "userName": "admin",
204             "password": "admin",
205             "createTime": "2016-07-06 15:33:18"}), "200"]
206
207         r2 = [0, json.JSONEncoder().encode({"vnfinstancestatus": "1"}), "200"]
208         mock_call_req.side_effect = [r1, r2]
209
210         response = self.client.get(
211             "/api/ztevnfmdriver/v1/ztevnfmid/vnfs/vbras_innstance_id")
212
213         self.assertEqual(status.HTTP_200_OK, response.status_code)
214
215         expect_resp_data = {"vnfInfo": {"vnfStatus": "1"}}
216         self.assertEqual(expect_resp_data, response.data)
217
218     @mock.patch.object(restcall, 'call_req')
219     def test_operation_status_004(self, mock_call_req):
220         vnfm_info = {
221             "userName": "admin",
222             "vendor": "ZTE",
223             "name": "ZTE_VNFM_237_62",
224             "vimId": "516cee95-e8ca-4d26-9268-38e343c2e31e",
225             "url": "http://192.168.237.165:2324",
226             "certificateUrl": "",
227             "version": "V1.0",
228             "vnfmId": "b0797c9b-3da9-459c-b25c-3813e9d8fd70",
229             "password": "admin",
230             "type": "ztevnfmdriver",
231             "createTime": "2016-10-31 11:08:39",
232             "description": ""
233         }
234         resp_body = {
235             "responseDescriptor": {
236                 "status": "processing",
237                 "responseHistoryList": [
238                     {
239                         "status": "error",
240                         "progress": 255,
241                         "errorCode": "",
242                         "responseId": 20,
243                         "statusDescription": "'JsonParser' object has no attribute 'parser_info'"}],
244                 "responseId": 21,
245                 "errorCode": "",
246                 "progress": 40,
247                 "statusDescription": "Create nf apply resource failed"},
248             "jobId": "NF-CREATE-11-ec6c2f2a-9f48-11e6-9405-fa163e91c2f9"}
249         r1 = [0, json.JSONEncoder().encode(vnfm_info), '200']
250         r2 = [0, json.JSONEncoder().encode(resp_body), '200']
251         mock_call_req.side_effect = [r1, r2]
252         response = self.client.get(
253             "/api/ztevnfmdriver/v1/{vnfmid}/jobs/{jobid}?responseId={responseId}".format(
254                 vnfmid=vnfm_info["vnfmId"],
255                 jobid=resp_body["jobId"],
256                 responseId=resp_body["responseDescriptor"]["responseId"]))
257
258         self.assertEqual(status.HTTP_200_OK, response.status_code)
259
260         self.assertDictEqual(resp_body, response.data)
261
262     @mock.patch.object(restcall, 'call_req')
263     def test_grantvnf_005(self, mock_call_req):
264         grant_data = {
265             "vim": {
266                 "accessinfo": {
267                     "tenant": "mano"
268                 },
269                 "vimid": "1"
270             }
271         }
272         ret = [0, json.JSONEncoder().encode(grant_data), '201']
273
274         req_data = {
275             "vnfmid": "13232222",
276             "nfvoid": "03212234",
277             "vimid": "12345678",
278             "exvimidlist ": [
279                 "exvimid"
280             ],
281             "tenant": " tenant1",
282             "vnfistanceid": "1234",
283             "operationright": "0",
284             "vmlist": [
285                 {
286                     "VMNumber": 1,
287                     "VMFlavor": "VDU_S_CDB_51",
288                     "vimid": "",
289                     "tenant": ""
290                 }, {
291                     "VMNumber": 1,
292                     "VMFlavor": "VDU_M_SLB_42",
293                     "vimid": "",
294                     "tenant": ""
295                 }
296             ]
297         }
298
299         mock_call_req.return_value = ret
300         response = self.client.put(
301             "/v1/resource/grant",
302             data=json.dumps(req_data),
303             content_type='application/json')
304
305         self.assertEqual(status.HTTP_201_CREATED, response.status_code)
306
307         expect_resp_data = {
308             "vimid": "1",
309             "tenant": "mano"}
310         self.assertDictEqual(expect_resp_data, response.data)
311
312     @mock.patch.object(restcall, 'call_req')
313     def test_notify_006(self, mock_call_req):
314         r1 = [0, json.JSONEncoder().encode(
315             {"vim":
316                 {
317                     "vimInfoId": "111111",
318                     "vimId": "12345678",
319                     "interfaceInfo": {
320                         "vimType": "vnf",
321                         "apiVersion": "v1",
322                         "protocolType": "None"},
323                     "accessInfo": {
324                         "tenant": "tenant1",
325                         "username": "admin",
326                         "password": "password"},
327                     "interfaceEndpoint": "http://127.0.0.1/api/v1"},
328                 "zone": "",
329                 "addResource": {
330                     "resourceDefinitionId": "xxxxx",
331                     "vimId": "12345678",
332                     "zoneId": "000"},
333                 "removeResource": "",
334                 "vimAssets": {
335                     "computeResourceFlavour": {
336                         "vimId": "12345678",
337                         "vduId": "sdfasdf",
338                         "vimFlavourId": "12"},
339                     "softwareImage": {
340                         "vimId": "12345678",
341                         "imageName": "AAA",
342                         "vimImageId": ""}},
343                 "additionalParam": ""
344              }), "200"]
345
346         mock_call_req.side_effect = [r1]
347         response = self.client.post(
348             "/v1/vnfs/lifecyclechangesnotification",
349             data=json.dumps(notify_req_data),
350             content_type='application/json')
351
352         self.assertEqual(status.HTTP_200_OK, response.status_code)
353
354         expect_resp_data = None
355         self.assertEqual(expect_resp_data, response.data)
356
357     @mock.patch.object(restcall, 'call_req')
358     def test_scale(self, mock_call_req):
359         job_info = {
360             "jobId": "801",
361             "vnfInstanceId": "101"
362         }
363         vnfm_info = {
364             "userName": "admin",
365             "vendor": "ZTE",
366             "name": "ZTE_VNFM_237_62",
367             "vimId": "516cee95-e8ca-4d26-9268-38e343c2e31e",
368             "url": "http://192.168.237.165:2324",
369             "certificateUrl": "",
370             "version": "V1.0",
371             "vnfmId": "b0797c9b-3da9-459c-b25c-3813e9d8fd70",
372             "password": "admin",
373             "type": "ztevnfmdriver",
374             "createTime": "2016-10-31 11:08:39",
375             "description": ""
376         }
377
378         ret = [0, json.JSONEncoder().encode(job_info), "202"]
379         ret_vnfm = [0, json.JSONEncoder().encode(vnfm_info), "200"]
380         mock_call_req.side_effect = [ret_vnfm, ret]
381
382         vnfd_info = {
383             "vnf_flavours": [
384                 {
385                     "flavour_id": "flavour1",
386                     "description": "",
387                     "vdu_profiles": [
388                         {
389                             "vdu_id": "vdu1Id",
390                             "instances_minimum_number": 1,
391                             "instances_maximum_number": 4,
392                             "local_affinity_antiaffinity_rule": [
393                                 {
394                                     "affinity_antiaffinity": "affinity",
395                                     "scope": "node",
396
397                                 }
398                             ]
399                         }
400                     ],
401                     "scaling_aspects": [
402                         {
403                             "id": "demo_aspect",
404                             "name": "demo_aspect",
405                             "description": "demo_aspect",
406                             "associated_group": "elementGroup1",
407                             "max_scale_level": 5
408                         }
409                     ]
410                 }
411             ],
412             "element_groups": [
413                 {
414                     "group_id": "elementGroup1",
415                     "description": "",
416                     "properties": {
417                         "name": "elementGroup1"
418                     },
419                     "members": [
420                         "gsu_vm",
421                         "pfu_vm"
422                     ]
423                 }
424             ]
425         }
426
427         scale_vnf_data = {
428             "type": "SCALE_OUT",
429             "aspectId": "demo_aspect",
430             "numberOfSteps": "3",
431             "additionalParam": {
432                 "vnfdModel": vnfd_info
433             }
434         }
435
436         response = self.client.post(
437             "/api/ztevnfmdriver/v1/100/vnfs/101/scale",
438             data=json.dumps(scale_vnf_data),
439             content_type='application/json')
440         self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code)
441         self.assertDictEqual(job_info, response.data)
442
443     @mock.patch.object(restcall, 'call_req')
444     def test_heal(self, mock_call_req):
445         job_info = {
446             "jobId": "12234455",
447             "vnfInstanceId": "10144445666"
448         }
449         vnfm_info = {
450             "userName": "admin",
451             "vendor": "ZTE",
452             "name": "ZTE_VNFM_237_62",
453             "vimId": "516cee95-e8ca-4d26-9268-38e343c2e31e",
454             "url": "http://192.168.237.165:2324",
455             "certificateUrl": "",
456             "version": "V1.0",
457             "vnfmId": "b0797c9b-3da9-459c-b25c-3813e9d8fd70",
458             "password": "admin",
459             "type": "ztevnfmdriver",
460             "createTime": "2016-10-31 11:08:39",
461             "description": ""
462         }
463
464         ret = [0, json.JSONEncoder().encode(job_info), "202"]
465         ret_vnfm = [0, json.JSONEncoder().encode(vnfm_info), "200"]
466         mock_call_req.side_effect = [ret_vnfm, ret]
467
468         heal_vnf_data = {
469             'action': 'vmReset',
470             'affectedvm': [{
471                 'flavour': {
472
473                 },
474                 'extention': '',
475                 'vmid': '804cca71-9ae9-4511-8e30-d1387718caff',
476                 'changtype': 'changed',
477                 'vduid': 'vdu_100',
478                 'vmname': 'ZTE_SSS_111_PP_2_L'
479             }],
480             'lifecycleoperation': 'operate',
481             'isgrace': 'force'
482         }
483
484         response = self.client.post("/api/ztevnfmdriver/v1/200/vnfs/201/heal", data=json.dumps(heal_vnf_data),
485                                     content_type='application/json')
486
487         self.assertEqual(status.HTTP_202_ACCEPTED, response.status_code)
488         self.assertDictEqual(job_info, response.data)
489
490     def test_health_check(self):
491         response = self.client.get("/api/ztevnfmdriver/v1/health_check")
492         self.assertEqual(status.HTTP_200_OK, response.status_code, response.content)
493         resp_data = json.loads(response.content)
494         self.assertEqual({"status": "active"}, resp_data)
495
496
497 notify_req_data = {"vnfinstanceid": "1",
498                    "nfvoid": "3",
499                    "extension": {"openo_notification": {"status": "finished",
500                                                         "affectedService": [],
501                                                         "affectedVnfc": [{"changeType": "added",
502                                                                           "computeResource": {"resourceId": "e8ccc55a-3ebb-4e46-8260-dc4a1646ef4f",
503                                                                                               "tenant": "ZTE_ONAP_PRO",
504                                                                                               "vimId": "vmware_vio",
505                                                                                               "resourceName": "ZTE_xGW_39_CDB_1"},
506                                                                           "storageResource": [],
507                                                                           "vnfcInstanceId": "17502154-c5bf-11e7-904d-fa163eee1ffe",
508                                                                           "vduType": "CDB",
509                                                                           "vduId": "VDU_S_CDB_51"},
510                                                                          {"changeType": "added",
511                                                                           "computeResource": {"resourceId": "a9dd6a73-76ee-4d07-9554-08f14c17261f",
512                                                                                               "tenant": "ZTE_ONAP_PRO",
513                                                                                               "vimId": "vmware_vio",
514                                                                                               "resourceName": "ZTE_xGW_39_SLB_1"},
515                                                                           "storageResource": [],
516                                                                           "vnfcInstanceId": "1750d540-c5bf-11e7-904d-fa163eee1ffe",
517                                                                           "vduType": "SLB",
518                                                                           "vduId": "VDU_M_SLB_42"}],
519                                                         "nfvoInstanceId": "3",
520                                                         "affectedVirtualLink": [{"changeType": "added",
521                                                                                  "virtualLinkInstanceId": "1753b60c-c5bf-11e7-904d-fa163eee1ffe",
522                                                                                  "networkResource": {"resourceId": "c55e0788-3683-48a1-b88a-a0cb5e05bd44",
523                                                                                                      "tenant": None,
524                                                                                                      "vimId": "vmware_vio",
525                                                                                                      "resourceName": "ZTE_VGW_MGT_NET39"},
526                                                                                  "virtualLinkDescId": "ZTE_VGW_MGT_NET39_virtualLink",
527                                                                                  "tenant": "ZTE_ONAP_PRO",
528                                                                                  "subnetworkResource": {"resourceId": "33c8a03d-00c9-4c57-a348-26dae462b473",
529                                                                                                         "tenant": None,
530                                                                                                         "vimId": "vmware_vio",
531                                                                                                         "resourceName": "ZTE_VGW_MGT_NET39_s"}},
532                                                                                 {"changeType": "added",
533                                                                                  "virtualLinkInstanceId": "175472a4-c5bf-11e7-904d-fa163eee1ffe",
534                                                                                  "networkResource": {"resourceId": "2d22b6e4-340b-45a8-8757-5206aa056b92",
535                                                                                                      "tenant": None,
536                                                                                                      "vimId": "vmware_vio",
537                                                                                                      "resourceName": "ZTE_VGW_SERVICE_NET39"},
538                                                                                  "virtualLinkDescId": "ZTE_VGW_SERVICE_NET39_virtualLink",
539                                                                                  "tenant": "ZTE_ONAP_PRO",
540                                                                                  "subnetworkResource": {"resourceId": "2ea2acc0-a4ed-44f8-9d31-9cdc9e3ebe62",
541                                                                                                         "tenant": None,
542                                                                                                         "vimId": "vmware_vio",
543                                                                                                         "resourceName": "ZTE_VGW_SERVICE_NET39_s"}}],
544                                                         "affectedVirtualStorage": [],
545                                                         "jobId": "",
546                                                         "affectedcapacity": {"vcp": "72",
547                                                                              "vm": "9",
548                                                                              "localStorage": "0",
549                                                                              "sharedStorage": "288",
550                                                                              "vMemory": "233472",
551                                                                              "port": "27"},
552                                                         "additionalParam": {"vmList": [{"vmName": "ZTE_xGW_39_CDB_1",
553                                                                                         "vduId": "VDU_S_CDB_51"},
554                                                                                        {"vmName": "ZTE_xGW_39_CDB_2",
555                                                                                         "vduId": "VDU_S_CDB_51"},
556                                                                                        {"vmName": "ZTE_xGW_39_SLB_1",
557                                                                                         "vduId": "VDU_M_SLB_42"},
558                                                                                        {"vmName": "ZTE_xGW_39_SLB_2",
559                                                                                         "vduId": "VDU_M_SLB_42"},
560                                                                                        {"vmName": "ZTE_xGW_39_GSU_1",
561                                                                                         "vduId": "VDU_M_GSU_22"},
562                                                                                        {"vmName": "ZTE_xGW_39_GSU_2",
563                                                                                         "vduId": "VDU_M_GSU_22"},
564                                                                                        {"vmName": "ZTE_xGW_39_MPU_1",
565                                                                                         "vduId": "VDU_M_MPU_12"},
566                                                                                        {"vmName": "ZTE_xGW_39_PFU_1",
567                                                                                         "vduId": "VDU_M_PFU_32"},
568                                                                                        {"vmName": "ZTE_xGW_39_PFU_2",
569                                                                                         "vduId": "VDU_M_PFU_32"}]},
570                                                         "nfInstanceId": "1",
571                                                         "affectedCp": [{"changeType": "added",
572                                                                         "cPInstanceId": "175767d4-c5bf-11e7-904d-fa163eee1ffe",
573                                                                         "ownertype": 3,
574                                                                         "cpdId": "CP_NO_0_CDB_ZTE_VGW_MGT_NET39",
575                                                                         "portResource": {"resourceId": "3296b6d8-ebca-4d33-98f4-68d1bc63a3d0",
576                                                                                          "tenant": "ZTE_ONAP_PRO",
577                                                                                          "vimId": "vmware_vio",
578                                                                                          "resourceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_su1"},
579                                                                         "cpInstanceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_su1",
580                                                                         "ownerid": "17502154-c5bf-11e7-904d-fa163eee1ffe",
581                                                                         "virtualLinkInstanceId": "1753b60c-c5bf-11e7-904d-fa163eee1ffe"},
582                                                                        {"changeType": "added",
583                                                                         "cPInstanceId": "1758181e-c5bf-11e7-904d-fa163eee1ffe",
584                                                                         "ownertype": 3,
585                                                                         "cpdId": "CP_NO_1_CDB_ZTE_VGW_SERVICE_NET39",
586                                                                         "portResource": {"resourceId": "5e277a18-94de-469a-a336-2c01ab46387e",
587                                                                                          "tenant": "ZTE_ONAP_PRO",
588                                                                                          "vimId": "vmware_vio",
589                                                                                          "resourceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_su2"},
590                                                                         "cpInstanceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_su2",
591                                                                         "ownerid": "17502154-c5bf-11e7-904d-fa163eee1ffe",
592                                                                         "virtualLinkInstanceId": "175472a4-c5bf-11e7-904d-fa163eee1ffe"}],
593                                                         "vnfdmodule": {"volume_storages": [],
594                                                                        "inputs": {},
595                                                                        "vdus": [{"volume_storages": [],
596                                                                                  "description": "CDB",
597                                                                                  "vdu_id": "VDU_S_CDB_51",
598                                                                                  "local_storages": ["local_disk_root_10GB",
599                                                                                                     "local_disk_ephemeral_14GB"],
600                                                                                  "nfv_compute": {"flavor_extra_specs": {"hw:cpu_policy": "dedicated",
601                                                                                                                         "hw:mem_page_size": "large",
602                                                                                                                         "hw:numa_nodes": 1,
603                                                                                                                         "hw:cpu_max_sockets": 1},
604                                                                                                  "mem_size": 8192,
605                                                                                                  "num_cpus": 2},
606                                                                                  "artifacts": [],
607                                                                                  "dependencies": [],
608                                                                                  "vls": ["ZTE_VGW_MGT_NET39_virtualLink",
609                                                                                          "ZTE_VGW_SERVICE_NET39_virtualLink"],
610                                                                                  "image_file": "image_51",
611                                                                                  "cps": ["CP_ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_su1",
612                                                                                          "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_su2"],
613                                                                                  "properties": {"key_vd": True,
614                                                                                                 "support_scaling": True,
615                                                                                                 "vdu_type": "CDB",
616                                                                                                 "name": "ZTE_xGW_39_CDB_1",
617                                                                                                 "storage_policy": "Share_Service",
618                                                                                                 "inject_network_address": True,
619                                                                                                 "is_predefined": False,
620                                                                                                 "location_info": {"vimid": "",
621                                                                                                                   "availability_zone": "",
622                                                                                                                   "vdc": "OG_OrganizationDC",
623                                                                                                                   "host": "",
624                                                                                                                   "tenant": "",
625                                                                                                                   "vapp": "xgw"},
626                                                                                                 "use_shared_vm": False,
627                                                                                                 "inject_data_list": [],
628                                                                                                 "allow_scale_updown": True,
629                                                                                                 "action": "ADD",
630                                                                                                 "watchdog": {},
631                                                                                                 "template_id": 51,
632                                                                                                 "manual_scale_select_vim": False,
633                                                                                                 "config_drive": True}},
634                                                                                 {"volume_storages": [],
635                                                                                  "description": "SLB",
636                                                                                  "vdu_id": "VDU_M_SLB_42",
637                                                                                  "local_storages": ["local_disk_root_10GB",
638                                                                                                     "local_disk_ephemeral_14GB"],
639                                                                                  "nfv_compute": {"flavor_extra_specs": {"hw:cpu_policy": "dedicated",
640                                                                                                                         "hw:mem_page_size": "large",
641                                                                                                                         "hw:numa_nodes": 1,
642                                                                                                                         "hw:cpu_max_sockets": 1},
643                                                                                                  "mem_size": 24576,
644                                                                                                  "num_cpus": 8},
645                                                                                  "artifacts": [],
646                                                                                  "dependencies": [],
647                                                                                  "vls": ["ZTE_VGW_MGT_NET39_virtualLink",
648                                                                                          "ZTE_VGW_SERVICE_NET39_virtualLink",
649                                                                                          "ZTE_NET39_virtualLink",
650                                                                                          "ZTE_VGW_GTP_NET39_virtualLink"],
651                                                                                  "image_file": "image_51",
652                                                                                  "cps": ["CP_ZTE_xGW_39_SLB_1_ZTE_VGW_MGT_NET39_su1",
653                                                                                          "CP_ZTE_xGW_39_SLB_1_ZTE_VGW_SERVICE_NET39_su2",
654                                                                                          "CP_ZTE_xGW_39_SLB_1_zte-net-subnet393",
655                                                                                          "CP_ZTE_xGW_39_SLB_1_ZTE_VGW_GTP_NET39_su4"],
656                                                                                  "properties": {"key_vd": True,
657                                                                                                 "support_scaling": False,
658                                                                                                 "vdu_type": "SLB",
659                                                                                                 "name": "ZTE_xGW_39_SLB_1",
660                                                                                                 "storage_policy": "Share_Service",
661                                                                                                 "inject_network_address": True,
662                                                                                                 "is_predefined": False,
663                                                                                                 "location_info": {"vimid": "",
664                                                                                                                   "availability_zone": "",
665                                                                                                                   "vdc": "OG_OrganizationDC",
666                                                                                                                   "host": "",
667                                                                                                                   "tenant": "",
668                                                                                                                   "vapp": "xgw"},
669                                                                                                 "use_shared_vm": False,
670                                                                                                 "inject_data_list": [],
671                                                                                                 "allow_scale_updown": True,
672                                                                                                 "action": "ADD",
673                                                                                                 "watchdog": {},
674                                                                                                 "template_id": 42,
675                                                                                                 "manual_scale_select_vim": False,
676                                                                                                 "config_drive": True}}],
677                                                                        "vcloud": [],
678                                                                        "extvirtuallink": "",
679                                                                        "server_groups": [],
680                                                                        "image_files": [{"properties": {"vendor": "zte",
681                                                                                                        "name": "ZXUN_xGW_CGSL_QCOW2_OP_V6.17.10.B17.ova",
682                                                                                                        "image_extra_specs": {},
683                                                                                                        "disk_format": "vmdk",
684                                                                                                        "file_url": "SoftwareImages/ZXUN-xGW-CGSL-QCOW2-V6.17.10.B17-image.tar.gz",
685                                                                                                        "container_type": "bare",
686                                                                                                        "version": "V6.17.10.B17.ova"},
687                                                                                         "image_file_id": "image_51",
688                                                                                         "description": "xgw image file"}],
689                                                                        "routers": [],
690                                                                        "local_storages": [{"local_storage_id": "local_disk_ephemeral_38GB",
691                                                                                            "description": "local_disk_ephemeral_38GB",
692                                                                                            "properties": {"disk_type": "ephemeral",
693                                                                                                           "size": 38}},
694                                                                                           {"local_storage_id": "local_disk_root_10GB",
695                                                                                            "description": "local_disk_root_10GB",
696                                                                                            "properties": {"disk_type": "root",
697                                                                                                           "size": 10}},
698                                                                                           {"local_storage_id": "local_disk_ephemeral_14GB",
699                                                                                            "description": "local_disk_ephemeral_14GB",
700                                                                                            "properties": {"disk_type": "ephemeral",
701                                                                                                           "size": 14}}],
702                                                                        "vnf_flavours": [],
703                                                                        "vnf_exposed": {"external_cps": [{"key_name": "ZTE_NET39_virtualLink",
704                                                                                                          "cpd_id": "CP_NO_3_PFU_ZTE_NET39"},
705                                                                                                         {"key_name": "ZTE_NET39_virtualLink1",
706                                                                                                          "cpd_id": "CP_NO_2_PFU_ZTE_NET39"},
707                                                                                                         {"key_name": "ZTE_VGW_GTP_NET39_virtualLink",
708                                                                                                          "cpd_id": "CP_NO_3_SLB_ZTE_VGW_GTP_NET39"},
709                                                                                                         {"key_name": "ZTE_NET39_virtualLink2",
710                                                                                                          "cpd_id": "CP_NO_2_SLB_ZTE_NET39"},
711                                                                                                         {"key_name": "provider-zte_virtualLink",
712                                                                                                          "cpd_id": "CP_NO_2_MPU_provider-zte"}],
713                                                                                        "forward_cps": [{"key_name": "ZTE_VGW_GTP_NET39_forwarder",
714                                                                                                         "cpd_id": "CP_NO_3_SLB_ZTE_VGW_GTP_NET39"},
715                                                                                                        {"key_name": "ZTE_NET39_forwarder1",
716                                                                                                         "cpd_id": "CP_NO_2_PFU_ZTE_NET39"},
717                                                                                                        {"key_name": "ZTE_NET39_forwarder2",
718                                                                                                         "cpd_id": "CP_NO_3_PFU_ZTE_NET39"},
719                                                                                                        {"key_name": "provider-zte_forwarder",
720                                                                                                         "cpd_id": "CP_NO_2_MPU_provider-zte"},
721                                                                                                        {"key_name": "ZTE_NET39_forwarder",
722                                                                                                         "cpd_id": "CP_NO_2_SLB_ZTE_NET39"}]},
723                                                                        "reserved_total": {"portnum": 27,
724                                                                                           "vcpunum": 72,
725                                                                                           "memorysize": 233472,
726                                                                                           "shdsize": 288,
727                                                                                           "isreserve": 0,
728                                                                                           "vmnum": 9},
729                                                                        "policies": [{"scaling": [{"description": "zte vgw vnf policy",
730                                                                                                   "policy_id": "Policy_1",
731                                                                                                   "targets": ["VDU_S_CDB_51",
732                                                                                                               "VDU_M_CDB_52",
733                                                                                                               "VDU_M_SLB_42",
734                                                                                                               "VDU_M_GSU_22",
735                                                                                                               "VDU_M_MPU_12",
736                                                                                                               "VDU_L_MPU_13",
737                                                                                                               "VDU_M_PFU_32",
738                                                                                                               "VDU_L_PFU_33"],
739                                                                                                   "properties": {"policy_file": "Policies/zte-vcn-vnf-policy.xml"}}],
740                                                                                      "healing": []}],
741                                                                        "plugins": [],
742                                                                        "services": [],
743                                                                        "vcenter": [],
744                                                                        "cps": [{"vl_id": "ZTE_VGW_MGT_NET39_virtualLink",
745                                                                                 "description": "ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_s",
746                                                                                 "vdu_id": "VDU_S_CDB_51",
747                                                                                 "properties": {"service_port_created": False,
748                                                                                                "name": "ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_s",
749                                                                                                "allowed_address_pairs": [],
750                                                                                                "bandwidth": 0,
751                                                                                                "is_virtual": False,
752                                                                                                "guest_os_mt": 1400,
753                                                                                                "vnic_type": "normal",
754                                                                                                "floating_ip_address": {},
755                                                                                                "mac_address": "",
756                                                                                                "port_security_enabled": False,
757                                                                                                "ip_address": "192.168.39.247",
758                                                                                                "order": 1,
759                                                                                                "security_groups": [],
760                                                                                                "bond": "none"},
761                                                                                 "cp_id": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_su1",
762                                                                                 "cpd_id": "CP_NO_0_CDB_ZTE_VGW_MGT_NET39"},
763                                                                                {"vl_id": "ZTE_VGW_SERVICE_NET39_virtualLink",
764                                                                                 "description": "ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_s",
765                                                                                 "vdu_id": "VDU_S_CDB_51",
766                                                                                 "properties": {"service_port_created": False,
767                                                                                                "name": "ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_s",
768                                                                                                "allowed_address_pairs": [],
769                                                                                                "bandwidth": 0,
770                                                                                                "is_virtual": False,
771                                                                                                "guest_os_mt": 1400,
772                                                                                                "vnic_type": "normal",
773                                                                                                "floating_ip_address": {},
774                                                                                                "mac_address": "",
775                                                                                                "port_security_enabled": False,
776                                                                                                "ip_address": "192.168.40.247",
777                                                                                                "order": 2,
778                                                                                                "security_groups": [],
779                                                                                                "bond": "none"},
780                                                                                 "cp_id": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_su2",
781                                                                                 "cpd_id": "CP_NO_1_CDB_ZTE_VGW_SERVICE_NET39"}],
782                                                                        "vls": [{"route_external": False,
783                                                                                 "route_id": "",
784                                                                                 "vl_id": "ZTE_VGW_MGT_NET39_virtualLink",
785                                                                                 "description": "ZTE_VGW_MGT_NET39_s",
786                                                                                 "properties": {"gateway_ip": "",
787                                                                                                "vendor": "ZTE",
788                                                                                                "name": "ZTE_VGW_MGT_NET39_s",
789                                                                                                "location_info": {"vdc": "OG_OrganizationDC",
790                                                                                                                  "vimid": 1,
791                                                                                                                  "tenant": "",
792                                                                                                                  "vapp": "xgw"},
793                                                                                                "start_ip": "",
794                                                                                                "segmentation_id": "142",
795                                                                                                "dns_nameservers": [],
796                                                                                                "vds_name": "",
797                                                                                                "mt": 1400,
798                                                                                                "is_predefined": True,
799                                                                                                "ip_version": 4,
800                                                                                                "netmask": "255.255.255.0",
801                                                                                                "end_ip": "",
802                                                                                                "host_routes": [],
803                                                                                                "vlan_transparent": False,
804                                                                                                "physical_network": "physnet1",
805                                                                                                "cidr": "192.168.39.0/24",
806                                                                                                "dhcp_enabled": False,
807                                                                                                "network_name": "ZTE_VGW_MGT_NET39",
808                                                                                                "network_type": "vlan"}},
809                                                                                {"route_external": False,
810                                                                                 "route_id": "",
811                                                                                 "vl_id": "ZTE_VGW_SERVICE_NET39_virtualLink",
812                                                                                 "description": "ZTE_VGW_SERVICE_NET39_s",
813                                                                                 "properties": {"gateway_ip": "",
814                                                                                                "vendor": "ZTE",
815                                                                                                "name": "ZTE_VGW_SERVICE_NET39_s",
816                                                                                                "location_info": {"vdc": "OG_OrganizationDC",
817                                                                                                                  "vimid": 1,
818                                                                                                                  "tenant": "",
819                                                                                                                  "vapp": "xgw"},
820                                                                                                "start_ip": "",
821                                                                                                "segmentation_id": "128",
822                                                                                                "dns_nameservers": [],
823                                                                                                "vds_name": "",
824                                                                                                "mt": 1400,
825                                                                                                "is_predefined": True,
826                                                                                                "ip_version": 4,
827                                                                                                "netmask": "255.255.255.0",
828                                                                                                "end_ip": "",
829                                                                                                "host_routes": [],
830                                                                                                "vlan_transparent": False,
831                                                                                                "physical_network": "physnet1",
832                                                                                                "cidr": "192.168.40.0/24",
833                                                                                                "dhcp_enabled": False,
834                                                                                                "network_name": "ZTE_VGW_SERVICE_NET39",
835                                                                                                "network_type": "vlan"}}],
836                                                                        "element_groups": [],
837                                                                        "metadata": {"plugin_info": "cn_plugin_3.0",
838                                                                                     "vendor": "ZTE",
839                                                                                     "is_shared": False,
840                                                                                     "adjust_vnf_capacity": True,
841                                                                                     "paas_project": "",
842                                                                                     "description": "VMware",
843                                                                                     "vnf_extend_type": "driver",
844                                                                                     "domain_type": "CN",
845                                                                                     "resview": "dync",
846                                                                                     "script_info": "",
847                                                                                     "service_category": "EPC",
848                                                                                     "version": "ZTE",
849                                                                                     "vnf_type": "SAE-GW",
850                                                                                     "cross_dc": False,
851                                                                                     "vmnumber_overquota_alarm": True,
852                                                                                     "vnfd_version": "V00000001",
853                                                                                     "id": "NFAR-ZTE-40-ZTE",
854                                                                                     "name": 40}},
855                                                         "operation": "instantiate",
856                                                         "vnfmInstanceId": "31f8934e-c785-4fa5-9205-c5f374ada982"}},
857                    "vimid": "vmware_vio",
858                    "timestamp": "20171110105828",
859                    "affectedcp": [{"changeType": "added",
860                                    "cPInstanceId": "175767d4-c5bf-11e7-904d-fa163eee1ffe",
861                                    "ownertype": 3,
862                                    "cpdId": "CP_NO_0_CDB_ZTE_VGW_MGT_NET39",
863                                    "portResource": {"resourceId": "3296b6d8-ebca-4d33-98f4-68d1bc63a3d0",
864                                                     "tenant": "ZTE_ONAP_PRO",
865                                                     "vimId": "vmware_vio",
866                                                     "resourceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_su1"},
867                                    "cpInstanceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_su1",
868                                    "ownerid": "17502154-c5bf-11e7-904d-fa163eee1ffe",
869                                    "virtualLinkInstanceId": "1753b60c-c5bf-11e7-904d-fa163eee1ffe"},
870                                   {"changeType": "added",
871                                    "cPInstanceId": "1758181e-c5bf-11e7-904d-fa163eee1ffe",
872                                    "ownertype": 3,
873                                    "cpdId": "CP_NO_1_CDB_ZTE_VGW_SERVICE_NET39",
874                                    "portResource": {"resourceId": "5e277a18-94de-469a-a336-2c01ab46387e",
875                                                     "tenant": "ZTE_ONAP_PRO",
876                                                     "vimId": "vmware_vio",
877                                                     "resourceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_su2"},
878                                    "cpInstanceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_su2",
879                                    "ownerid": "17502154-c5bf-11e7-904d-fa163eee1ffe",
880                                    "virtualLinkInstanceId": "175472a4-c5bf-11e7-904d-fa163eee1ffe"}],
881                    "vmlist": [{"VMNumber": 1,
882                                "vdutype": "CDB",
883                                "VMFlavor": "VDU_S_CDB_51",
884                                "VMIDlist": [{"VMID": "e8ccc55a-3ebb-4e46-8260-dc4a1646ef4f",
885                                              "VMName": "ZTE_xGW_39_CDB_1",
886                                              "vimid": "vmware_vio",
887                                              "tenant": "ZTE_ONAP_PRO"}]},
888                               {"VMNumber": 1,
889                                "vdutype": "SLB",
890                                "VMFlavor": "VDU_M_SLB_42",
891                                "VMIDlist": [{"VMID": "a9dd6a73-76ee-4d07-9554-08f14c17261f",
892                                              "VMName": "ZTE_xGW_39_SLB_1",
893                                              "vimid": "vmware_vio",
894                                              "tenant": "ZTE_ONAP_PRO"}]}],
895                    "EventType": 1,
896                    "vnfmid": "31f8934e-c785-4fa5-9205-c5f374ada982",
897                    "affectedvirtuallink ": [{"changeType": "added",
898                                              "virtualLinkInstanceId": "1753b60c-c5bf-11e7-904d-fa163eee1ffe",
899                                              "networkResource": {"resourceId": "c55e0788-3683-48a1-b88a-a0cb5e05bd44",
900                                                                  "tenant": None,
901                                                                  "vimId": "vmware_vio",
902                                                                  "resourceName": "ZTE_VGW_MGT_NET39"},
903                                              "virtualLinkDescId": "ZTE_VGW_MGT_NET39_virtualLink",
904                                              "tenant": "ZTE_ONAP_PRO",
905                                              "subnetworkResource": {"resourceId": "33c8a03d-00c9-4c57-a348-26dae462b473",
906                                                                     "tenant": None,
907                                                                     "vimId": "vmware_vio",
908                                                                     "resourceName": "ZTE_VGW_MGT_NET39_s"}},
909                                             {"changeType": "added",
910                                              "virtualLinkInstanceId": "175472a4-c5bf-11e7-904d-fa163eee1ffe",
911                                              "networkResource": {"resourceId": "2d22b6e4-340b-45a8-8757-5206aa056b92",
912                                                                  "tenant": None,
913                                                                  "vimId": "vmware_vio",
914                                                                  "resourceName": "ZTE_VGW_SERVICE_NET39"},
915                                              "virtualLinkDescId": "ZTE_VGW_SERVICE_NET39_virtualLink",
916                                              "tenant": "ZTE_ONAP_PRO",
917                                              "subnetworkResource": {"resourceId": "2ea2acc0-a4ed-44f8-9d31-9cdc9e3ebe62",
918                                                                     "tenant": None,
919                                                                     "vimId": "vmware_vio",
920                                                                     "resourceName": "ZTE_VGW_SERVICE_NET39_s"}}]}