FIx vfc-catalog additional_headers info 59/13759/1
authorying.yunlong <ying.yunlong@zte.com.cn>
Wed, 20 Sep 2017 07:47:51 +0000 (15:47 +0800)
committerying.yunlong <ying.yunlong@zte.com.cn>
Wed, 20 Sep 2017 07:47:51 +0000 (15:47 +0800)
Change-Id: I5e04046ca1eea7b6ea2e1e6aa0011419b3608044
Issue-ID: VFC-399
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
catalog/pub/msapi/extsys.py

index 4a0d4f8..ad300fe 100644 (file)
@@ -26,7 +26,7 @@ logger = logging.getLogger(__name__)
 
 def call_aai(resource, method, content=''):
     additional_headers = {
-        'X-FromAppId': 'VFC-NFVO-LCM',
+        'X-FromAppId': 'VFC-CATALOG',
         'X-TransactionId': str(uuid.uuid1())
     }
 
@@ -45,6 +45,7 @@ def get_vims():
     if ret[0] != 0:
         logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
         raise CatalogException("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")
@@ -55,6 +56,20 @@ def get_vims():
     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?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 CatalogException("Failed to query vim(%s) from extsys." % vim_id)
+
+    # convert vim_info_aai to internal vim_info
+    vim_info_aai = json.JSONDecoder().decode(ret[1])
+    vim_info = convert_vim_info(vim_info_aai)
+    return vim_info
+
+
 def split_vim_to_owner_region(vim_id):
     split_vim = vim_id.split('_')
     cloud_owner = split_vim[0]
@@ -65,14 +80,12 @@ 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(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"),
@@ -84,25 +97,13 @@ def convert_vim_info(vim_info_aai):
     return vim_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?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 CatalogException("Failed to query vim(%s) from extsys." % vim_id)
-    # convert vim_info_aai to internal vim_info
-    vim_info_aai = json.JSONDecoder().decode(ret[1])
-    vim_info = convert_vim_info(vim_info_aai)
-    return vim_info
-
-
 def get_sdn_controller_by_id(sdn_ontroller_id):
     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 CatalogException("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)