summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhewei-cmss <hewei@cmss.chinamobile.com>2019-10-14 13:54:54 +0800
committerhewei-cmss <hewei@cmss.chinamobile.com>2019-10-14 15:22:41 +0800
commit621d3a6ac812ecc59ae1579cd6c9fd5f65345943 (patch)
tree0189302afd0112a05834f9c5b3a411911cab00aa
parent2ff0797f2bcc531acc56eef60aec40c5c6b1ef00 (diff)
add package state
add package is using state when ns instanting Issue-ID: VFC-1504 Signed-off-by: hewei-cmss <hewei@cmss.chinamobile.com> Change-Id: I3079925e97588e74d7ea4bab3e88494e52647c09
-rw-r--r--lcm/ns/biz/ns_instant.py1
-rw-r--r--lcm/ns/tests/test_ns_instant.py5
-rw-r--r--lcm/ns/tests/test_sol_ns_instantiate_api.py1
-rw-r--r--lcm/pub/msapi/sdc_run_catalog.py8
4 files changed, 15 insertions, 0 deletions
diff --git a/lcm/ns/biz/ns_instant.py b/lcm/ns/biz/ns_instant.py
index e6f0d1be..5cd33783 100644
--- a/lcm/ns/biz/ns_instant.py
+++ b/lcm/ns/biz/ns_instant.py
@@ -87,6 +87,7 @@ class InstantNSService(object):
dst_plan = sdc_run_catalog.parse_nsd(ns_inst.nspackage_id, input_parameters)
logger.debug('tosca plan dest: %s' % dst_plan)
logger.debug('Start query nsd(%s)' % ns_inst.nspackage_id)
+ sdc_run_catalog.modify_nsd_state(ns_inst.nspackage_id)
NSInstModel.objects.filter(id=self.ns_inst_id).update(nsd_model=dst_plan)
params_vnf = []
diff --git a/lcm/ns/tests/test_ns_instant.py b/lcm/ns/tests/test_ns_instant.py
index 50a7508b..ddc13b60 100644
--- a/lcm/ns/tests/test_ns_instant.py
+++ b/lcm/ns/tests/test_ns_instant.py
@@ -56,6 +56,7 @@ class TestNsInstant(TestCase):
config.WORKFLOW_OPTION = "buildin"
mock_call_req.side_effect = [
[0, {"model": json.dumps(NSD_MODEL_DICT)}, '200'],
+ [0, None, '202'],
[0, VNFM_LIST_IN_AAI_DICT, '200'],
[0, VNFM_IN_AAI_DICT, '200']
]
@@ -109,6 +110,8 @@ class TestNsInstant(TestCase):
[0, json.JSONEncoder().encode(items), "200"],
"/api/wso2bpel/v1/process/instance":
[0, json.JSONEncoder().encode(ret), "200"],
+ "/api/catalog/v1/ns_descriptors/1":
+ [0, None, "202"],
}
def side_effect(*args):
@@ -131,6 +134,8 @@ class TestNsInstant(TestCase):
mock_vals = {
"api/workflow/v1/process/instance":
[0, json.JSONEncoder().encode(ret), "200"],
+ "/api/catalog/v1/ns_descriptors/1":
+ [0, None, "202"],
}
def side_effect(*args):
diff --git a/lcm/ns/tests/test_sol_ns_instantiate_api.py b/lcm/ns/tests/test_sol_ns_instantiate_api.py
index f13b7c41..0b1bca6d 100644
--- a/lcm/ns/tests/test_sol_ns_instantiate_api.py
+++ b/lcm/ns/tests/test_sol_ns_instantiate_api.py
@@ -53,6 +53,7 @@ class TestInstantiateNsApi(TestCase):
def test_ns_instantiate_when_succeed_to_enter_workflow(self, mock_run, mock_call_req):
config.WORKFLOW_OPTION = "buildin"
mock_call_req.side_effect = [
+ [0, None, '202'],
[0, self.vnfms, '200'],
[0, self.vnfm, '200']
]
diff --git a/lcm/pub/msapi/sdc_run_catalog.py b/lcm/pub/msapi/sdc_run_catalog.py
index 073b8332..d1b26070 100644
--- a/lcm/pub/msapi/sdc_run_catalog.py
+++ b/lcm/pub/msapi/sdc_run_catalog.py
@@ -67,3 +67,11 @@ def query_pnf_descriptor(filter=None):
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Failed to query pnf descriptor(%s) from catalog." % pnfdId)
return json.JSONDecoder().decode(ret[1])
+
+
+def modify_nsd_state(csar_id):
+ req_param = json.JSONEncoder().encode({"usageState": 1})
+ ret = req_by_msb("/api/catalog/v1/ns_descriptors/%s" % csar_id, "PUT", req_param)
+ if ret[0] != 0:
+ logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ raise NSLCMException("Failed to modify nsd state of CSAR(%s) from catalog." % csar_id)