diff options
Diffstat (limited to 'cba/remote-python')
-rw-r--r-- | cba/remote-python/Definitions/remote-python.json | 229 | ||||
-rw-r--r-- | cba/remote-python/Scripts/python/EchoRemotePython.py | 28 | ||||
-rw-r--r-- | cba/remote-python/Scripts/python/FailingRemotePython.py | 30 | ||||
-rw-r--r-- | cba/remote-python/TOSCA-Metadata/TOSCA.meta | 8 |
4 files changed, 295 insertions, 0 deletions
diff --git a/cba/remote-python/Definitions/remote-python.json b/cba/remote-python/Definitions/remote-python.json new file mode 100644 index 0000000..c002e9d --- /dev/null +++ b/cba/remote-python/Definitions/remote-python.json @@ -0,0 +1,229 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-remote-python", + "template_version": "1.0.0", + "template_tags": "Bell, CBA, test" + }, + "dsl_definitions": { + "args": { + "arg0": "remote executor regression" + }, + "remote-executor": { + "type": "token-auth", + "host": .CMD_EXEC_SVC, + "port": "50051", + "token": "Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==" + }, + "remote-executor-wrong-port": { + "type": "token-auth", + "host": "127.0.0.1", + "port": "4242", + "token": "Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==" + } + }, + "topology_template": { + "workflows": { + "remote-python": { + "steps": { + "execute-script": { + "description": "Execute Remote Python Script", + "target": "execute-remote-python" + } + }, + "inputs": { + "input": { + "required": false, + "type": "string" + } + }, + "outputs": { + "execute-command-logs": { + "type": "string", + "value": { + "get_attribute": [ + "execute-remote-python", + "execute-command-logs" + ] + } + }, + "execute-command-payload": { + "type": "json", + "value": { + "get_attribute": [ + "execute-remote-python", + "response-data" + ] + } + } + } + }, + "failing-remote-python": { + "steps": { + "execute-script": { + "description": "Execute Remote Python Script", + "target": "execute-failing-remote-python" + } + }, + "inputs": {}, + "outputs": { + "execute-command-logs": { + "type": "string", + "value": { + "get_attribute": [ + "execute-failing-remote-python", + "execute-command-logs" + ] + } + }, + "execute-command-payload": { + "type": "json", + "value": { + "get_attribute": [ + "execute-failing-remote-python", + "response-data" + ] + } + } + } + }, + "connection-fail": { + "steps": { + "execute-script": { + "description": "Execute Remote Python Script", + "target": "connection-fail" + } + }, + "inputs": {}, + "outputs": { + "execute-command-logs": { + "type": "string", + "value": { + "get_attribute": [ + "connection-fail", + "execute-command-logs" + ] + } + }, + "execute-command-payload": { + "type": "json", + "value": { + "get_attribute": [ + "connection-fail", + "response-data" + ] + } + } + } + } + }, + "node_templates": { + "execute-remote-python": { + "type": "component-remote-python-executor", + "interfaces": { + "ComponentRemotePythonExecutor": { + "operations": { + "process": { + "implementation": { + "primary": "component-script", + "timeout": 180, + "operation_host": "SELF" + }, + "inputs": { + "endpoint-selector": "remote-executor", + "command": "python EchoRemotePython.py", + "argument-properties": "*args", + "packages": [ + { + "type": "pip", + "package": [ + "requests" + ] + } + ] + } + } + } + } + }, + "artifacts": { + "component-script": { + "type": "artifact-script-python", + "file": "Scripts/python/EchoRemotePython.py" + } + } + }, + "execute-failing-remote-python": { + "type": "component-remote-python-executor", + "interfaces": { + "ComponentRemotePythonExecutor": { + "operations": { + "process": { + "implementation": { + "primary": "component-script", + "timeout": 180, + "operation_host": "SELF" + }, + "inputs": { + "endpoint-selector": "remote-executor", + "command": "python FailingRemotePython.py", + "argument-properties": "*args", + "packages": [ + { + "type": "pip", + "package": [ + "requests" + ] + } + ] + } + } + } + } + }, + "artifacts": { + "component-script": { + "type": "artifact-script-python", + "file": "Scripts/python/FailingRemotePython.py" + } + } + }, + "connection-fail": { + "type": "component-remote-python-executor", + "interfaces": { + "ComponentRemotePythonExecutor": { + "operations": { + "process": { + "implementation": { + "primary": "component-script", + "timeout": 180, + "operation_host": "SELF" + }, + "inputs": { + "endpoint-selector": "remote-executor-wrong-port", + "command": "python EchoRemotePython.py", + "argument-properties": "*args", + "packages": [ + { + "type": "pip", + "package": [ + "requests" + ] + } + ] + } + } + } + } + }, + "artifacts": { + "component-script": { + "type": "artifact-script-python", + "file": "Scripts/python/EchoRemotePython.py" + } + } + } + } + } +} diff --git a/cba/remote-python/Scripts/python/EchoRemotePython.py b/cba/remote-python/Scripts/python/EchoRemotePython.py new file mode 100644 index 0000000..5b775f2 --- /dev/null +++ b/cba/remote-python/Scripts/python/EchoRemotePython.py @@ -0,0 +1,28 @@ +#!/usr/bin/python +# +# Copyright © 2020 Bell Canada. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import sys +from cds_utils.payload_coder import send_response_data_payload + +def echo(arg): + print(arg) + +if __name__ == "__main__": + echo(sys.argv[1]) + resp_data = {"abc": ["xyz", "qqq"]} + send_response_data_payload(resp_data) + sys.exit(0) diff --git a/cba/remote-python/Scripts/python/FailingRemotePython.py b/cba/remote-python/Scripts/python/FailingRemotePython.py new file mode 100644 index 0000000..e8a356b --- /dev/null +++ b/cba/remote-python/Scripts/python/FailingRemotePython.py @@ -0,0 +1,30 @@ +#!/usr/bin/python +# +# Copyright © 2020 Bell Canada. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import sys +from cds_utils.payload_coder import send_response_data_payload + +if __name__ == "__main__": + try: + raise Exception("Intentionally raised exception!") + except Exception as e: + print("Intentionally raised exception!") + resp_data = { + "errorMessage": "Intentionally raised exception!" + } + send_response_data_payload(resp_data) + sys.exit(1) diff --git a/cba/remote-python/TOSCA-Metadata/TOSCA.meta b/cba/remote-python/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..85fa3bd --- /dev/null +++ b/cba/remote-python/TOSCA-Metadata/TOSCA.meta @@ -0,0 +1,8 @@ +TOSCA-Meta-File-Version: 1.0.0 +CSAR-Version: 1.0 +Created-By: Selffish +Entry-Definitions: Definitions/remote-python.json +Template-Tags: test, regression +Template-Name: RT-remote-python +Template-Version: 1.0.0 +Template-Type: DEFAULT
\ No newline at end of file |