Change-Id: I3d0a9a7fb38643646f5f60840307fdd6b61b9a9b
Issue-ID: VFC-456
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
=================================
Output:
{
=================================
Output:
{
- "status": "int",
- "message": "string",
- "deployedId": "string",
- "processId": "string"
+ "status": "int",
+ "message": "string",
+ "deployedId": "string",
+ "processId": "string"
def deploy_workflow(file_path):
file_name = file_path.split("/")[-1]
file_data = {
def deploy_workflow(file_path):
file_name = file_path.split("/")[-1]
file_data = {
- 'file': open(file_path, 'rb'),
+ 'file': open(file_path, 'rb'),
'filename': file_name}
ret = restcall.upload_by_msb("api/workflow/v1/package", "POST", file_data)
if ret[0] != 0:
raise NSLCMException("Status code is %s, detail is %s.", ret[2], ret[1])
return json.JSONDecoder().decode(ret[1])
'filename': file_name}
ret = restcall.upload_by_msb("api/workflow/v1/package", "POST", file_data)
if ret[0] != 0:
raise NSLCMException("Status code is %s, detail is %s.", ret[2], ret[1])
return json.JSONDecoder().decode(ret[1])
"""
Input:
None
=================================
Output:
{
"""
Input:
None
=================================
Output:
{
- "status": "int",
- "message": "string",
+ "status": "int",
+ "message": "string",
def undeploy_workflow(deploy_id):
uri = "api/workflow/v1/package/{deployId}".format(deployId=deploy_id)
ret = restcall.req_by_msb(uri, "DELETE")
def undeploy_workflow(deploy_id):
uri = "api/workflow/v1/package/{deployId}".format(deployId=deploy_id)
ret = restcall.req_by_msb(uri, "DELETE")
- "processId": "string",
- "params": "Map<String, String>"
+ "processId": "string",
+ "params": "Map<String, String>"
}
=================================
Output:
{
}
=================================
Output:
{
- "status": "int",
- "message": "string",
+ "status": "int",
+ "message": "string",
def exec_workflow(content):
content_str = json.JSONEncoder().encode(content)
ret = restcall.req_by_msb("api/workflow/v1/process/instance", "POST", content_str)
if ret[0] != 0:
raise NSLCMException("Status code is %s, detail is %s.", ret[2], ret[1])
return json.JSONDecoder().decode(ret[1])
def exec_workflow(content):
content_str = json.JSONEncoder().encode(content)
ret = restcall.req_by_msb("api/workflow/v1/process/instance", "POST", content_str)
if ret[0] != 0:
raise NSLCMException("Status code is %s, detail is %s.", ret[2], ret[1])
return json.JSONDecoder().decode(ret[1])
return item['processId']
raise NSLCMException('service[%s,%s] process id not exist' % (name, srv_template_id))
return item['processId']
raise NSLCMException('service[%s,%s] process id not exist' % (name, srv_template_id))
def get_servicetemplate_id(nsd_id):
ret = req_by_msb('/api/catalog/v1/servicetemplates', 'GET')
if ret[0] != 0:
def get_servicetemplate_id(nsd_id):
ret = req_by_msb('/api/catalog/v1/servicetemplates', 'GET')
if ret[0] != 0:
if stpl.get("id", "") == nsd_id:
return stpl["serviceTemplateId"]
raise NSLCMException('servicetemplate(%s) does not exist.' % nsd_id)
if stpl.get("id", "") == nsd_id:
return stpl["serviceTemplateId"]
raise NSLCMException('servicetemplate(%s) does not exist.' % nsd_id)
def get_servicetemplate(nsd_id):
ret = req_by_msb('/api/catalog/v1/servicetemplates', 'GET')
if ret[0] != 0:
def get_servicetemplate(nsd_id):
ret = req_by_msb('/api/catalog/v1/servicetemplates', 'GET')
if ret[0] != 0:
vim_info = convert_vim_info(vim_info_aai)
return vim_info
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]
cloud_region = "".join(split_vim[1:])
return cloud_owner, cloud_region
def split_vim_to_owner_region(vim_id):
split_vim = vim_id.split('_')
cloud_owner = split_vim[0]
cloud_region = "".join(split_vim[1:])
return cloud_owner, cloud_region
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")
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")
logger = logging.getLogger(__name__)
logger = logging.getLogger(__name__)
def call_from_ns_cancel_resource(res_type, instid):
method = "DELETE"
if res_type == 'vl':
def call_from_ns_cancel_resource(res_type, instid):
method = "DELETE"
if res_type == 'vl':
req_param = {}
ret = req_by_msb(uri, method, json.dumps(req_param))
logger.info("[NS terminate] call vnfm [%s] result:%s" % (res_type, ret))
req_param = {}
ret = req_by_msb(uri, method, json.dumps(req_param))
logger.info("[NS terminate] call vnfm [%s] result:%s" % (res_type, ret))
- return ret
\ No newline at end of file
raise NSLCMException("Failed to parsernsd of CSAR(%s) from catalog." % csar_id)
return json.JSONDecoder().decode(ret[1])
raise NSLCMException("Failed to parsernsd of CSAR(%s) from catalog." % csar_id)
return json.JSONDecoder().decode(ret[1])
def parse_vnfd(csar_id, input_parameters=[]):
req_param = json.JSONEncoder().encode({"csarId": csar_id, "inputs": input_parameters})
ret = req_by_msb("/api/catalog/v1/parservnfd", "POST", req_param)
def parse_vnfd(csar_id, input_parameters=[]):
req_param = json.JSONEncoder().encode({"csarId": csar_id, "inputs": input_parameters})
ret = req_by_msb("/api/catalog/v1/parservnfd", "POST", req_param)
import logging
from lcm.pub.exceptions import NSLCMException
import logging
from lcm.pub.exceptions import NSLCMException
-from lcm.pub.utils.restcall import req_by_msb
-from lcm.pub.utils.values import ignore_case_get
from lcm.pub.msapi.extsys import get_vnfm_by_id
from lcm.pub.msapi.extsys import get_vnfm_by_id
+from lcm.pub.utils.restcall import req_by_msb
logger = logging.getLogger(__name__)
logger = logging.getLogger(__name__)
raise NSLCMException('Failed to send nf init request to VNFM(%s)' % vnfm_inst_id)
return json.JSONDecoder().decode(ret[1])
raise NSLCMException('Failed to send nf init request to VNFM(%s)' % vnfm_inst_id)
return json.JSONDecoder().decode(ret[1])
def send_nf_terminate_request(vnfm_inst_id, vnf_inst_id, req_param):
vnfm = get_vnfm_by_id(vnfm_inst_id)
uri = '/api/%s/v1/%s/vnfs/%s/terminate' % (vnfm["type"], vnfm_inst_id, vnf_inst_id)
def send_nf_terminate_request(vnfm_inst_id, vnf_inst_id, req_param):
vnfm = get_vnfm_by_id(vnfm_inst_id)
uri = '/api/%s/v1/%s/vnfs/%s/terminate' % (vnfm["type"], vnfm_inst_id, vnf_inst_id)
raise NSLCMException('Failed to send nf terminate request to VNFM(%s)' % vnfm_inst_id)
return json.JSONDecoder().decode(ret[1]) if ret[1] else {}
raise NSLCMException('Failed to send nf terminate request to VNFM(%s)' % vnfm_inst_id)
return json.JSONDecoder().decode(ret[1]) if ret[1] else {}
def query_vnfm_job(vnfm_inst_id, job_id, response_id=0):
vnfm = get_vnfm_by_id(vnfm_inst_id)
retry_time = 3
def query_vnfm_job(vnfm_inst_id, job_id, response_id=0):
vnfm = get_vnfm_by_id(vnfm_inst_id)
retry_time = 3
- uri = '/api/%s/v1/%s/jobs/%s?responseId=%s' % (vnfm["type"],
- vnfm_inst_id, job_id, response_id)
+ uri = '/api/%s/v1/%s/jobs/%s?responseId=%s' % (vnfm["type"], vnfm_inst_id, job_id, response_id)
while retry_time > 0:
rsp = req_by_msb(uri, "GET")
if str(rsp[2]) == '404':
while retry_time > 0:
rsp = req_by_msb(uri, "GET")
if str(rsp[2]) == '404':
raise NSLCMException('Failed to query job from VNFM!')
return True, json.JSONDecoder().decode(rsp[1])
raise NSLCMException('Failed to query job from VNFM!')
return True, json.JSONDecoder().decode(rsp[1])
def send_nf_scaling_request(vnfm_inst_id, vnf_inst_id, req_param):
vnfm = get_vnfm_by_id(vnfm_inst_id)
uri = '/api/%s/v1/%s/vnfs/%s/scale' % (vnfm["type"], vnfm_inst_id, vnf_inst_id)
def send_nf_scaling_request(vnfm_inst_id, vnf_inst_id, req_param):
vnfm = get_vnfm_by_id(vnfm_inst_id)
uri = '/api/%s/v1/%s/vnfs/%s/scale' % (vnfm["type"], vnfm_inst_id, vnf_inst_id)