diff options
author | maopengzhang <zhang.maopeng1@zte.com.cn> | 2018-10-16 14:07:38 +0800 |
---|---|---|
committer | maopengzhang <zhang.maopeng1@zte.com.cn> | 2018-10-16 14:55:44 +0800 |
commit | 9738b5dcc1c26c0e58c8ba37c606ed5e4018d4a7 (patch) | |
tree | 9a968ced1dc4a84a675795f938cfef21aba74181 | |
parent | c06206e70907a5fc0b308a7521a7676c07117466 (diff) |
add pnf in build in workflow
add pnf in build in workflow
Change-Id: I4fe5aa56076c94c9a659dc273631328ac1814ec0
Issue-ID: VFC-1041
Signed-off-by: maopengzhang <zhang.maopeng1@zte.com.cn>
-rw-r--r-- | lcm/ns/biz/ns_instant.py | 3 | ||||
-rw-r--r-- | lcm/pub/config/config.py | 2 | ||||
-rw-r--r-- | lcm/workflows/build_in.py | 18 |
3 files changed, 21 insertions, 2 deletions
diff --git a/lcm/ns/biz/ns_instant.py b/lcm/ns/biz/ns_instant.py index 7185cfc0..52f686be 100644 --- a/lcm/ns/biz/ns_instant.py +++ b/lcm/ns/biz/ns_instant.py @@ -242,7 +242,8 @@ class InstantNSService(object): vls = len(data.get('vls', [])) sfcs = len(data.get('fps', [])) vnfs = len(data.get('vnfs', [])) - return {'vlCount': str(vls), 'sfcCount': str(sfcs), 'vnfCount': str(vnfs)} + pnfs = len(data.get('pnfs', [])) + return {'vlCount': str(vls), 'sfcCount': str(sfcs), 'vnfCount': str(vnfs), 'pnfCount': str(pnfs)} def init_pnf_para(self, plan_dict): pnfs_in_input = ignore_case_get(self.req_data, "addpnfData") diff --git a/lcm/pub/config/config.py b/lcm/pub/config/config.py index 9d63b254..5ba41e98 100644 --- a/lcm/pub/config/config.py +++ b/lcm/pub/config/config.py @@ -66,7 +66,7 @@ MR_PORT = '3904' # [workflow] DEPLOY_WORKFLOW_WHEN_START = False -# Support option: activiti/wso2/buildin +# Support option: activiti/wso2/buildin/grapflow WORKFLOW_OPTION = "buildin" # [OOF config] diff --git a/lcm/workflows/build_in.py b/lcm/workflows/build_in.py index 9086bc8b..993efbe6 100644 --- a/lcm/workflows/build_in.py +++ b/lcm/workflows/build_in.py @@ -53,6 +53,7 @@ def run_ns_instantiate(input_data): nsd_json = ignore_case_get(input_data, "object_context") ns_param_json = ignore_case_get(input_data, "object_additionalParamForNs") vnf_param_json = ignore_case_get(input_data, "object_additionalParamForVnf") + pnf_param_json = ignore_case_get(input_data, "object_additionalParamForPnf") vl_count = int(ignore_case_get(input_data, "vlCount", 0)) vnf_count = int(ignore_case_get(input_data, "vnfCount", 0)) sfc_count = int(ignore_case_get(input_data, "sfcCount", 0)) @@ -69,6 +70,9 @@ def run_ns_instantiate(input_data): [confirm_vnf_status(inst_id) for inst_id, _, _ in jobs] + update_job(job_id, 50, "true", "Start to create PNF") + create_pnf(pnf_param_json) + update_job(job_id, 70, "true", "Start to create SFC") g_jobs_status[job_id] = [1 for i in range(sfc_count)] jobs = [create_sfc(ns_inst_id, i + 1, nsd_json, sdnc_id) for i in range(sfc_count)] @@ -186,6 +190,7 @@ class JobWaitThread(Thread): """ Job Wait """ + def __init__(self, inst_id, job_id, ns_job_id, index): Thread.__init__(self) self.inst_id = inst_id @@ -269,3 +274,16 @@ def confirm_sfc_status(sfc_inst_id): sfc_status = ret[1]["sfcStatus"] if sfc_status != "active": raise NSLCMException("Status of SFC(%s) is not active" % sfc_inst_id) + + +def create_pnf(pnf_param_json): + if pnf_param_json and len(pnf_param_json) > 0: + pnfs = json.JSONDecoder().decode(pnf_param_json) + for pnf in pnfs: + uri = "/api/nslcm/v1/pnfs" + method = "POST" + content = json.JSONEncoder().encode(pnf["input"]["content"]) + ret = restcall.req_by_msb(uri, method, content) + if ret[0] != 0: + logger.error("Failed to call create_pnf(%s) result %s", content, ret) + raise NSLCMException("Failed to call create_pnf(%s)" % content) |