1 # Copyright 2017 ZTE Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 from lcm.pub.exceptions import NSLCMException
17 from lcm.pub.utils import restcall
23 =================================
28 "deployedId": "string",
34 def deploy_workflow(file_path):
35 file_name = file_path.split("/")[-1]
37 'file': open(file_path, 'rb'),
38 'filename': file_name}
39 ret = restcall.upload_by_msb("api/workflow/v1/package", "POST", file_data)
41 raise NSLCMException("Status code is %s, detail is %s.", ret[2], ret[1])
42 return json.JSONDecoder().decode(ret[1])
48 =================================
57 def undeploy_workflow(deploy_id):
58 uri = "api/workflow/v1/package/{deployId}".format(deployId=deploy_id)
59 ret = restcall.req_by_msb(uri, "DELETE")
61 raise NSLCMException("Status code is %s, detail is %s.", ret[2], ret[1])
62 return json.JSONDecoder().decode(ret[1])
68 "processId": "string",
69 "params": "Map<String, String>"
71 =================================
80 def exec_workflow(content):
81 content_str = json.JSONEncoder().encode(content)
82 ret = restcall.req_by_msb("api/workflow/v1/process/instance", "POST", content_str)
84 raise NSLCMException("Status code is %s, detail is %s.", ret[2], ret[1])
85 return json.JSONDecoder().decode(ret[1])