Add code to download scaling json 43/33743/2
authorfengyuanxing <feng.yuanxing@zte.com.cn>
Fri, 2 Mar 2018 07:16:18 +0000 (15:16 +0800)
committerfengyuanxing <feng.yuanxing@zte.com.cn>
Fri, 2 Mar 2018 07:30:21 +0000 (15:30 +0800)
Change-Id: I97f13443430db70e99c22b9baec2610b58aee191
Issue-ID: VFC-784
Signed-off-by: fengyuanxing <feng.yuanxing@zte.com.cn>
lcm/pub/msapi/catalog.py

index ebefcab..7efd63d 100644 (file)
@@ -18,6 +18,7 @@ import logging
 from lcm.pub.utils.restcall import req_by_msb
 from lcm.pub.utils.values import ignore_case_get
 from lcm.pub.exceptions import NSLCMException
+from lcm.pub.database.models import NSInstModel
 
 logger = logging.getLogger(__name__)
 
@@ -104,3 +105,13 @@ def get_servicetemplate(nsd_id):
         if stpl.get("id", "") == nsd_id:
             return stpl
     return NSLCMException('servicetemplate(%s) does not exist.' % nsd_id)
+
+
+# Gets scaling map json according to nsd id.
+def get_scalingmap_json_package(ns_InstanceId):
+    csar_id = NSInstModel.objects.filter(id=ns_InstanceId)[0]["nspackage_id"]
+    downloadUrl = query_csar_from_catalog(csar_id, "packageInfo")["downloadUrl"]
+    ret = req_by_msb(downloadUrl, 'GET')
+    scalingmap_json = json.JSONDecoder().decode(ret[1])
+
+    return scalingmap_json