2 # ============LICENSE_START===================================================
3 # Copyright (c) 2018 Amdocs. All rights reserved.
4 # ===================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 # use this file except in compliance with the License. You may obtain a copy
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 # License for the specific language governing permissions and limitations under
16 # ============LICENSE_END====================================================
19 from flask import Flask, request, jsonify
20 from flask_autodoc.autodoc import Autodoc
21 from aria import install_aria_extensions
22 from aria.cli.core import aria
23 from aria.utils import threading
24 from aria.orchestrator.workflow_runner import WorkflowRunner
25 from aria.orchestrator.workflows.executor.dry import DryExecutor
29 route_base = "/api/multicloud-azure/" + version_id + "/"
30 app = Flask("onap-aria-rest")
33 execution_state = util.SafeDict()
37 install_aria_extensions()
38 app.run(host='0.0.0.0', port=5000, threaded=True)
44 "services/<service_id>/executions/<workflow_name>",
47 @aria.pass_model_storage
48 @aria.pass_resource_storage
49 @aria.pass_plugin_manager
59 Start an execution for the specified service
61 body = request.json or {}
62 executor = DryExecutor(
63 ) if 'executor' in body and body['executor'] == 'dry' else None
65 inputs = body['inputs'] if 'inputs' in body else None
66 task_max_attempts = (body['task_max_attempts']
67 if 'task_max_attempts' in body else 30)
68 task_retry_interval = (body['task_retry_interval']
69 if 'task_retry_interval' in body else 30)
71 runner = WorkflowRunner(model_storage, resource_storage, plugin_manager,
72 service_id=service_id,
73 workflow_name=workflow_name,
76 task_max_attempts=task_max_attempts,
77 task_retry_interval=task_retry_interval)
79 service = model_storage.service.get(service_id)
80 tname = '{}_{}_{}'.format(service.name, workflow_name, runner.execution_id)
81 thread = threading.ExceptionThread(target=runner.execute,
84 execution_state[str(runner.execution_id)] = [runner, thread]
85 logger.info("execution {} started".format(runner.execution_id))
86 return jsonify({"id": runner.execution_id}), 202
89 if __name__ == "__main__":
90 app.run(host='0.0.0.0', port=5000, threaded=True)