aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-09-07 13:52:26 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-09-07 13:52:26 +0800
commit1353da7aa7eeb3fbe021f62e7f1e45626b3884e1 (patch)
treea3b73ed86300eec7c0d22077737d8733b2415122
parent7586bf5f92305ef4265b8edda1fc7b7e379f6efa (diff)
Implement query sdnc info from ESR
Add get_sdn_controller_by_id methods to get vnfm info from esr. Change-Id: Ia76c4dcf6adbbaee9be910a18cb9fbecf85ec87f Issue-ID: VFC-309 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r--lcm/pub/msapi/aai.py36
1 files changed, 33 insertions, 3 deletions
diff --git a/lcm/pub/msapi/aai.py b/lcm/pub/msapi/aai.py
index 151c4f63..13a85230 100644
--- a/lcm/pub/msapi/aai.py
+++ b/lcm/pub/msapi/aai.py
@@ -254,19 +254,20 @@ def split_vim_to_owner_region(vim_id):
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(vim_info_aai, "esr-system-info")
- tenants = ignore_case_get(vim_info_aai, "tenants")
+ # 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(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": "openstack",
+ "type": ignore_case_get(esr_system_info[0], "type"),
"createTime": "2016-07-18 12:22:53"
}
return vim_info
@@ -285,3 +286,32 @@ def get_vims():
vim = convert_vim_info(vim)
vims_info.append(vim)
return vims_info
+
+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")
+ 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)
+
+ # convert vim_info_aai to internal vim_info
+ sdnc_info_aai = json.JSONDecoder().decode(ret[1])
+ sdnc_info = convert_sdnc_info(sdnc_info_aai)
+ return sdnc_info
+
+def convert_sdnc_info(sdnc_info_aai):
+ esr_system_info = ignore_case_get(sdnc_info_aai, "esr-system-info")
+ sdnc_info = {
+ "sdnControllerId": sdnc_info_aai["thirdparty-sdnc-id"],
+ "name": sdnc_info_aai["thirdparty-sdnc-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"),
+ "vendor": ignore_case_get(esr_system_info[0], "vendor"),
+ "version": ignore_case_get(esr_system_info[0], "version"),
+ "description": "",
+ "protocol": ignore_case_get(esr_system_info[0], "protocal"),
+ "productName": ignore_case_get(sdnc_info_aai, "product-name"),
+ "type": ignore_case_get(esr_system_info[0], "type"),
+ "createTime": "2016-07-18 12:22:53"
+ }
+ return sdnc_info