summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--zte/vmanager/driver/interfaces/tests.py990
-rw-r--r--zte/vmanager/driver/interfaces/views.py31
-rw-r--r--zte/vmanager/driver/pub/config/config.py10
-rw-r--r--zte/vmanager/driver/pub/utils/restcall.py58
-rw-r--r--zte/vmanager/tox.ini2
5 files changed, 861 insertions, 230 deletions
diff --git a/zte/vmanager/driver/interfaces/tests.py b/zte/vmanager/driver/interfaces/tests.py
index 715e2d9a..a47c08ef 100644
--- a/zte/vmanager/driver/interfaces/tests.py
+++ b/zte/vmanager/driver/interfaces/tests.py
@@ -27,59 +27,77 @@ class InterfacesTest(TestCase):
def tearDown(self):
pass
- # @mock.patch.object(restcall, 'call_req_aai')
@mock.patch.object(restcall, 'call_req')
def test_instantiate_vnf_001(self, mock_call_req):
- """
- Initate_VNF
- """
- vnfm_info = {u'userName': u'admin',
- u'vendor': u'ZTE',
- u'name': u'ZTE_VNFM_237_62',
- u'vimId': u'516cee95-e8ca-4d26-9268-38e343c2e31e',
- u'url': u'http://192.168.237.165:2324',
- u'certificateUrl': u'',
- u'version': u'V1.0',
- u'vnfmId': u'b0797c9b-3da9-459c-b25c-3813e9d8fd70',
- u'password': u'admin',
- u'type': u'ztevmanagerdriver',
- u'createTime': u'2016-10-31 11:08:39',
- u'description': u''}
- vnfd_info = {u'vnfInstanceInfo': [{u'vnfInstanceId': u'59b79a9f-9e37-4f6c-acaf-5f41d9cb3f76',
- u'vnfInstanceName': u'VFW_59b79a9f-9e37-4f6c-acaf-5f41d9cb3f76'},
- {u'vnfInstanceId': u'6c5e4bd3-e8a6-42d8-a7a4-53a8ef74c6ac',
- u'vnfInstanceName': u'VFW_6c5e4bd3-e8a6-42d8-a7a4-53a8ef74c6ac'},
- {u'vnfInstanceId': u'930de5c9-8043-41df-ace8-ede2262a3713',
- u'vnfInstanceName': u'VFW_930de5c9-8043-41df-ace8-ede2262a3713'},
- {u'vnfInstanceId': u'c677a305-a7bd-4baf-9eee-c383c588bb3c',
- u'vnfInstanceName': u'VFW_c677a305-a7bd-4baf-9eee-c383c588bb3c'},
- {u'vnfInstanceId': u'e708e5c5-bdf4-436a-b928-826887806d82',
- u'vnfInstanceName': u'VFW_e708e5c5-bdf4-436a-b928-826887806d82'}],
- u'csarId': u'd852e1be-0aac-48f1-b1a4-cd825f6cdf9a',
- u'imageInfo': [
- {u'status': u'Enable', u'index': u'0',
- u'vimId': u'516cee95-e8ca-4d26-9268-38e343c2e31e',
- u'fileName': u'VFW_IMAGE_VCPE_ZTE',
- u'vimUser': u'admin',
- u'imageId': u'd2b73154-0414-466a-a1e6-51b9461b753a',
- u'tenant': u'admin'}],
- u'packageInfo': {u'usageState': u'NotInUse',
- u'onBoardState': u'onBoarded',
- u'name': u'VFW',
- u'format': u'yaml',
- u'provider': u'ZTE',
- u'vnfdProvider': u'zte',
- u'vnfdId': u'vcpe_vfw_zte_1_0',
- u'deletionPending': False,
- u'version': u'v1.0',
- u'vnfVersion': u'1.0',
- u'vnfdVersion': u'1.0.0',
- u'processState': u'normal',
- u'modifyTime': u'2016-10-31 16:21:32',
- u'downloadUri': u'http://192.168.233.226:80/',
- u'operationalState': u'Disabled',
- u'createTime': u'2016-10-31 16:21:11',
- u'size': u'12.1 MB'}}
+ vnfm_info = {
+ "userName": "admin",
+ "vendor": "ZTE",
+ "name": "ZTE_VNFM_237_62",
+ "vimId": "516cee95-e8ca-4d26-9268-38e343c2e31e",
+ "url": "http://192.168.237.165:2324",
+ "certificateUrl": "",
+ "version": "V1.0",
+ "vnfmId": "b0797c9b-3da9-459c-b25c-3813e9d8fd70",
+ "password": "admin",
+ "type": "ztevmanagerdriver",
+ "createTime": "2016-10-31 11:08:39",
+ "description": ""
+ }
+ vnfd_info = {
+ "vnfInstanceInfo": [
+ {
+ "vnfInstanceId": "59b79a9f-9e37-4f6c-acaf-5f41d9cb3f76",
+ "vnfInstanceName": "VFW_59b79a9f-9e37-4f6c-acaf-5f41d9cb3f76"
+ },
+ {
+ "vnfInstanceId": "6c5e4bd3-e8a6-42d8-a7a4-53a8ef74c6ac",
+ "vnfInstanceName": "VFW_6c5e4bd3-e8a6-42d8-a7a4-53a8ef74c6ac"
+ },
+ {
+ "vnfInstanceId": "930de5c9-8043-41df-ace8-ede2262a3713",
+ "vnfInstanceName": "VFW_930de5c9-8043-41df-ace8-ede2262a3713"
+ },
+ {
+ "vnfInstanceId": "c677a305-a7bd-4baf-9eee-c383c588bb3c",
+ "vnfInstanceName": "VFW_c677a305-a7bd-4baf-9eee-c383c588bb3c"
+ },
+ {
+ "vnfInstanceId": "e708e5c5-bdf4-436a-b928-826887806d82",
+ "vnfInstanceName": "VFW_e708e5c5-bdf4-436a-b928-826887806d82"
+ }
+ ],
+ "csarId": "d852e1be-0aac-48f1-b1a4-cd825f6cdf9a",
+ "imageInfo": [
+ {
+ "status": "Enable",
+ "index": "0",
+ "vimId": "516cee95-e8ca-4d26-9268-38e343c2e31e",
+ "fileName": "VFW_IMAGE_VCPE_ZTE",
+ "vimUser": "admin",
+ "imageId": "d2b73154-0414-466a-a1e6-51b9461b753a",
+ "tenant": "admin"
+ }
+ ],
+ "packageInfo": {
+ "usageState": "NotInUse",
+ "onBoardState": "onBoarded",
+ "name": "VFW",
+ "format": "yaml",
+ "provider": "ZTE",
+ "vnfdProvider": "zte",
+ "vnfdId": "vcpe_vfw_zte_1_0",
+ "deletionPending": False,
+ "version": "v1.0",
+ "vnfVersion": "1.0",
+ "vnfdVersion": "1.0.0",
+ "processState": "normal",
+ "modifyTime": "2016-10-3116: 21: 32",
+ "downloadUri": "http: //192.168.233.226: 80/",
+ "operationalState": "Disabled",
+ "createTime": "2016-10-3116: 21: 11",
+ "size": "12.1MB"
+ }
+ }
packageInfo = {
"size": "12.1 MB",
"usageState": "NotInUse",
@@ -104,18 +122,13 @@ class InterfacesTest(TestCase):
}
inst_response = {
- u'vnfInstanceId': u'8',
- u'jobid': u'NF-CREATE-8-b384535c-9f45-11e6-8749-fa163e91c2f9'
+ "vnfInstanceId": "8",
+ "jobid": "NF-CREATE-8-b384535c-9f45-11e6-8749-fa163e91c2f9"
}
ret = [0, json.JSONEncoder().encode(inst_response), '200']
-
r1 = [0, json.JSONEncoder().encode(vnfm_info), "200"]
-
r2 = [0, json.JSONEncoder().encode(vnfd_info), "200"]
-
r3 = [0, json.JSONEncoder().encode(packageInfo), "200"]
-
- # mock_call_req_aai.side_effect =[r1]
mock_call_req.side_effect = [r1, r2, r3, ret]
req_data = {
@@ -141,12 +154,8 @@ class InterfacesTest(TestCase):
expect_resp_data = {"jobid": "NF-CREATE-8-b384535c-9f45-11e6-8749-fa163e91c2f9", "vnfInstanceId": "8"}
self.assertEqual(expect_resp_data, response.data)
- # @mock.patch.object(restcall, 'call_req_aai')
@mock.patch.object(restcall, 'call_req')
def test_terminate_vnf__002(self, mock_call_req):
- """
- Terminate_VNF
- """
r1 = [0, json.JSONEncoder().encode({
"vnfmId": "19ecbb3a-3242-4fa3-9926-8dfb7ddc29ee",
"name": "g_vnfm",
@@ -162,7 +171,6 @@ class InterfacesTest(TestCase):
"createTime": "2016-07-06 15:33:18"}), "200"]
r2 = [0, json.JSONEncoder().encode({"vnfInstanceId": "1", "JobId": "1"}), "200"]
- # mock_call_req_aai.side_effect = [r1]
mock_call_req.side_effect = [r1, r2]
response = self.client.post("/api/ztevmanagerdriver/v1/ztevnfmid/vnfs/vbras_innstance_id/terminate")
@@ -171,12 +179,8 @@ class InterfacesTest(TestCase):
expect_resp_data = {"jobid": "1", "vnfInstanceId": "1"}
self.assertEqual(expect_resp_data, response.data)
- # @mock.patch.object(restcall, 'call_req_aai')
@mock.patch.object(restcall, 'call_req')
def test_query_vnf_003(self, mock_call_req):
- """
- Query_VNF
- """
r1 = [0, json.JSONEncoder().encode({
"vnfmId": "19ecbb3a-3242-4fa3-9926-8dfb7ddc29ee",
"name": "g_vnfm",
@@ -192,7 +196,6 @@ class InterfacesTest(TestCase):
"createTime": "2016-07-06 15:33:18"}), "200"]
r2 = [0, json.JSONEncoder().encode({"vnfinstancestatus": "1"}), "200"]
- # mock_call_req_aai.side_effect = [r1]
mock_call_req.side_effect = [r1, r2]
response = self.client.get("/api/ztevmanagerdriver/v1/ztevnfmid/vnfs/vbras_innstance_id")
@@ -202,24 +205,22 @@ class InterfacesTest(TestCase):
expect_resp_data = {"vnfInfo": {"vnfStatus": "1"}}
self.assertEqual(expect_resp_data, response.data)
- # @mock.patch.object(restcall, 'call_req_aai')
@mock.patch.object(restcall, 'call_req')
def test_operation_status_004(self, mock_call_req):
- """
- Operation_status
- """
- vnfm_info = {u'userName': u'admin',
- u'vendor': u'ZTE',
- u'name': u'ZTE_VNFM_237_62',
- u'vimId': u'516cee95-e8ca-4d26-9268-38e343c2e31e',
- u'url': u'http://192.168.237.165:2324',
- u'certificateUrl': u'',
- u'version': u'V1.0',
- u'vnfmId': u'b0797c9b-3da9-459c-b25c-3813e9d8fd70',
- u'password': u'admin',
- u'type': u'ztevmanagerdriver',
- u'createTime': u'2016-10-31 11:08:39',
- u'description': u''}
+ vnfm_info = {
+ "userName": "admin",
+ "vendor": "ZTE",
+ "name": "ZTE_VNFM_237_62",
+ "vimId": "516cee95-e8ca-4d26-9268-38e343c2e31e",
+ "url": "http://192.168.237.165:2324",
+ "certificateUrl": "",
+ "version": "V1.0",
+ "vnfmId": "b0797c9b-3da9-459c-b25c-3813e9d8fd70",
+ "password": "admin",
+ "type": "ztevmanagerdriver",
+ "createTime": "2016-10-31 11:08:39",
+ "description": ""
+ }
resp_body = {
"responsedescriptor": {
"status": "processing",
@@ -241,7 +242,6 @@ class InterfacesTest(TestCase):
}
r1 = [0, json.JSONEncoder().encode(vnfm_info), '200']
r2 = [0, json.JSONEncoder().encode(resp_body), '200']
- # mock_call_req_aai.side_effect = [r1]
mock_call_req.side_effect = [r1, r2]
response = self.client.get("/api/ztevmanagerdriver/v1/{vnfmid}/jobs/{jobid}?responseId={responseId}".format(
vnfmid=vnfm_info["vnfmId"],
@@ -256,12 +256,15 @@ class InterfacesTest(TestCase):
@mock.patch.object(restcall, 'call_req')
def test_grantvnf_005(self, mock_call_req):
- """
- Grant_VNF
- """
- ret = [0,
- '{"vim":{"accessinfo":{"tenant":"admin"},"vimid":"516cee95-e8ca-4d26-9268-38e343c2e31e"}}',
- '201']
+ grant_data = {
+ "vim": {
+ "accessinfo": {
+ "tenant": "admin"
+ },
+ "vimid": "516cee95-e8ca-4d26-9268-38e343c2e31e"
+ }
+ }
+ ret = [0, json.JSONEncoder().encode(grant_data), '201']
req_data = {
"vnfmid": "13232222",
@@ -298,9 +301,6 @@ class InterfacesTest(TestCase):
@mock.patch.object(restcall, 'call_req')
def test_notify_006(self, mock_call_req):
- """
- Notification
- """
r1 = [0, json.JSONEncoder().encode(
{"vim":
{
@@ -333,52 +333,35 @@ class InterfacesTest(TestCase):
"additionalParam": ""
}), "200"]
- req_data = {
- "nfvoid": "1",
- "vnfmid": "876543211",
- "vimid": "6543211",
- "timestamp": "1234567890",
- "vnfinstanceid": "1",
- "eventtype": "0",
- "vmlist":
- [
- {
- "vmflavor": "SMP",
- "vmnumber": "3",
- "vmidlist ": ["vmuuid"]},
- {
- "vmflavor": "CMP",
- "vmnumber": "3",
- "vmidlist ": ["vmuuid"]}]}
mock_call_req.side_effect = [r1]
response = self.client.post("/api/ztevmanagerdriver/v1/vnfs/lifecyclechangesnotification",
- data=json.dumps(req_data), content_type='application/json')
+ data=json.dumps(notify_req_data), content_type='application/json')
self.assertEqual(str(status.HTTP_200_OK), response.status_code)
expect_resp_data = None
self.assertEqual(expect_resp_data, response.data)
- # @mock.patch.object(restcall, 'call_req_aai')
@mock.patch.object(restcall, 'call_req')
def test_scale(self, mock_call_req):
job_info = {"jobid": "801", "nfInstanceId": "101"}
- vnfm_info = {u'userName': u'admin',
- u'vendor': u'ZTE',
- u'name': u'ZTE_VNFM_237_62',
- u'vimId': u'516cee95-e8ca-4d26-9268-38e343c2e31e',
- u'url': u'http://192.168.237.165:2324',
- u'certificateUrl': u'',
- u'version': u'V1.0',
- u'vnfmId': u'b0797c9b-3da9-459c-b25c-3813e9d8fd70',
- u'password': u'admin',
- u'type': u'ztevmanagerdriver',
- u'createTime': u'2016-10-31 11:08:39',
- u'description': u''}
+ vnfm_info = {
+ "userName": "admin",
+ "vendor": "ZTE",
+ "name": "ZTE_VNFM_237_62",
+ "vimId": "516cee95-e8ca-4d26-9268-38e343c2e31e",
+ "url": "http://192.168.237.165:2324",
+ "certificateUrl": "",
+ "version": "V1.0",
+ "vnfmId": "b0797c9b-3da9-459c-b25c-3813e9d8fd70",
+ "password": "admin",
+ "type": "ztevmanagerdriver",
+ "createTime": "2016-10-31 11:08:39",
+ "description": ""
+ }
ret = [0, json.JSONEncoder().encode(job_info), "202"]
ret_vnfm = [0, json.JSONEncoder().encode(vnfm_info), "200"]
- # mock_call_req_aai.side_effect = [ret_vnfm]
mock_call_req.side_effect = [ret_vnfm, ret]
vnfd_info = {
@@ -440,26 +423,29 @@ class InterfacesTest(TestCase):
self.assertEqual(str(status.HTTP_202_ACCEPTED), response.status_code)
self.assertDictEqual(job_info, response.data)
- # @mock.patch.object(restcall, 'call_req_aai')
@mock.patch.object(restcall, 'call_req')
def test_heal(self, mock_call_req):
- job_info = {"jobid": "12234455", "nfInstanceId": "10144445666"}
- vnfm_info = {u'userName': u'admin',
- u'vendor': u'ZTE',
- u'name': u'ZTE_VNFM_237_62',
- u'vimId': u'516cee95-e8ca-4d26-9268-38e343c2e31e',
- u'url': u'http://192.168.237.165:2324',
- u'certificateUrl': u'',
- u'version': u'V1.0',
- u'vnfmId': u'b0797c9b-3da9-459c-b25c-3813e9d8fd70',
- u'password': u'admin',
- u'type': u'ztevmanagerdriver',
- u'createTime': u'2016-10-31 11:08:39',
- u'description': u''}
+ job_info = {
+ "jobid": "12234455",
+ "nfInstanceId": "10144445666"
+ }
+ vnfm_info = {
+ "userName": "admin",
+ "vendor": "ZTE",
+ "name": "ZTE_VNFM_237_62",
+ "vimId": "516cee95-e8ca-4d26-9268-38e343c2e31e",
+ "url": "http://192.168.237.165:2324",
+ "certificateUrl": "",
+ "version": "V1.0",
+ "vnfmId": "b0797c9b-3da9-459c-b25c-3813e9d8fd70",
+ "password": "admin",
+ "type": "ztevmanagerdriver",
+ "createTime": "2016-10-31 11:08:39",
+ "description": ""
+ }
ret = [0, json.JSONEncoder().encode(job_info), "202"]
ret_vnfm = [0, json.JSONEncoder().encode(vnfm_info), "200"]
- # mock_call_req_aai.side_effect = [ret_vnfm]
mock_call_req.side_effect = [ret_vnfm, ret]
heal_vnf_data = {
@@ -483,3 +469,725 @@ class InterfacesTest(TestCase):
self.assertEqual(str(status.HTTP_202_ACCEPTED), response.status_code)
self.assertDictEqual(job_info, response.data)
+
+
+notify_req_data = {
+ "vnfinstanceid": "1",
+ "nfvoid": "3",
+ "extension": {
+ "openo_notification": {
+ "status": "finished",
+ "affectedService": [
+
+ ],
+ "affectedVnfc": [
+ {
+ "changeType": "added",
+ "computeResource": {
+ "resourceId": "e8ccc55a-3ebb-4e46-8260-dc4a1646ef4f",
+ "tenant": "ZTE_ONAP_PRO",
+ "vimId": "vmware_vio",
+ "resourceName": "ZTE_xGW_39_CDB_1"
+ },
+ "storageResource": [
+
+ ],
+ "vnfcInstanceId": "17502154-c5bf-11e7-904d-fa163eee1ffe",
+ "vduType": "CDB",
+ "vduId": "VDU_S_CDB_51"
+ },
+ {
+ "changeType": "added",
+ "computeResource": {
+ "resourceId": "a9dd6a73-76ee-4d07-9554-08f14c17261f",
+ "tenant": "ZTE_ONAP_PRO",
+ "vimId": "vmware_vio",
+ "resourceName": "ZTE_xGW_39_SLB_1"
+ },
+ "storageResource": [
+
+ ],
+ "vnfcInstanceId": "1750d540-c5bf-11e7-904d-fa163eee1ffe",
+ "vduType": "SLB",
+ "vduId": "VDU_M_SLB_42"
+ }
+ ],
+ "nfvoInstanceId": "3",
+ "affectedVirtualLink": [
+ {
+ "changeType": "added",
+ "virtualLinkInstanceId": "1753b60c-c5bf-11e7-904d-fa163eee1ffe",
+ "networkResource": {
+ "resourceId": "c55e0788-3683-48a1-b88a-a0cb5e05bd44",
+ "tenant": None,
+ "vimId": "vmware_vio",
+ "resourceName": "ZTE_VGW_MGT_NET39"
+ },
+ "virtualLinkDescId": "ZTE_VGW_MGT_NET39_virtualLink",
+ "tenant": "ZTE_ONAP_PRO",
+ "subnetworkResource": {
+ "resourceId": "33c8a03d-00c9-4c57-a348-26dae462b473",
+ "tenant": None,
+ "vimId": "vmware_vio",
+ "resourceName": "ZTE_VGW_MGT_NET39_s"
+ }
+ },
+ {
+ "changeType": "added",
+ "virtualLinkInstanceId": "175472a4-c5bf-11e7-904d-fa163eee1ffe",
+ "networkResource": {
+ "resourceId": "2d22b6e4-340b-45a8-8757-5206aa056b92",
+ "tenant": None,
+ "vimId": "vmware_vio",
+ "resourceName": "ZTE_VGW_SERVICE_NET39"
+ },
+ "virtualLinkDescId": "ZTE_VGW_SERVICE_NET39_virtualLink",
+ "tenant": "ZTE_ONAP_PRO",
+ "subnetworkResource": {
+ "resourceId": "2ea2acc0-a4ed-44f8-9d31-9cdc9e3ebe62",
+ "tenant": None,
+ "vimId": "vmware_vio",
+ "resourceName": "ZTE_VGW_SERVICE_NET39_s"
+ }
+ }
+ ],
+ "affectedVirtualStorage": [
+
+ ],
+ "jobId": "",
+ "affectedcapacity": {
+ "vcp": "72",
+ "vm": "9",
+ "localStorage": "0",
+ "sharedStorage": "288",
+ "vMemory": "233472",
+ "port": "27"
+ },
+ "additionalParam": {
+ "vmList": [
+ {
+ "vmName": "ZTE_xGW_39_CDB_1",
+ "vduId": "VDU_S_CDB_51"
+ },
+ {
+ "vmName": "ZTE_xGW_39_CDB_2",
+ "vduId": "VDU_S_CDB_51"
+ },
+ {
+ "vmName": "ZTE_xGW_39_SLB_1",
+ "vduId": "VDU_M_SLB_42"
+ },
+ {
+ "vmName": "ZTE_xGW_39_SLB_2",
+ "vduId": "VDU_M_SLB_42"
+ },
+ {
+ "vmName": "ZTE_xGW_39_GSU_1",
+ "vduId": "VDU_M_GSU_22"
+ },
+ {
+ "vmName": "ZTE_xGW_39_GSU_2",
+ "vduId": "VDU_M_GSU_22"
+ },
+ {
+ "vmName": "ZTE_xGW_39_MPU_1",
+ "vduId": "VDU_M_MPU_12"
+ },
+ {
+ "vmName": "ZTE_xGW_39_PFU_1",
+ "vduId": "VDU_M_PFU_32"
+ },
+ {
+ "vmName": "ZTE_xGW_39_PFU_2",
+ "vduId": "VDU_M_PFU_32"
+ }
+ ]
+ },
+ "nfInstanceId": "1",
+ "affectedCp": [
+ {
+ "changeType": "added",
+ "cPInstanceId": "175767d4-c5bf-11e7-904d-fa163eee1ffe",
+ "ownertype": 3,
+ "cpdId": "CP_NO_0_CDB_ZTE_VGW_MGT_NET39",
+ "portResource": {
+ "resourceId": "3296b6d8-ebca-4d33-98f4-68d1bc63a3d0",
+ "tenant": "ZTE_ONAP_PRO",
+ "vimId": "vmware_vio",
+ "resourceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_su1"
+ },
+ "cpInstanceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_su1",
+ "ownerid": "17502154-c5bf-11e7-904d-fa163eee1ffe",
+ "virtualLinkInstanceId": "1753b60c-c5bf-11e7-904d-fa163eee1ffe"
+ },
+ {
+ "changeType": "added",
+ "cPInstanceId": "1758181e-c5bf-11e7-904d-fa163eee1ffe",
+ "ownertype": 3,
+ "cpdId": "CP_NO_1_CDB_ZTE_VGW_SERVICE_NET39",
+ "portResource": {
+ "resourceId": "5e277a18-94de-469a-a336-2c01ab46387e",
+ "tenant": "ZTE_ONAP_PRO",
+ "vimId": "vmware_vio",
+ "resourceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_su2"
+ },
+ "cpInstanceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_su2",
+ "ownerid": "17502154-c5bf-11e7-904d-fa163eee1ffe",
+ "virtualLinkInstanceId": "175472a4-c5bf-11e7-904d-fa163eee1ffe"
+ }
+ ],
+ "vnfdmodule": {
+ "volume_storages": [
+
+ ],
+ "inputs": {
+
+ },
+ "vdus": [
+ {
+ "volume_storages": [
+
+ ],
+ "description": "CDB",
+ "vdu_id": "VDU_S_CDB_51",
+ "local_storages": [
+ "local_disk_root_10GB",
+ "local_disk_ephemeral_14GB"
+ ],
+ "nfv_compute": {
+ "flavor_extra_specs": {
+ "hw:cpu_policy": "dedicated",
+ "hw:mem_page_size": "large",
+ "hw:numa_nodes": 1,
+ "hw:cpu_max_sockets": 1
+ },
+ "mem_size": 8192,
+ "num_cpus": 2
+ },
+ "artifacts": [
+
+ ],
+ "dependencies": [
+
+ ],
+ "vls": [
+ "ZTE_VGW_MGT_NET39_virtualLink",
+ "ZTE_VGW_SERVICE_NET39_virtualLink"
+ ],
+ "image_file": "image_51",
+ "cps": [
+ "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_su1",
+ "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_su2"
+ ],
+ "properties": {
+ "key_vd": True,
+ "support_scaling": True,
+ "vdu_type": "CDB",
+ "name": "ZTE_xGW_39_CDB_1",
+ "storage_policy": "Share_Service",
+ "inject_network_address": True,
+ "is_predefined": False,
+ "location_info": {
+ "vimid": "",
+ "availability_zone": "",
+ "vdc": "OG_OrganizationDC",
+ "host": "",
+ "tenant": "",
+ "vapp": "xgw"
+ },
+ "use_shared_vm": False,
+ "inject_data_list": [
+
+ ],
+ "allow_scale_updown": True,
+ "action": "ADD",
+ "watchdog": {
+
+ },
+ "template_id": 51,
+ "manual_scale_select_vim": False,
+ "config_drive": True
+ }
+ },
+ {
+ "volume_storages": [
+
+ ],
+ "description": "SLB",
+ "vdu_id": "VDU_M_SLB_42",
+ "local_storages": [
+ "local_disk_root_10GB",
+ "local_disk_ephemeral_14GB"
+ ],
+ "nfv_compute": {
+ "flavor_extra_specs": {
+ "hw:cpu_policy": "dedicated",
+ "hw:mem_page_size": "large",
+ "hw:numa_nodes": 1,
+ "hw:cpu_max_sockets": 1
+ },
+ "mem_size": 24576,
+ "num_cpus": 8
+ },
+ "artifacts": [
+
+ ],
+ "dependencies": [
+
+ ],
+ "vls": [
+ "ZTE_VGW_MGT_NET39_virtualLink",
+ "ZTE_VGW_SERVICE_NET39_virtualLink",
+ "ZTE_NET39_virtualLink",
+ "ZTE_VGW_GTP_NET39_virtualLink"
+ ],
+ "image_file": "image_51",
+ "cps": [
+ "CP_ZTE_xGW_39_SLB_1_ZTE_VGW_MGT_NET39_su1",
+ "CP_ZTE_xGW_39_SLB_1_ZTE_VGW_SERVICE_NET39_su2",
+ "CP_ZTE_xGW_39_SLB_1_zte-net-subnet393",
+ "CP_ZTE_xGW_39_SLB_1_ZTE_VGW_GTP_NET39_su4"
+ ],
+ "properties": {
+ "key_vd": True,
+ "support_scaling": False,
+ "vdu_type": "SLB",
+ "name": "ZTE_xGW_39_SLB_1",
+ "storage_policy": "Share_Service",
+ "inject_network_address": True,
+ "is_predefined": False,
+ "location_info": {
+ "vimid": "",
+ "availability_zone": "",
+ "vdc": "OG_OrganizationDC",
+ "host": "",
+ "tenant": "",
+ "vapp": "xgw"
+ },
+ "use_shared_vm": False,
+ "inject_data_list": [
+
+ ],
+ "allow_scale_updown": True,
+ "action": "ADD",
+ "watchdog": {
+
+ },
+ "template_id": 42,
+ "manual_scale_select_vim": False,
+ "config_drive": True
+ }
+ }
+ ],
+ "vcloud": [
+
+ ],
+ "extvirtuallink": "",
+ "server_groups": [
+
+ ],
+ "image_files": [
+ {
+ "properties": {
+ "vendor": "zte",
+ "name": "ZXUN_xGW_CGSL_QCOW2_OP_V6.17.10.B17.ova",
+ "image_extra_specs": {
+
+ },
+ "disk_format": "vmdk",
+ "file_url": "SoftwareImages/ZXUN-xGW-CGSL-QCOW2-V6.17.10.B17-image.tar.gz",
+ "container_type": "bare",
+ "version": "V6.17.10.B17.ova"
+ },
+ "image_file_id": "image_51",
+ "description": "xgw image file"
+ }
+ ],
+ "routers": [
+
+ ],
+ "local_storages": [
+ {
+ "local_storage_id": "local_disk_ephemeral_38GB",
+ "description": "local_disk_ephemeral_38GB",
+ "properties": {
+ "disk_type": "ephemeral",
+ "size": 38
+ }
+ },
+ {
+ "local_storage_id": "local_disk_root_10GB",
+ "description": "local_disk_root_10GB",
+ "properties": {
+ "disk_type": "root",
+ "size": 10
+ }
+ },
+ {
+ "local_storage_id": "local_disk_ephemeral_14GB",
+ "description": "local_disk_ephemeral_14GB",
+ "properties": {
+ "disk_type": "ephemeral",
+ "size": 14
+ }
+ }
+ ],
+ "vnf_flavours": [
+
+ ],
+ "vnf_exposed": {
+ "external_cps": [
+ {
+ "key_name": "ZTE_NET39_virtualLink",
+ "cpd_id": "CP_NO_3_PFU_ZTE_NET39"
+ },
+ {
+ "key_name": "ZTE_NET39_virtualLink1",
+ "cpd_id": "CP_NO_2_PFU_ZTE_NET39"
+ },
+ {
+ "key_name": "ZTE_VGW_GTP_NET39_virtualLink",
+ "cpd_id": "CP_NO_3_SLB_ZTE_VGW_GTP_NET39"
+ },
+ {
+ "key_name": "ZTE_NET39_virtualLink2",
+ "cpd_id": "CP_NO_2_SLB_ZTE_NET39"
+ },
+ {
+ "key_name": "provider-zte_virtualLink",
+ "cpd_id": "CP_NO_2_MPU_provider-zte"
+ }
+ ],
+ "forward_cps": [
+ {
+ "key_name": "ZTE_VGW_GTP_NET39_forwarder",
+ "cpd_id": "CP_NO_3_SLB_ZTE_VGW_GTP_NET39"
+ },
+ {
+ "key_name": "ZTE_NET39_forwarder1",
+ "cpd_id": "CP_NO_2_PFU_ZTE_NET39"
+ },
+ {
+ "key_name": "ZTE_NET39_forwarder2",
+ "cpd_id": "CP_NO_3_PFU_ZTE_NET39"
+ },
+ {
+ "key_name": "provider-zte_forwarder",
+ "cpd_id": "CP_NO_2_MPU_provider-zte"
+ },
+ {
+ "key_name": "ZTE_NET39_forwarder",
+ "cpd_id": "CP_NO_2_SLB_ZTE_NET39"
+ }
+ ]
+ },
+ "reserved_total": {
+ "portnum": 27,
+ "vcpunum": 72,
+ "memorysize": 233472,
+ "shdsize": 288,
+ "isreserve": 0,
+ "vmnum": 9
+ },
+ "policies": [
+ {
+ "scaling": [
+ {
+ "description": "zte vgw vnf policy",
+ "policy_id": "Policy_1",
+ "targets": [
+ "VDU_S_CDB_51",
+ "VDU_M_CDB_52",
+ "VDU_M_SLB_42",
+ "VDU_M_GSU_22",
+ "VDU_M_MPU_12",
+ "VDU_L_MPU_13",
+ "VDU_M_PFU_32",
+ "VDU_L_PFU_33"
+ ],
+ "properties": {
+ "policy_file": "Policies/zte-vcn-vnf-policy.xml"
+ }
+ }
+ ],
+ "healing": [
+
+ ]
+ }
+ ],
+ "plugins": [
+
+ ],
+ "services": [
+
+ ],
+ "vcenter": [
+
+ ],
+ "cps": [
+ {
+ "vl_id": "ZTE_VGW_MGT_NET39_virtualLink",
+ "description": "ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_s",
+ "vdu_id": "VDU_S_CDB_51",
+ "properties": {
+ "service_port_created": False,
+ "name": "ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_s",
+ "allowed_address_pairs": [
+
+ ],
+ "bandwidth": 0,
+ "is_virtual": False,
+ "guest_os_mt": 1400,
+ "vnic_type": "normal",
+ "floating_ip_address": {
+
+ },
+ "mac_address": "",
+ "port_security_enabled": False,
+ "ip_address": "192.168.39.247",
+ "order": 1,
+ "security_groups": [
+
+ ],
+ "bond": "none"
+ },
+ "cp_id": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_su1",
+ "cpd_id": "CP_NO_0_CDB_ZTE_VGW_MGT_NET39"
+ },
+ {
+ "vl_id": "ZTE_VGW_SERVICE_NET39_virtualLink",
+ "description": "ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_s",
+ "vdu_id": "VDU_S_CDB_51",
+ "properties": {
+ "service_port_created": False,
+ "name": "ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_s",
+ "allowed_address_pairs": [
+
+ ],
+ "bandwidth": 0,
+ "is_virtual": False,
+ "guest_os_mt": 1400,
+ "vnic_type": "normal",
+ "floating_ip_address": {
+
+ },
+ "mac_address": "",
+ "port_security_enabled": False,
+ "ip_address": "192.168.40.247",
+ "order": 2,
+ "security_groups": [
+
+ ],
+ "bond": "none"
+ },
+ "cp_id": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_su2",
+ "cpd_id": "CP_NO_1_CDB_ZTE_VGW_SERVICE_NET39"
+ }
+ ],
+ "vls": [
+ {
+ "route_external": False,
+ "route_id": "",
+ "vl_id": "ZTE_VGW_MGT_NET39_virtualLink",
+ "description": "ZTE_VGW_MGT_NET39_s",
+ "properties": {
+ "gateway_ip": "",
+ "vendor": "ZTE",
+ "name": "ZTE_VGW_MGT_NET39_s",
+ "location_info": {
+ "vdc": "OG_OrganizationDC",
+ "vimid": 1,
+ "tenant": "",
+ "vapp": "xgw"
+ },
+ "start_ip": "",
+ "segmentation_id": "142",
+ "dns_nameservers": [
+
+ ],
+ "vds_name": "",
+ "mt": 1400,
+ "is_predefined": True,
+ "ip_version": 4,
+ "netmask": "255.255.255.0",
+ "end_ip": "",
+ "host_routes": [
+
+ ],
+ "vlan_transparent": False,
+ "physical_network": "physnet1",
+ "cidr": "192.168.39.0/24",
+ "dhcp_enabled": False,
+ "network_name": "ZTE_VGW_MGT_NET39",
+ "network_type": "vlan"
+ }
+ },
+ {
+ "route_external": False,
+ "route_id": "",
+ "vl_id": "ZTE_VGW_SERVICE_NET39_virtualLink",
+ "description": "ZTE_VGW_SERVICE_NET39_s",
+ "properties": {
+ "gateway_ip": "",
+ "vendor": "ZTE",
+ "name": "ZTE_VGW_SERVICE_NET39_s",
+ "location_info": {
+ "vdc": "OG_OrganizationDC",
+ "vimid": 1,
+ "tenant": "",
+ "vapp": "xgw"
+ },
+ "start_ip": "",
+ "segmentation_id": "128",
+ "dns_nameservers": [
+
+ ],
+ "vds_name": "",
+ "mt": 1400,
+ "is_predefined": True,
+ "ip_version": 4,
+ "netmask": "255.255.255.0",
+ "end_ip": "",
+ "host_routes": [
+
+ ],
+ "vlan_transparent": False,
+ "physical_network": "physnet1",
+ "cidr": "192.168.40.0/24",
+ "dhcp_enabled": False,
+ "network_name": "ZTE_VGW_SERVICE_NET39",
+ "network_type": "vlan"
+ }
+ }
+ ],
+ "element_groups": [
+
+ ],
+ "metadata": {
+ "plugin_info": "cn_plugin_3.0",
+ "vendor": "ZTE",
+ "is_shared": False,
+ "adjust_vnf_capacity": True,
+ "paas_project": "",
+ "description": "VMware",
+ "vnf_extend_type": "driver",
+ "domain_type": "CN",
+ "resview": "dync",
+ "script_info": "",
+ "service_category": "EPC",
+ "version": "ZTE",
+ "vnf_type": "SAE-GW",
+ "cross_dc": False,
+ "vmnumber_overquota_alarm": True,
+ "vnfd_version": "V00000001",
+ "id": "NFAR-ZTE-40-ZTE",
+ "name": 40
+ }
+ },
+ "operation": "instantiate",
+ "vnfmInstanceId": "31f8934e-c785-4fa5-9205-c5f374ada982"
+ }
+ },
+ "vimid": "vmware_vio",
+ "timestamp": "20171110105828",
+ "affectedcp": [
+ {
+ "changeType": "added",
+ "cPInstanceId": "175767d4-c5bf-11e7-904d-fa163eee1ffe",
+ "ownertype": 3,
+ "cpdId": "CP_NO_0_CDB_ZTE_VGW_MGT_NET39",
+ "portResource": {
+ "resourceId": "3296b6d8-ebca-4d33-98f4-68d1bc63a3d0",
+ "tenant": "ZTE_ONAP_PRO",
+ "vimId": "vmware_vio",
+ "resourceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_su1"
+ },
+ "cpInstanceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_MGT_NET39_su1",
+ "ownerid": "17502154-c5bf-11e7-904d-fa163eee1ffe",
+ "virtualLinkInstanceId": "1753b60c-c5bf-11e7-904d-fa163eee1ffe"
+ },
+ {
+ "changeType": "added",
+ "cPInstanceId": "1758181e-c5bf-11e7-904d-fa163eee1ffe",
+ "ownertype": 3,
+ "cpdId": "CP_NO_1_CDB_ZTE_VGW_SERVICE_NET39",
+ "portResource": {
+ "resourceId": "5e277a18-94de-469a-a336-2c01ab46387e",
+ "tenant": "ZTE_ONAP_PRO",
+ "vimId": "vmware_vio",
+ "resourceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_su2"
+ },
+ "cpInstanceName": "CP_ZTE_xGW_39_CDB_1_ZTE_VGW_SERVICE_NET39_su2",
+ "ownerid": "17502154-c5bf-11e7-904d-fa163eee1ffe",
+ "virtualLinkInstanceId": "175472a4-c5bf-11e7-904d-fa163eee1ffe"
+ }
+ ],
+ "vmlist": [
+ {
+ "VMNumber": 1,
+ "vdutype": "CDB",
+ "VMFlavor": "VDU_S_CDB_51",
+ "VMIDlist": [
+ {
+ "VMID": "e8ccc55a-3ebb-4e46-8260-dc4a1646ef4f",
+ "VMName": "ZTE_xGW_39_CDB_1",
+ "vimid": "vmware_vio",
+ "tenant": "ZTE_ONAP_PRO"
+ }
+ ]
+ },
+ {
+ "VMNumber": 1,
+ "vdutype": "SLB",
+ "VMFlavor": "VDU_M_SLB_42",
+ "VMIDlist": [
+ {
+ "VMID": "a9dd6a73-76ee-4d07-9554-08f14c17261f",
+ "VMName": "ZTE_xGW_39_SLB_1",
+ "vimid": "vmware_vio",
+ "tenant": "ZTE_ONAP_PRO"
+ }
+ ]
+ }
+ ],
+ "EventType": 1,
+ "vnfmid": "31f8934e-c785-4fa5-9205-c5f374ada982",
+ "affectedvirtuallink ": [
+ {
+ "changeType": "added",
+ "virtualLinkInstanceId": "1753b60c-c5bf-11e7-904d-fa163eee1ffe",
+ "networkResource": {
+ "resourceId": "c55e0788-3683-48a1-b88a-a0cb5e05bd44",
+ "tenant": None,
+ "vimId": "vmware_vio",
+ "resourceName": "ZTE_VGW_MGT_NET39"
+ },
+ "virtualLinkDescId": "ZTE_VGW_MGT_NET39_virtualLink",
+ "tenant": "ZTE_ONAP_PRO",
+ "subnetworkResource": {
+ "resourceId": "33c8a03d-00c9-4c57-a348-26dae462b473",
+ "tenant": None,
+ "vimId": "vmware_vio",
+ "resourceName": "ZTE_VGW_MGT_NET39_s"
+ }
+ },
+ {
+ "changeType": "added",
+ "virtualLinkInstanceId": "175472a4-c5bf-11e7-904d-fa163eee1ffe",
+ "networkResource": {
+ "resourceId": "2d22b6e4-340b-45a8-8757-5206aa056b92",
+ "tenant": None,
+ "vimId": "vmware_vio",
+ "resourceName": "ZTE_VGW_SERVICE_NET39"
+ },
+ "virtualLinkDescId": "ZTE_VGW_SERVICE_NET39_virtualLink",
+ "tenant": "ZTE_ONAP_PRO",
+ "subnetworkResource": {
+ "resourceId": "2ea2acc0-a4ed-44f8-9d31-9cdc9e3ebe62",
+ "tenant": None,
+ "vimId": "vmware_vio",
+ "resourceName": "ZTE_VGW_SERVICE_NET39_s"
+ }
+ }
+ ]
+}
diff --git a/zte/vmanager/driver/interfaces/views.py b/zte/vmanager/driver/interfaces/views.py
index 6626c1d3..21432b2f 100644
--- a/zte/vmanager/driver/interfaces/views.py
+++ b/zte/vmanager/driver/interfaces/views.py
@@ -22,7 +22,7 @@ from rest_framework.decorators import api_view
from rest_framework.response import Response
from driver.pub.utils import restcall
-from driver.pub.utils.restcall import req_by_msb, call_aai
+from driver.pub.utils.restcall import req_by_msb
from driver.pub.config.config import VNF_FTP
logger = logging.getLogger(__name__)
@@ -72,12 +72,6 @@ def get_vnfminfo_from_nslcm(vnfmid):
return ret
-# Query vnfm_info from esr
-def vnfm_get(vnfmid):
- ret = call_aai("api/aai-esr-server/v1/vnfms/%s" % vnfmid, "GET")
- return ret
-
-
# Query vnfd_info from nslcm
def vnfd_get(vnfpackageid):
ret = req_by_msb("api/nslcm/v1/vnfpackage/%s" % vnfpackageid, "GET")
@@ -90,7 +84,6 @@ def vnfpackage_get(csarid):
return ret
-# ==================================================
create_vnf_url = "v1/vnfs"
create_vnf_param_mapping = {
"packageUrl": "",
@@ -188,7 +181,6 @@ def instantiate_vnf(request, *args, **kwargs):
return Response(data=resp_data, status=ret[2])
-# ==================================================
vnf_delete_url = "v1/vnfs/%s"
vnf_delete_param_mapping = {
"terminationType": "terminationType",
@@ -229,9 +221,6 @@ def terminate_vnf(request, *args, **kwargs):
return Response(data=resp_data, status=ret[2])
-# ==================================================
-
-
vnf_detail_url = "v1/vnfs/%s"
vnf_detail_resp_mapping = {
"VNFInstanseStatus": "status"
@@ -410,12 +399,14 @@ def notify(request, *args, **kwargs):
openo_notification = ignorcase_get(extension, "openo_notification")
if openo_notification:
affectedvnfcs = ignorcase_get(openo_notification, "affectedVnfc")
+ affectedvls = ignorcase_get(openo_notification, "affectedvirtuallink")
+ affectedcps = ignorcase_get(openo_notification, "affectedCp")
+ vnfdmodule = ignorcase_get(openo_notification, "vnfdmodule")
else:
affectedvnfcs = ignorcase_get(ignorcase_get(request.data, "extension"), "affectedvnfc")
-
- affectedvls = ignorcase_get(ignorcase_get(request.data, "extension"), "affectedvl")
- affectedcps = ignorcase_get(ignorcase_get(request.data, "extension"), "affectedcp")
- vnfdmodule = ignorcase_get(ignorcase_get(request.data, "extension"), "vnfdmodule")
+ affectedvls = ignorcase_get(ignorcase_get(request.data, "extension"), "affectedvl")
+ affectedcps = ignorcase_get(ignorcase_get(request.data, "extension"), "affectedcp")
+ vnfdmodule = ignorcase_get(ignorcase_get(request.data, "extension"), "vnfdmodule")
data["vnfdmodule"] = vnfdmodule
@@ -440,11 +431,7 @@ def notify(request, *args, **kwargs):
for affectedcp in affectedcps:
data["affectedCp"].append(affectedcp)
- # {
- # "virtualLinkInstanceId": ignorcase_get(affectedcp, "virtuallinkinstanceid"),
- # "ownerId": ignorcase_get(affectedcp, "ownerId"),
- # "ownerType": ignorcase_get(affectedcp, "ownerType")
- # }
+
ret = req_by_msb(notify_url.format(vnfmid=ignorcase_get(data, 'VNFMID'),
vnfInstanceId=ignorcase_get(data, 'vnfinstanceid')),
"POST", content=json.JSONEncoder().encode(data))
@@ -506,7 +493,6 @@ def scale(request, *args, **kwargs):
if ret[0] != 0:
return Response(data={'error': 'scale error'}, status=ret[2])
resp_data = json.JSONDecoder().decode(ret[1])
- # jobId = resp_data["jobid"]
logger.info("resp_data=%s", resp_data)
except Exception as e:
logger.error("Error occurred when scaling VNF,error:%s", e.message)
@@ -554,7 +540,6 @@ def heal(request, *args, **kwargs):
if ret[0] != 0:
return Response(data={'error': 'heal error'}, status=ret[2])
resp_data = json.JSONDecoder().decode(ret[1])
- # jobId = resp_data["jobid"]
logger.info("resp_data=%s", resp_data)
except Exception as e:
logger.error("Error occurred when healing VNF,error:%s", e.message)
diff --git a/zte/vmanager/driver/pub/config/config.py b/zte/vmanager/driver/pub/config/config.py
index e5d90b33..3ccdde3d 100644
--- a/zte/vmanager/driver/pub/config/config.py
+++ b/zte/vmanager/driver/pub/config/config.py
@@ -12,16 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# [AAI]
-AAI_SERVICE_IP = '127.0.0.1'
-AAI_SERVICE_PORT = '8443'
-AAI_BASE_URL = "https://%s:%s/aai/v8" % (AAI_SERVICE_IP, AAI_SERVICE_PORT)
-AAI_USER = "AAI"
-AAI_PASSWORD = "AAI"
-CLOUD_OWNER = "11"
-CLOUD_REGION_ID = ""
-TENANT_ID = ""
-
# [VNFFTP]
VNF_FTP = "ftp://VMVNFM:Vnfm_1g3T@127.0.0.1:21/"
diff --git a/zte/vmanager/driver/pub/utils/restcall.py b/zte/vmanager/driver/pub/utils/restcall.py
index 3bf9c2d8..fd0b3ddd 100644
--- a/zte/vmanager/driver/pub/utils/restcall.py
+++ b/zte/vmanager/driver/pub/utils/restcall.py
@@ -12,14 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import logging
import sys
import traceback
-import logging
import urllib2
import uuid
+
import httplib2
-from driver.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT, AAI_BASE_URL, AAI_USER, AAI_PASSWORD
+from driver.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT
rest_no_auth, rest_oneway_auth, rest_bothway_auth = 0, 1, 2
HTTP_200_OK, HTTP_201_CREATED, HTTP_204_NO_CONTENT, HTTP_202_ACCEPTED = '200', '201', '204', '202'
@@ -93,56 +94,3 @@ def combine_url(base_url, resource):
else:
full_url = base_url + '/' + resource
return full_url
-
-
-def call_req_aai(base_url, user, passwd, auth_type, resource, method, content=''):
- callid = str(uuid.uuid1())
- logger.debug("[%s]call_req('%s','%s','%s',%s,'%s','%s','%s')" % (
- callid, base_url, user, passwd, auth_type, resource, method, content))
- ret = None
- resp_status = ''
- try:
- full_url = combine_url(base_url, resource)
- headers = {'content-type': 'application/json', 'accept': 'application/json',
- 'X-FromAppId': 'VFC-SVNFM-ZTE-DRIVER', 'X-TransactionId': str(uuid.uuid1())}
- if user:
- headers['Authorization'] = 'Basic ' + ('%s:%s' % (user, passwd)).encode("base64")
- ca_certs = None
- for retry_times in range(3):
- http = httplib2.Http(ca_certs=ca_certs, disable_ssl_certificate_validation=(auth_type == rest_no_auth))
- http.follow_all_redirects = True
- try:
- resp, resp_content = http.request(full_url, method=method.upper(), body=content, headers=headers)
- resp_status, resp_body = resp['status'], resp_content.decode('UTF-8')
- logger.debug("[%s][%d]status=%s,resp_body=%s)" % (callid, retry_times, resp_status, resp_body))
- if resp_status in status_ok_list:
- ret = [0, resp_body, resp_status]
- else:
- ret = [1, resp_body, resp_status]
- break
- except Exception as ex:
- if 'httplib.ResponseNotReady' in str(sys.exc_info()):
- logger.debug("retry_times=%d", retry_times)
- logger.error(traceback.format_exc())
- ret = [1, "Unable to connect to %s" % full_url, resp_status]
- continue
- raise ex
- except urllib2.URLError as err:
- ret = [2, str(err), resp_status]
- except Exception as ex:
- logger.error(traceback.format_exc())
- logger.error("[%s]ret=%s" % (callid, str(sys.exc_info())))
- res_info = str(sys.exc_info())
- if 'httplib.ResponseNotReady' in res_info:
- res_info = "The URL[%s] request failed or is not responding." % full_url
- ret = [3, res_info, resp_status]
- except:
- logger.error(traceback.format_exc())
- ret = [4, str(sys.exc_info()), resp_status]
-
- logger.debug("[%s]ret=%s" % (callid, str(ret)))
- return ret
-
-
-def call_aai(resource, method, data=''):
- return call_req_aai(AAI_BASE_URL, AAI_USER, AAI_PASSWORD, rest_no_auth, resource, method, data)
diff --git a/zte/vmanager/tox.ini b/zte/vmanager/tox.ini
index dce819a1..2d18a624 100644
--- a/zte/vmanager/tox.ini
+++ b/zte/vmanager/tox.ini
@@ -7,7 +7,7 @@ deps = -r{toxinidir}/requirements.txt
commands = coverage run --branch manage.py test
[flake8]
-ignore = E501,W291,E121,F401,W391,E302,E265,E231,F841,E127,E128,E122,E126,E303,E722
+ignore = E501,E722
max-complexity = 12
[testenv:pep8]