From ffd4c835081dd04f0f56e54a3f6bf27f7ca0ae59 Mon Sep 17 00:00:00 2001 From: "ying.yunlong" Date: Fri, 8 Sep 2017 09:08:09 +0800 Subject: Update query vnfms api in vfc lcm extsys Change-Id: I2c4c0718e7fc1ccea82dcf36e508fed1402242fc Issue-ID: VFC-313 Signed-off-by: ying.yunlong --- lcm/pub/msapi/aai.py | 19 ------------------- lcm/pub/msapi/extsys.py | 33 +++++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/lcm/pub/msapi/aai.py b/lcm/pub/msapi/aai.py index 1d1b3916..2666807f 100644 --- a/lcm/pub/msapi/aai.py +++ b/lcm/pub/msapi/aai.py @@ -214,25 +214,6 @@ def convert_vnfm_info(vnfm_info_aai): return vnfm_info -def select_vnfm(vnfm_type, vim_id): - uri = '/external-system/esr-vnfm-list' - ret = call_aai(uri, "GET") - if ret[0] > 0: - logger.error("Failed to call %s: %s", uri, ret[1]) - raise NSLCMException('Failed to get vnfms from extsys.') - vnfms = json.JSONDecoder().decode(ret[1]) - vnfms = ignore_case_get(vnfms, "esr-vnfm") - for vnfm in vnfms: - esr_system_info = ignore_case_get(vnfm, "esr-system-info") - type = ignore_case_get(esr_system_info, "type") - vimId = vnfm["vnfm-id"] - if type == vnfm_type and vimId == vim_id: - # convert vnfm_info_aai to internal vnfm_info - vnfm = convert_vnfm_info(vnfm) - return vnfm - raise NSLCMException('No vnfm found with %s in vim(%s)' % (vnfm_type, vim_id)) - - 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") diff --git a/lcm/pub/msapi/extsys.py b/lcm/pub/msapi/extsys.py index 6393ef04..296f4cba 100644 --- a/lcm/pub/msapi/extsys.py +++ b/lcm/pub/msapi/extsys.py @@ -77,15 +77,40 @@ def get_vnfm_by_id(vnfm_inst_id): raise NSLCMException('Send get VNFM information request to extsys failed.') return json.JSONDecoder().decode(ret[1]) + +def convert_vnfm_info(vnfm_info_aai): + esr_system_info = ignore_case_get(ignore_case_get(vnfm_info_aai, "esr-system-info-list"), "esr-system-info") + vnfm_info = { + "vnfmId": vnfm_info_aai["vnfm-id"], + "name": vnfm_info_aai["vnfm-id"], + "type": ignore_case_get(esr_system_info[0], "type"), + "vimId": vnfm_info_aai["vim-id"], + "vendor": ignore_case_get(esr_system_info[0], "vendor"), + "version": ignore_case_get(esr_system_info[0], "version"), + "description": "vnfm", + "certificateUrl": vnfm_info_aai["certificate-url"], + "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"), + "createTime": "2016-07-06 15:33:18" + } + return vnfm_info + + def select_vnfm(vnfm_type, vim_id): - uri = '/api/aai-esr-server/v1/vnfms' - ret = req_by_msb(uri, "GET") + uri = '/external-system/esr-vnfm-list' + ret = call_aai(uri, "GET") if ret[0] > 0: logger.error("Failed to call %s: %s", uri, ret[1]) raise NSLCMException('Failed to get vnfms from extsys.') vnfms = json.JSONDecoder().decode(ret[1]) + vnfms = ignore_case_get(vnfms, "esr-vnfm") for vnfm in vnfms: - if vnfm["type"] == vnfm_type and vnfm["vimId"] == vim_id: + esr_system_info = ignore_case_get(vnfm, "esr-system-info") + type = ignore_case_get(esr_system_info, "type") + vimId = vnfm["vnfm-id"] + if type == vnfm_type and vimId == vim_id: + # convert vnfm_info_aai to internal vnfm_info + vnfm = convert_vnfm_info(vnfm) return vnfm raise NSLCMException('No vnfm found with %s in vim(%s)' % (vnfm_type, vim_id)) - -- cgit 1.2.3-korg