+
+def confirm_vnf_status(vnf_inst_id):
+ uri = "api/nslcm/v1/ns/vnfs/{vnfInstId}".format(vnfInstId=vnf_inst_id)
+ ret = restcall.req_by_msb(uri, "GET")
+ if ret[0] != 0:
+ raise NSLCMException("Failed to call get_vnf(%s)" % vnf_inst_id)
+ ret[1] = json.JSONDecoder().decode(ret[1])
+
+ vnf_status = ret[1]["vnfStatus"]
+ if vnf_status != "active":
+ raise NSLCMException("Status of VNF(%s) is not active" % vnf_inst_id)
+
+
+def confirm_sfc_status(sfc_inst_id):
+ uri = "api/nslcm/v1/ns/sfcs/{sfcInstId}".format(sfcInstId=sfc_inst_id)
+ ret = restcall.req_by_msb(uri, "GET")
+ if ret[0] != 0:
+ raise NSLCMException("Failed to call get_sfc(%s)" % sfc_inst_id)
+ ret[1] = json.JSONDecoder().decode(ret[1])
+
+ 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 list(pnfs.values()):
+ 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)