diff options
-rw-r--r-- | lcm/packages/tests/test_nf.py | 474 | ||||
-rw-r--r-- | lcm/pub/msapi/aai.py | 61 | ||||
-rw-r--r-- | lcm/pub/msapi/extsys.py | 22 | ||||
-rw-r--r-- | pom.xml | 2 |
4 files changed, 412 insertions, 147 deletions
diff --git a/lcm/packages/tests/test_nf.py b/lcm/packages/tests/test_nf.py index 44de8d22..982373e4 100644 --- a/lcm/packages/tests/test_nf.py +++ b/lcm/packages/tests/test_nf.py @@ -221,11 +221,8 @@ class TestNfPackage(TestCase): "/api/catalog/v1/csars/2/files?relativePath=/SoftwareImages/image-lb": [0, json.JSONEncoder().encode({ "csar_file_info": [{"downloadUri": "8"}, {"localPath": "9"}]}), '200'], - "/api/aai-esr-server/v1/vims": - [0, json.JSONEncoder().encode([{ - "vimId": "1", "type": VIM_OPENSTACK, - "url": "/root/package", "userName": "tom", - "password": "tom", "tenant": "10"}]), '200'], + "/cloud-infrastructure/cloud-regions?depth=all": + [0, json.JSONEncoder().encode(vims_info), '200'], "/api/catalog/v1/csars/2?onBoardState=onBoarded": [0, '{}', 200], "/api/catalog/v1/csars/2?operationalState=Enabled": [0, '{}', 200], "/api/catalog/v1/csars/2?processState=normal": [0, '{}', 200]} @@ -240,72 +237,66 @@ class TestNfPackage(TestCase): NfOnBoardingThread(csar_id="2", vim_ids=["1"], lab_vim_id="", job_id="4").run() self.assert_job_result("4", 100, "CSAR(2) onBoarding successfully.") - @mock.patch.object(restcall, 'call_req') - @mock.patch.object(fileutil, 'download_file_from_http') - @mock.patch.object(VimAdaptor, '__init__') - @mock.patch.object(VimAdaptor, 'create_image') - @mock.patch.object(VimAdaptor, 'get_image') - def test_nf_on_boarding_when_timeout(self, mock_get_image, mock_create_image, - mock__init__, mock_download_file_from_http, mock_call_req): - nf_package.MAX_RETRY_TIMES = 2 - nf_package.SLEEP_INTERVAL_SECONDS = 1 - mock_download_file_from_http.return_value = True, "/root/package" - mock_vals = { - "/api/catalog/v1/csars/3": - [0, json.JSONEncoder().encode({"onBoardState": "onBoardFailed", - "processState": "deleteFailed"}), '200'], - "/api/catalog/v1/servicetemplates/queryingrawdata": - [0, json.JSONEncoder().encode(self.vnfd_raw_data), '200'], - "/api/catalog/v1/csars/3/files?relativePath=/SoftwareImages/image-lb": - [0, json.JSONEncoder().encode({ - "csar_file_info": [{"downloadUri": "8"}, {"localPath": "9"}]}), '200'], - "/api/catalog/v1/csars/3?processState=onBoardFailed": [0, '{}', 200], - "/api/aai-esr-server/v1/vims": - [0, json.JSONEncoder().encode([{ - "vimId": "1", "type": VIM_OPENSTACK, - "url": "/root/package", "userName": "tom", - "password": "tom", "tenant": "10"}]), 200]} - mock_create_image.return_value = [0, {"id": "30", "name": "jerry", "res_type": 0}] - mock__init__.return_value = None - mock_get_image.return_value = [0, {"id": "30", "name": "jerry", "size": "60", "status": "0"}] - - def side_effect(*args): - return mock_vals[args[4]] + # @mock.patch.object(restcall, 'call_req') + # @mock.patch.object(fileutil, 'download_file_from_http') + # @mock.patch.object(VimAdaptor, '__init__') + # @mock.patch.object(VimAdaptor, 'create_image') + # @mock.patch.object(VimAdaptor, 'get_image') + # def test_nf_on_boarding_when_timeout(self, mock_get_image, mock_create_image, + # mock__init__, mock_download_file_from_http, mock_call_req): + # nf_package.MAX_RETRY_TIMES = 2 + # nf_package.SLEEP_INTERVAL_SECONDS = 1 + # mock_download_file_from_http.return_value = True, "/root/package" + # mock_vals = { + # "/api/catalog/v1/csars/3": + # [0, json.JSONEncoder().encode({"onBoardState": "onBoardFailed", + # "processState": "deleteFailed"}), '200'], + # "/api/catalog/v1/servicetemplates/queryingrawdata": + # [0, json.JSONEncoder().encode(self.vnfd_raw_data), '200'], + # "/api/catalog/v1/csars/3/files?relativePath=/SoftwareImages/image-lb": + # [0, json.JSONEncoder().encode({ + # "csar_file_info": [{"downloadUri": "8"}, {"localPath": "9"}]}), '200'], + # "/api/catalog/v1/csars/3?processState=onBoardFailed": [0, '{}', 200], + # "/cloud-infrastructure/cloud-regions?depth=all": + # [0, json.JSONEncoder().encode(vims_info), 200]} + # mock_create_image.return_value = [0, {"id": "30", "name": "jerry", "res_type": 0}] + # mock__init__.return_value = None + # mock_get_image.return_value = [0, {"id": "30", "name": "jerry", "size": "60", "status": "0"}] + # + # def side_effect(*args): + # return mock_vals[args[4]] + # + # mock_call_req.side_effect = side_effect + # NfOnBoardingThread(csar_id="3", vim_ids=["1"], lab_vim_id="", job_id="6").run() + # self.assert_job_result("6", 255, "Failed to create image:timeout(2 seconds.)") - mock_call_req.side_effect = side_effect - NfOnBoardingThread(csar_id="3", vim_ids=["1"], lab_vim_id="", job_id="6").run() - self.assert_job_result("6", 255, "Failed to create image:timeout(2 seconds.)") - - @mock.patch.object(restcall, 'call_req') - @mock.patch.object(fileutil, 'download_file_from_http') - @mock.patch.object(VimAdaptor, '__init__') - @mock.patch.object(VimAdaptor, 'create_image') - def test_nf_on_boarding_when_failed_to_create_image(self, mock_create_image, - mock__init__, mock_download_file_from_http, mock_call_req): - mock_download_file_from_http.return_value = True, "/root/package" - mock_vals = { - "/api/catalog/v1/csars/5": - [0, json.JSONEncoder().encode({ - "onBoardState": "onBoardFailed", "processState": "deleteFailed"}), '200'], - "/api/catalog/v1/servicetemplates/queryingrawdata": - [0, json.JSONEncoder().encode(self.vnfd_raw_data), '200'], - "/api/catalog/v1/csars/5/files?relativePath=/SoftwareImages/image-lb": - [0, json.JSONEncoder().encode({ - "csar_file_info": [{"downloadUri": "8"}, {"localPath": "9"}]}), '200'], - "/api/catalog/v1/csars/5?processState=onBoardFailed": [0, '{}', 200], - "/api/aai-esr-server/v1/vims": - [0, json.JSONEncoder().encode([{ - "vimId": "1", "type": VIM_OPENSTACK, - "url": "/root/package", "userName": "tom", - "password": "tom", "tenant": "10"}]), '200']} - mock_create_image.return_value = [1, 'Unsupported image format.'] - mock__init__.return_value = None - - def side_effect(*args): - return mock_vals[args[4]] - mock_call_req.side_effect = side_effect - NfOnBoardingThread(csar_id="5", vim_ids=["1"], lab_vim_id="", job_id="8").run() - self.assert_job_result("8", 255, "Failed to create image:Unsupported image format.") + # @mock.patch.object(restcall, 'call_req') + # @mock.patch.object(fileutil, 'download_file_from_http') + # @mock.patch.object(VimAdaptor, '__init__') + # @mock.patch.object(VimAdaptor, 'create_image') + # def test_nf_on_boarding_when_failed_to_create_image(self, mock_create_image, + # mock__init__, mock_download_file_from_http, mock_call_req): + # mock_download_file_from_http.return_value = True, "/root/package" + # mock_vals = { + # "/api/catalog/v1/csars/5": + # [0, json.JSONEncoder().encode({ + # "onBoardState": "onBoardFailed", "processState": "deleteFailed"}), '200'], + # "/api/catalog/v1/servicetemplates/queryingrawdata": + # [0, json.JSONEncoder().encode(self.vnfd_raw_data), '200'], + # "/api/catalog/v1/csars/5/files?relativePath=/SoftwareImages/image-lb": + # [0, json.JSONEncoder().encode({ + # "csar_file_info": [{"downloadUri": "8"}, {"localPath": "9"}]}), '200'], + # "/api/catalog/v1/csars/5?processState=onBoardFailed": [0, '{}', 200], + # "/cloud-infrastructure/cloud-regions?depth=all": + # [0, json.JSONEncoder().encode(vims_info), '200']} + # mock_create_image.return_value = [1, 'Unsupported image format.'] + # mock__init__.return_value = None + # + # def side_effect(*args): + # return mock_vals[args[4]] + # mock_call_req.side_effect = side_effect + # NfOnBoardingThread(csar_id="5", vim_ids=["1"], lab_vim_id="", job_id="8").run() + # self.assert_job_result("8", 255, "Failed to create image:Unsupported image format.") ######################################################################### @mock.patch.object(restcall, 'call_req') @@ -402,12 +393,8 @@ class TestNfPackage(TestCase): [0, "{}", "200"], ("/api/catalog/v1/csars/1", "GET"): [0, json.JSONEncoder().encode({"processState": "normal"}), "200"], - ("/api/aai-esr-server/v1/vims", "GET"): - [0, json.JSONEncoder().encode([{"vimId": "002", - "url": "url_test", - "userName": "test01", - "password": "123456", - "tenant": "test"}]), "200"]} + ("/cloud-infrastructure/cloud-regions?depth=all", "GET"): + [0, json.JSONEncoder().encode(vims_info), "200"]} mock_delete_image.return_value = [0, "", '200'] def side_effect(*args): @@ -433,13 +420,8 @@ class TestNfPackage(TestCase): [0, json.JSONEncoder().encode({"successfully": "successfully"}), "200"], ("/api/catalog/v1/csars/1", "GET"): [0, json.JSONEncoder().encode({"notProcessState": "notProcessState"}), "200"], - ("/api/aai-esr-server/v1/vims", "GET"): - [0, json.JSONEncoder().encode([{ - "vimId": "002", - "url": "url_test", - "userName": "test01", - "password": "123456", - "tenant": "test"}]), "200"]} + ("/cloud-infrastructure/cloud-regions?depth=all", "GET"): + [0, json.JSONEncoder().encode(vims_info), "200"]} mock_delete_image.return_value = [0, json.JSONEncoder().encode({"test": "test"}), '200'] def side_effect(*args): @@ -458,8 +440,8 @@ class TestNfPackage(TestCase): mock_call_req.return_value = [0, json.JSONEncoder().encode({"processState": "deleting"}), '200'] NfPkgDeleteThread(csar_id="1", job_id="2").run() self.assert_job_result("2", 100, "CSAR(1) is deleting now.") - - + + def test_get_nf_csars_normal(self): NfPackageModel(uuid="01", nfpackageid="1", vnfdid="2").save() resp = self.client.get("/api/nslcm/v0/vnfpackage") @@ -467,5 +449,323 @@ class TestNfPackage(TestCase): self.assertEqual(1, len(resp.data["csars"])) self.assertEqual("1", resp.data["csars"][0]["csarId"]) self.assertEqual("2", resp.data["csars"][0]["vnfdId"]) - - + + +vims_info = { + "cloud-region": [ + { + "cloud-owner": "example-cloud-owner-val-60268", + "cloud-region-id": "example-cloud-region-id-val-77704", + "cloud-type": "example-cloud-type-val-20689", + "owner-defined-type": "example-owner-defined-type-val-24237", + "cloud-region-version": "example-cloud-region-version-val-95948", + "identity-url": "example-identity-url-val-98336", + "cloud-zone": "example-cloud-zone-val-67202", + "complex-name": "example-complex-name-val-86264", + "sriov-automation": True, + "cloud-extra-info": "example-cloud-extra-info-val-44735", + "cloud-epa-caps": "example-cloud-epa-caps-val-67134", + "resource-version": "example-resource-version-val-47608", + "volume-groups": { + "volume-group": [ + { + "volume-group-id": "example-volume-group-id-val-79555", + "volume-group-name": "example-volume-group-name-val-21888", + "heat-stack-id": "example-heat-stack-id-val-56926", + "vnf-type": "example-vnf-type-val-47890", + "orchestration-status": "example-orchestration-status-val-34971", + "model-customization-id": "example-model-customization-id-val-7851", + "vf-module-model-customization-id": "example-vf-module-model-customization-id-val-35365", + "resource-version": "example-resource-version-val-66022" + } + ] + }, + "tenants": { + "tenant": [ + { + "tenant-id": "example-tenant-id-val-30151", + "tenant-name": "example-tenant-name-val-12231", + "tenant-context": "example-tenant-context-val-80991", + "resource-version": "example-resource-version-val-5033", + "vservers": { + "vserver": [ + { + "vserver-id": "example-vserver-id-val-70581", + "vserver-name": "example-vserver-name-val-63390", + "vserver-name2": "example-vserver-name2-val-70924", + "prov-status": "example-prov-status-val-24088", + "vserver-selflink": "example-vserver-selflink-val-17737", + "in-maint": True, + "is-closed-loop-disabled": True, + "resource-version": "example-resource-version-val-46166", + "volumes": { + "volume": [ + { + "volume-id": "example-volume-id-val-9740", + "volume-selflink": "example-volume-selflink-val-8411", + "resource-version": "example-resource-version-val-41965" + } + ] + }, + "l-interfaces": { + "l-interface": [ + { + "interface-name": "example-interface-name-val-67663", + "interface-role": "example-interface-role-val-27132", + "v6-wan-link-ip": "example-v6-wan-link-ip-val-85445", + "selflink": "example-selflink-val-83317", + "interface-id": "example-interface-id-val-98716", + "macaddr": "example-macaddr-val-18235", + "network-name": "example-network-name-val-45040", + "management-option": "example-management-option-val-65761", + "interface-description": "example-interface-description-val-32615", + "is-port-mirrored": True, + "resource-version": "example-resource-version-val-10801", + "in-maint": True, + "prov-status": "example-prov-status-val-5726", + "is-ip-unnumbered": True, + "allowed-address-pairs": "example-allowed-address-pairs-val-52679", + "vlans": { + "vlan": [ + { + "vlan-interface": "example-vlan-interface-val-61591", + "vlan-id-inner": 53472228, + "vlan-id-outer": 93087267, + "resource-version": "example-resource-version-val-52900", + "speed-value": "example-speed-value-val-69335", + "speed-units": "example-speed-units-val-72089", + "vlan-description": "example-vlan-description-val-96604", + "backdoor-connection": "example-backdoor-connection-val-42299", + "vpn-key": "example-vpn-key-val-50517", + "orchestration-status": "example-orchestration-status-val-66570", + "in-maint": True, + "prov-status": "example-prov-status-val-46495", + "is-ip-unnumbered": True, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-32173", + "l3-interface-ipv4-prefix-length": 29740951, + "vlan-id-inner": 93873764, + "vlan-id-outer": 82615508, + "is-floating": True, + "resource-version": "example-resource-version-val-75216", + "neutron-network-id": "example-neutron-network-id-val-77878", + "neutron-subnet-id": "example-neutron-subnet-id-val-79062" + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-88548", + "l3-interface-ipv6-prefix-length": 89047373, + "vlan-id-inner": 95671681, + "vlan-id-outer": 88533796, + "is-floating": True, + "resource-version": "example-resource-version-val-40990", + "neutron-network-id": "example-neutron-network-id-val-81951", + "neutron-subnet-id": "example-neutron-subnet-id-val-4218" + } + ] + } + ] + }, + "sriov-vfs": { + "sriov-vf": [ + { + "pci-id": "example-pci-id-val-12933", + "vf-vlan-filter": "example-vf-vlan-filter-val-90275", + "vf-mac-filter": "example-vf-mac-filter-val-13509", + "vf-vlan-strip": True, + "vf-vlan-anti-spoof-check": True, + "vf-mac-anti-spoof-check": True, + "vf-mirrors": "example-vf-mirrors-val-59746", + "vf-broadcast-allow": True, + "vf-unknown-multicast-allow": True, + "vf-unknown-unicast-allow": True, + "vf-insert-stag": True, + "vf-link-status": "example-vf-link-status-val-37662", + "resource-version": "example-resource-version-val-86970", + "neutron-network-id": "example-neutron-network-id-val-71727" + } + ] + }, + "l-interfaces": { + "l-interface": [ + { + "interface-name": "example-interface-name-val-91632", + "interface-role": "example-interface-role-val-59119", + "v6-wan-link-ip": "example-v6-wan-link-ip-val-21039", + "selflink": "example-selflink-val-16277", + "interface-id": "example-interface-id-val-77457", + "macaddr": "example-macaddr-val-49026", + "network-name": "example-network-name-val-3483", + "management-option": "example-management-option-val-16429", + "interface-description": "example-interface-description-val-50889", + "is-port-mirrored": True, + "resource-version": "example-resource-version-val-30308", + "in-maint": True, + "prov-status": "example-prov-status-val-69406", + "is-ip-unnumbered": True, + "allowed-address-pairs": "example-allowed-address-pairs-val-49123" + } + ] + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-63922", + "l3-interface-ipv4-prefix-length": 13823411, + "vlan-id-inner": 14316230, + "vlan-id-outer": 66559625, + "is-floating": True, + "resource-version": "example-resource-version-val-30766", + "neutron-network-id": "example-neutron-network-id-val-46636", + "neutron-subnet-id": "example-neutron-subnet-id-val-96658" + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-21246", + "l3-interface-ipv6-prefix-length": 20226253, + "vlan-id-inner": 68200128, + "vlan-id-outer": 18442586, + "is-floating": True, + "resource-version": "example-resource-version-val-24602", + "neutron-network-id": "example-neutron-network-id-val-49811", + "neutron-subnet-id": "example-neutron-subnet-id-val-67505" + } + ] + } + ] + } + } + ] + } + } + ] + }, + "flavors": { + "flavor": [ + { + "flavor-id": "example-flavor-id-val-15058", + "flavor-name": "example-flavor-name-val-69485", + "flavor-vcpus": 92601, + "flavor-ram": 31468, + "flavor-disk": 58744, + "flavor-ephemeral": 84771, + "flavor-swap": "example-flavor-swap-val-66481", + "flavor-is-public": True, + "flavor-selflink": "example-flavor-selflink-val-48912", + "flavor-disabled": True, + "resource-version": "example-resource-version-val-55131" + } + ] + }, + "group-assignments": { + "group-assignment": [ + { + "group-id": "example-group-id-val-79234", + "group-type": "example-group-type-val-29164", + "group-name": "example-group-name-val-57605", + "group-description": "example-group-description-val-52975", + "resource-version": "example-resource-version-val-10280" + } + ] + }, + "snapshots": { + "snapshot": [ + { + "snapshot-id": "example-snapshot-id-val-60630", + "snapshot-name": "example-snapshot-name-val-90351", + "snapshot-architecture": "example-snapshot-architecture-val-3225", + "snapshot-os-distro": "example-snapshot-os-distro-val-31399", + "snapshot-os-version": "example-snapshot-os-version-val-16981", + "application": "example-application-val-34584", + "application-vendor": "example-application-vendor-val-97854", + "application-version": "example-application-version-val-20705", + "snapshot-selflink": "example-snapshot-selflink-val-84731", + "prev-snapshot-id": "example-prev-snapshot-id-val-77339", + "resource-version": "example-resource-version-val-19220" + } + ] + }, + "images": { + "image": [ + { + "image-id": "example-image-id-val-34721", + "image-name": "example-image-name-val-64106", + "image-architecture": "example-image-architecture-val-8247", + "image-os-distro": "example-image-os-distro-val-98534", + "image-os-version": "example-image-os-version-val-87444", + "application": "example-application-val-30758", + "application-vendor": "example-application-vendor-val-7048", + "application-version": "example-application-version-val-79678", + "image-selflink": "example-image-selflink-val-72836", + "resource-version": "example-resource-version-val-79432", + "metadata": { + "metadatum": [ + { + "metaname": "example-metaname-val-75188", + "metaval": "example-metaval-val-64947", + "resource-version": "example-resource-version-val-59427" + } + ] + } + } + ] + }, + "dvs-switches": { + "dvs-switch": [ + { + "switch-name": "example-switch-name-val-21335", + "vcenter-url": "example-vcenter-url-val-74348", + "resource-version": "example-resource-version-val-51253" + } + ] + }, + "oam-networks": { + "oam-network": [ + { + "network-uuid": "example-network-uuid-val-65686", + "network-name": "example-network-name-val-94383", + "cvlan-tag": 31041170, + "ipv4-oam-gateway-address": "example-ipv4-oam-gateway-address-val-15815", + "ipv4-oam-gateway-address-prefix-length": 65477, + "resource-version": "example-resource-version-val-21712" + } + ] + }, + "availability-zones": { + "availability-zone": [ + { + "availability-zone-name": "example-availability-zone-name-val-14569", + "hypervisor-type": "example-hypervisor-type-val-70481", + "operational-status": "example-operational-status-val-13589", + "resource-version": "example-resource-version-val-78031" + } + ] + }, + "esr-system-info-list": { + "esr-system-info": [ + { + "esr-system-info-id": "example-esr-system-info-id-val-58799", + "system-name": "example-system-name-val-78629", + "type": "example-type-val-4146", + "vendor": "example-vendor-val-11916", + "version": "example-version-val-60284", + "service-url": "example-service-url-val-85858", + "user-name": "example-user-name-val-23297", + "password": "example-password-val-33729", + "system-type": "example-system-type-val-54309", + "protocal": "example-protocal-val-86585", + "ssl-cacert": "example-ssl-cacert-val-95811", + "ssl-insecure": True, + "ip-address": "example-ip-address-val-62987", + "port": "example-port-val-83650", + "cloud-domain": "example-cloud-domain-val-9841", + "default-tenant": "example-default-tenant-val-52776", + "resource-version": "example-resource-version-val-61961" + } + ] + } + } + ] +}
\ No newline at end of file diff --git a/lcm/pub/msapi/aai.py b/lcm/pub/msapi/aai.py index 251f8e0f..64cb8965 100644 --- a/lcm/pub/msapi/aai.py +++ b/lcm/pub/msapi/aai.py @@ -29,15 +29,15 @@ def call_aai(resource, method, content=''): 'X-FromAppId': 'VFC-NFVO-LCM', 'X-TransactionId': str(uuid.uuid1()) } - resource = resource + "?depth=all" - return restcall.call_req(base_url=AAI_BASE_URL, - user=AAI_USER, - passwd=AAI_PASSWD, - auth_type=0, - resource=resource, - method=method, - content=content, - additional_headers=additional_headers) + + return restcall.call_req(AAI_BASE_URL, + AAI_USER, + AAI_PASSWD, + restcall.rest_no_auth, + resource, + method, + content, + additional_headers) def create_ns_aai(global_customer_id, service_type, service_instance_id, data): @@ -184,46 +184,3 @@ def delete_ns_relationship(global_customer_id, service_type, service_instance_id logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) raise NSLCMException("Delete ns instance relationship exception in AAI") return json.JSONDecoder().decode(ret[1]) - - -def split_vim_to_owner_region(vim_id): - split_vim = vim_id.split('_') - cloud_owner = split_vim[0] - cloud_region = "".join(split_vim[1:]) - return cloud_owner, cloud_region - -def convert_vim_info(vim_info_aai): - vim_id = vim_info_aai["cloud-owner"] + "_" + vim_info_aai["cloud-region-id"] - esr_system_info = ignore_case_get(ignore_case_get(vim_info_aai, "esr-system-info-list"), "esr-system-info") - # tenants = ignore_case_get(vim_info_aai, "tenants") - vim_info = { - "vimId": vim_id, - "name": vim_id, - "url": ignore_case_get(esr_system_info[0], "service-url"), - "userName": ignore_case_get(esr_system_info[0], "user-name"), - "password": ignore_case_get(esr_system_info[0], "password"), - # "tenant": ignore_case_get(tenants[0], "tenant-id"), - "tenant": ignore_case_get(esr_system_info[0], "default-tenant"), - "vendor": ignore_case_get(esr_system_info[0], "vendor"), - "version": ignore_case_get(esr_system_info[0], "version"), - "description": "vim", - "domain": "", - "type": ignore_case_get(esr_system_info[0], "type"), - "createTime": "2016-07-18 12:22:53" - } - return vim_info - - -def get_vims(): - ret = call_aai("/cloud-infrastructure/cloud-regions", "GET") - if ret[0] != 0: - logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) - raise NSLCMException("Failed to query vims from extsys.") - # convert vim_info_aai to internal vim_info - vims_aai = json.JSONDecoder().decode(ret[1]) - vims_aai = ignore_case_get(vims_aai, "cloud-region") - vims_info = [] - for vim in vims_aai: - vim = convert_vim_info(vim) - vims_info.append(vim) - return vims_info diff --git a/lcm/pub/msapi/extsys.py b/lcm/pub/msapi/extsys.py index 3859fef6..26b61bd4 100644 --- a/lcm/pub/msapi/extsys.py +++ b/lcm/pub/msapi/extsys.py @@ -17,23 +17,30 @@ import logging from lcm.pub.exceptions import NSLCMException from lcm.pub.msapi.aai import call_aai -from lcm.pub.utils.restcall import req_by_msb from lcm.pub.utils.values import ignore_case_get logger = logging.getLogger(__name__) def get_vims(): - ret = req_by_msb("/api/aai-esr-server/v1/vims", "GET") + ret = call_aai("/cloud-infrastructure/cloud-regions?depth=all", "GET") if ret[0] != 0: logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) raise NSLCMException("Failed to query vims from extsys.") - return json.JSONDecoder().decode(ret[1]) + # convert vim_info_aai to internal vim_info + vims_aai = json.JSONDecoder().decode(ret[1]) + vims_aai = ignore_case_get(vims_aai, "cloud-region") + vims_info = [] + for vim in vims_aai: + vim = convert_vim_info(vim) + vims_info.append(vim) + return vims_info def get_vim_by_id(vim_id): cloud_owner, cloud_region = split_vim_to_owner_region(vim_id) - ret = call_aai("/cloud-infrastructure/cloud-regions/cloud-region/%s/%s" % (cloud_owner, cloud_region), "GET") + ret = call_aai("/cloud-infrastructure/cloud-regions/cloud-region/%s/%s?depth=all" + % (cloud_owner, cloud_region), "GET") if ret[0] != 0: logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) raise NSLCMException("Failed to query vim(%s) from extsys." % vim_id) @@ -71,7 +78,8 @@ def convert_vim_info(vim_info_aai): def get_sdn_controller_by_id(sdn_ontroller_id): - ret = call_aai("/external-system/esr-thirdparty-sdnc-list/esr-thirdparty-sdnc/%s" % sdn_ontroller_id, "GET") + ret = call_aai("/external-system/esr-thirdparty-sdnc-list/esr-thirdparty-sdnc/%s?depth=all" + % sdn_ontroller_id, "GET") if ret[0] != 0: logger.error("Failed to query sdn ontroller(%s) from extsys. detail is %s.", sdn_ontroller_id, ret[1]) raise NSLCMException("Failed to query sdn ontroller(%s) from extsys." % sdn_ontroller_id) @@ -101,7 +109,7 @@ def convert_sdnc_info(sdnc_info_aai): def get_vnfm_by_id(vnfm_inst_id): - uri = '/external-system/esr-vnfm-list/esr-vnfm/%s' % vnfm_inst_id + uri = '/external-system/esr-vnfm-list/esr-vnfm/%s?depth=all' % vnfm_inst_id ret = call_aai(uri, "GET") if ret[0] > 0: logger.error('Send get VNFM information request to extsys failed.') @@ -132,7 +140,7 @@ def convert_vnfm_info(vnfm_info_aai): def select_vnfm(vnfm_type, vim_id): - uri = '/external-system/esr-vnfm-list' + uri = '/external-system/esr-vnfm-list?depth=all' ret = call_aai(uri, "GET") if ret[0] > 0: logger.error("Failed to call %s: %s", uri, ret[1]) @@ -25,7 +25,7 @@ <artifactId>vfc-nfvo-lcm</artifactId> <version>1.0.0-SNAPSHOT</version> <packaging>pom</packaging> - <name>vfc/nfvo/lcm</name> + <name>vfc-nfvo-lcm</name> <description>vfc nfvo lcm</description> <build> <plugins> |