diff options
Diffstat (limited to 'cds-regression-test/cba')
76 files changed, 4622 insertions, 0 deletions
diff --git a/cds-regression-test/cba/ansible-python-dg/Definitions/ansible-python.json b/cds-regression-test/cba/ansible-python-dg/Definitions/ansible-python.json new file mode 100644 index 0000000..eb39f30 --- /dev/null +++ b/cds-regression-test/cba/ansible-python-dg/Definitions/ansible-python.json @@ -0,0 +1,175 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-ansible-python-dg", + "template_version": "1.0.0", + "template_tags": "Bell, CBA, test" + }, + "dsl_definitions": { + "ansible-remote-endpoint": { + "type": "token-auth", + "url": "http://cds-regression-mockserver/ansible-python-dg/success", + "token": "Bearer J9gEtMDqf7P4YsJ7444fioY9VAhLDIs1" + }, + "remote-executor": { + "type": "token-auth", + "host": "regression-cdsce-cds-ce", + "port": "50051", + "token": "Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==" + } + }, + "topology_template": { + "workflows": { + "run-dg": { + "steps": { + "process": { + "description": "Run ansible then pass artifacts to command executor", + "target": "execute-dg", + "activities": [ + { + "call_operation": "" + } + ] + } + }, + "inputs": { + "endpoint-selector": { + "required": true, + "type": "string" + }, + "job-template-name": { + "required": true, + "type": "string" + }, + "limit": { + "required": false, + "type": "string" + }, + "inventory": { + "required": false, + "type": "string" + }, + "tags": { + "required": false, + "type": "string" + }, + "skip-tags": { + "required": false, + "type": "string" + }, + "extra-vars": { + "required": false, + "type": "json" + } + }, + "outputs": { + "execute-command-logs": { + "type": "string", + "value": { + "get_attribute": [ + "python", + "execute-command-logs" + ] + } + } + } + } + }, + "node_templates": { + "execute-dg": { + "type": "dg-generic", + "properties": { + "content": { + "get_artifact": [ + "SELF", + "dg" + ] + }, + "dependency-node-templates": [ + "ansible", + "python" + ] + }, + "artifacts": { + "dg": { + "type": "artifact-directed-graph", + "file": "Plans/ansible-python-dg.xml" + } + } + }, + "ansible": { + "type": "component-remote-ansible-executor", + "interfaces": { + "ComponentRemoteAnsibleExecutor": { + "operations": { + "process": { + "inputs": { + "endpoint-selector": "*ansible-remote-endpoint", + "job-template-name": { + "get_input": "job-template-name" + }, + "limit": { + "get_input": "limit" + }, + "inventory": { + "get_input": "inventory" + }, + "extra-vars": { + "get_input": "extra-vars" + }, + "tags": { + "get_input": "tags" + }, + "skip-tags": { + "get_input": "skip-tags" + } + } + } + } + } + } + }, + "python": { + "type": "component-remote-python-executor", + "interfaces": { + "ComponentRemotePythonExecutor": { + "operations": { + "process": { + "implementation": { + "primary": "component-script", + "timeout": 1800, + "operation_host": "SELF" + }, + "inputs": { + "endpoint-selector": "remote-executor", + "command": "python rt-python.py", + "dynamic-properties": { + "get_attribute": [ + "ansible", + "ansible-artifacts" + ] + }, + "packages": [ + { + "type": "pip", + "package": [ + "requests" + ] + } + ] + } + } + } + } + }, + "artifacts": { + "component-script": { + "type": "artifact-script-python", + "file": "Scripts/rt-python.py" + } + } + } + } + } +} diff --git a/cds-regression-test/cba/ansible-python-dg/Plans/ansible-python-dg.xml b/cds-regression-test/cba/ansible-python-dg/Plans/ansible-python-dg.xml new file mode 100644 index 0000000..e00f17a --- /dev/null +++ b/cds-regression-test/cba/ansible-python-dg/Plans/ansible-python-dg.xml @@ -0,0 +1,27 @@ +<service-logic + xmlns='http://www.onap.org/sdnc/svclogic' + xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' + xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='CONFIG' version='1.0.0'> + <method rpc='AnsiblePython' mode='sync'> + <block atomic="true"> + <execute plugin="ansible" method="process"> + <outcome value='failure'> + <return status="failure"> + </return> + </outcome> + <outcome value='success'> + <execute plugin="python" method="process"> + <outcome value='failure'> + <return status="failure"> + </return> + </outcome> + <outcome value='success'> + <return status='success'> + </return> + </outcome> + </execute> + </outcome> + </execute> + </block> + </method> +</service-logic>
\ No newline at end of file diff --git a/cds-regression-test/cba/ansible-python-dg/Scripts/rt-python.py b/cds-regression-test/cba/ansible-python-dg/Scripts/rt-python.py new file mode 100644 index 0000000..76af364 --- /dev/null +++ b/cds-regression-test/cba/ansible-python-dg/Scripts/rt-python.py @@ -0,0 +1,11 @@ +#!/usr/bin/python + +import sys +import json + + +if __name__ == "__main__": + ansibleArtifacts = json.loads(sys.argv[1]) + interfaceName = ansibleArtifacts["topology"]["tor-8.tenlab-cloud"][0]["interface_name"] + print(interfaceName) + sys.exit(0) diff --git a/cds-regression-test/cba/ansible-python-dg/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/ansible-python-dg/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..844f38b --- /dev/null +++ b/cds-regression-test/cba/ansible-python-dg/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/ansible-python.json +Template-Tags: test, regression +Template-Name: RT-ansible-python-dg +Template-Version: 1.0.0 +Template-Type: DEFAULT diff --git a/cds-regression-test/cba/cba/ansible-python-dg/Definitions/ansible-python.json b/cds-regression-test/cba/cba/ansible-python-dg/Definitions/ansible-python.json new file mode 100644 index 0000000..eb39f30 --- /dev/null +++ b/cds-regression-test/cba/cba/ansible-python-dg/Definitions/ansible-python.json @@ -0,0 +1,175 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-ansible-python-dg", + "template_version": "1.0.0", + "template_tags": "Bell, CBA, test" + }, + "dsl_definitions": { + "ansible-remote-endpoint": { + "type": "token-auth", + "url": "http://cds-regression-mockserver/ansible-python-dg/success", + "token": "Bearer J9gEtMDqf7P4YsJ7444fioY9VAhLDIs1" + }, + "remote-executor": { + "type": "token-auth", + "host": "regression-cdsce-cds-ce", + "port": "50051", + "token": "Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==" + } + }, + "topology_template": { + "workflows": { + "run-dg": { + "steps": { + "process": { + "description": "Run ansible then pass artifacts to command executor", + "target": "execute-dg", + "activities": [ + { + "call_operation": "" + } + ] + } + }, + "inputs": { + "endpoint-selector": { + "required": true, + "type": "string" + }, + "job-template-name": { + "required": true, + "type": "string" + }, + "limit": { + "required": false, + "type": "string" + }, + "inventory": { + "required": false, + "type": "string" + }, + "tags": { + "required": false, + "type": "string" + }, + "skip-tags": { + "required": false, + "type": "string" + }, + "extra-vars": { + "required": false, + "type": "json" + } + }, + "outputs": { + "execute-command-logs": { + "type": "string", + "value": { + "get_attribute": [ + "python", + "execute-command-logs" + ] + } + } + } + } + }, + "node_templates": { + "execute-dg": { + "type": "dg-generic", + "properties": { + "content": { + "get_artifact": [ + "SELF", + "dg" + ] + }, + "dependency-node-templates": [ + "ansible", + "python" + ] + }, + "artifacts": { + "dg": { + "type": "artifact-directed-graph", + "file": "Plans/ansible-python-dg.xml" + } + } + }, + "ansible": { + "type": "component-remote-ansible-executor", + "interfaces": { + "ComponentRemoteAnsibleExecutor": { + "operations": { + "process": { + "inputs": { + "endpoint-selector": "*ansible-remote-endpoint", + "job-template-name": { + "get_input": "job-template-name" + }, + "limit": { + "get_input": "limit" + }, + "inventory": { + "get_input": "inventory" + }, + "extra-vars": { + "get_input": "extra-vars" + }, + "tags": { + "get_input": "tags" + }, + "skip-tags": { + "get_input": "skip-tags" + } + } + } + } + } + } + }, + "python": { + "type": "component-remote-python-executor", + "interfaces": { + "ComponentRemotePythonExecutor": { + "operations": { + "process": { + "implementation": { + "primary": "component-script", + "timeout": 1800, + "operation_host": "SELF" + }, + "inputs": { + "endpoint-selector": "remote-executor", + "command": "python rt-python.py", + "dynamic-properties": { + "get_attribute": [ + "ansible", + "ansible-artifacts" + ] + }, + "packages": [ + { + "type": "pip", + "package": [ + "requests" + ] + } + ] + } + } + } + } + }, + "artifacts": { + "component-script": { + "type": "artifact-script-python", + "file": "Scripts/rt-python.py" + } + } + } + } + } +} diff --git a/cds-regression-test/cba/cba/ansible-python-dg/Plans/ansible-python-dg.xml b/cds-regression-test/cba/cba/ansible-python-dg/Plans/ansible-python-dg.xml new file mode 100644 index 0000000..e00f17a --- /dev/null +++ b/cds-regression-test/cba/cba/ansible-python-dg/Plans/ansible-python-dg.xml @@ -0,0 +1,27 @@ +<service-logic + xmlns='http://www.onap.org/sdnc/svclogic' + xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' + xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='CONFIG' version='1.0.0'> + <method rpc='AnsiblePython' mode='sync'> + <block atomic="true"> + <execute plugin="ansible" method="process"> + <outcome value='failure'> + <return status="failure"> + </return> + </outcome> + <outcome value='success'> + <execute plugin="python" method="process"> + <outcome value='failure'> + <return status="failure"> + </return> + </outcome> + <outcome value='success'> + <return status='success'> + </return> + </outcome> + </execute> + </outcome> + </execute> + </block> + </method> +</service-logic>
\ No newline at end of file diff --git a/cds-regression-test/cba/cba/ansible-python-dg/Scripts/rt-python.py b/cds-regression-test/cba/cba/ansible-python-dg/Scripts/rt-python.py new file mode 100644 index 0000000..76af364 --- /dev/null +++ b/cds-regression-test/cba/cba/ansible-python-dg/Scripts/rt-python.py @@ -0,0 +1,11 @@ +#!/usr/bin/python + +import sys +import json + + +if __name__ == "__main__": + ansibleArtifacts = json.loads(sys.argv[1]) + interfaceName = ansibleArtifacts["topology"]["tor-8.tenlab-cloud"][0]["interface_name"] + print(interfaceName) + sys.exit(0) diff --git a/cds-regression-test/cba/cba/ansible-python-dg/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/cba/ansible-python-dg/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..844f38b --- /dev/null +++ b/cds-regression-test/cba/cba/ansible-python-dg/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/ansible-python.json +Template-Tags: test, regression +Template-Name: RT-ansible-python-dg +Template-Version: 1.0.0 +Template-Type: DEFAULT diff --git a/cds-regression-test/cba/cba/cli/elalto/Definitions/cli.json b/cds-regression-test/cba/cba/cli/elalto/Definitions/cli.json new file mode 100644 index 0000000..722663e --- /dev/null +++ b/cds-regression-test/cba/cba/cli/elalto/Definitions/cli.json @@ -0,0 +1,106 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-cli", + "template_version": "1.0.0", + "template_tags": "test, regression" + }, + "dsl_definitions": { + "device-properties": { + "type": "basic-auth", + "host": { + "get_input": "host" + }, + "username": { + "get_input": "username" + }, + "password": { + "get_input": "password" + }, + "port": { + "get_input": "port" + }, + "connectionTimeOut": { + "get_input": "connectionTimeOut" + } + } + }, + "topology_template": { + "workflows": { + "cli": { + "steps": { + "cli": { + "description": "CLI Workflow", + "target": "cli" + } + }, + "inputs": { + "resolution-key": { + "required": false, + "type": "string" + }, + "password": { + "required": true, + "type": "string" + }, + "username": { + "required": true, + "type": "string" + }, + "host": { + "required": true, + "type": "string" + }, + "port": { + "required": false, + "type": "string" + }, + "connectionTimeOut": { + "required": true, + "type": "string" + }, + "commands": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "outputs": { + "response-data": { + "type": "string", + "value": { + "get_attribute": [ + "cli", + "response-data" + ] + } + } + } + } + }, + "node_templates": { + "cli": { + "type": "component-script-executor", + "interfaces": { + "ComponentScriptExecutor": { + "operations": { + "process": { + "implementation": { + "primary": "component-script" + }, + "inputs": { + "script-type": "kotlin", + "script-class-reference": "cli.CliRegressionTest" + }, + "outputs": {} + } + } + } + } + } + } + } +} diff --git a/cds-regression-test/cba/cba/cli/elalto/Scripts/kotlin/cli/cli.kt b/cds-regression-test/cba/cba/cli/elalto/Scripts/kotlin/cli/cli.kt new file mode 100755 index 0000000..12786c8 --- /dev/null +++ b/cds-regression-test/cba/cba/cli/elalto/Scripts/kotlin/cli/cli.kt @@ -0,0 +1,59 @@ +/*
+ * Copyright © 2019 IBM, 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.
+ */
+
+package cli
+
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.cli.executor.cliDeviceInfo
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.cli.executor.getSshClientService
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+
+
+open class CliRegressionTest : AbstractScriptComponentFunction() {
+
+ private val log = logger(CliRegressionTest::class)
+
+ override suspend fun processNB(executionRequest: ExecutionServiceInput) {
+ // Get Client Service
+ val sshClientService = getSshClientService(cliDeviceInfo("device-properties"))
+ sshClientService.startSession()
+
+ // Read Commands
+ val timeout = bluePrintRuntimeService.getInputValue("connectionTimeOut").asText()
+ val commands = bluePrintRuntimeService.getInputValue("commands")
+ .let { JacksonUtils.getListFromJsonNode(it, String::class.java) }
+
+ // Execute
+ var responsesLog = "Error"
+ try {
+ responsesLog = sshClientService.executeCommands(commands, timeout.toLong())
+ log.info(responsesLog)
+ } catch (e: Exception) {
+ e.message?.let { addError(it) }
+ } finally {
+ setAttribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, responsesLog.asJsonPrimitive())
+ sshClientService.closeSession()
+ }
+ }
+
+ override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ log.info("Executing Recovery")
+ }
+}
\ No newline at end of file diff --git a/cds-regression-test/cba/cba/cli/elalto/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/cba/cli/elalto/TOSCA-Metadata/TOSCA.meta new file mode 100755 index 0000000..7bb2d45 --- /dev/null +++ b/cds-regression-test/cba/cba/cli/elalto/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/cli.json +Template-Tags: test, regression +Template-Name: RT-cli +Template-Version: 1.0.0 +Template-Type: DEFAULT
\ No newline at end of file diff --git a/cds-regression-test/cba/cba/cli/frankfurt/Definitions/cli.json b/cds-regression-test/cba/cba/cli/frankfurt/Definitions/cli.json new file mode 100644 index 0000000..c0070da --- /dev/null +++ b/cds-regression-test/cba/cba/cli/frankfurt/Definitions/cli.json @@ -0,0 +1,113 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-cli", + "template_version": "1.0.0", + "template_tags": "test, regression" + }, + "dsl_definitions": { + "device-properties": { + "type": "basic-auth", + "host": { + "get_input": "host" + }, + "username": { + "get_input": "username" + }, + "password": { + "get_input": "password" + }, + "port": { + "get_input": "port" + }, + "logging": { + "get_input": "logging" + }, + "connectionTimeOut": { + "get_input": "connectionTimeOut" + } + } + }, + "topology_template": { + "workflows": { + "cli": { + "steps": { + "cli": { + "description": "CLI Workflow", + "target": "cli" + } + }, + "inputs": { + "resolution-key": { + "required": false, + "type": "string" + }, + "password": { + "required": true, + "type": "string" + }, + "username": { + "required": true, + "type": "string" + }, + "host": { + "required": true, + "type": "string" + }, + "port": { + "required": false, + "type": "string" + }, + "connectionTimeOut": { + "required": true, + "type": "string" + }, + "logging": { + "required": true, + "type": "boolean" + }, + "commands": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "outputs": { + "response-data": { + "type": "string", + "value": { + "get_attribute": [ + "cli", + "response-data" + ] + } + } + } + } + }, + "node_templates": { + "cli": { + "type": "component-script-executor", + "interfaces": { + "ComponentScriptExecutor": { + "operations": { + "process": { + "implementation": { + "primary": "component-script" + }, + "inputs": { + "script-type": "kotlin", + "script-class-reference": "cli.CliRegressionTest" + }, + "outputs": {} + } + } + } + } + } + } + } +} diff --git a/cds-regression-test/cba/cba/cli/frankfurt/Scripts/kotlin/cli/cli.kt b/cds-regression-test/cba/cba/cli/frankfurt/Scripts/kotlin/cli/cli.kt new file mode 100755 index 0000000..1e1ade0 --- /dev/null +++ b/cds-regression-test/cba/cba/cli/frankfurt/Scripts/kotlin/cli/cli.kt @@ -0,0 +1,59 @@ +/* + * Copyright © 2019 IBM, 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. + */ + +package cli + +import org.onap.ccsdk.cds.controllerblueprints.core.logger +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.functions.cli.executor.cliDeviceInfo +import org.onap.ccsdk.cds.blueprintsprocessor.functions.cli.executor.getSshClientService +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor +import org.onap.ccsdk.cds.blueprintsprocessor.ssh.service.CommandResult +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType + +open class CliRegressionTest : AbstractScriptComponentFunction() { + + private val log = logger(CliRegressionTest::class) + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + // Get Client Service + val sshClientService = getSshClientService(cliDeviceInfo("device-properties")) + sshClientService.startSession() + + // Read Commands + val timeout = bluePrintRuntimeService.getInputValue("connectionTimeOut").asText() + val commands = bluePrintRuntimeService.getInputValue("commands") + .let { JacksonUtils.getListFromJsonNode(it, String::class.java) } + + // Execute + var responsesLog: List<CommandResult>? = null + try { + responsesLog = sshClientService.executeCommands(commands, timeout.toLong()) + log.info(responsesLog.toString()) + } catch (e: Exception) { + e.message?.let { addError(it) } + } finally { + setAttribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, responsesLog?.map { it->it.asJsonType()}.asJsonType()) + sshClientService.closeSession() + } + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Executing Recovery") + } +} diff --git a/cds-regression-test/cba/cba/cli/frankfurt/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/cba/cli/frankfurt/TOSCA-Metadata/TOSCA.meta new file mode 100755 index 0000000..7bb2d45 --- /dev/null +++ b/cds-regression-test/cba/cba/cli/frankfurt/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/cli.json +Template-Tags: test, regression +Template-Name: RT-cli +Template-Version: 1.0.0 +Template-Type: DEFAULT
\ No newline at end of file diff --git a/cds-regression-test/cba/cba/lock-device/Definitions/lock-device.json b/cds-regression-test/cba/cba/lock-device/Definitions/lock-device.json new file mode 100644 index 0000000..c90021c --- /dev/null +++ b/cds-regression-test/cba/cba/lock-device/Definitions/lock-device.json @@ -0,0 +1,98 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-lock-device", + "template_version": "1.0.0", + "template_tags": "Bell, CBA, test" + }, + "dsl_definitions": {}, + "topology_template": { + "workflows": { + "resolve-deploy-kotlin": { + "steps": { + "resolve": { + "description": "resolve vnf-id", + "target": "resource-resolution", + "on_success": [ + "execute-script" + ] + }, + "execute-script": { + "description": "Execute Kotlin Script", + "target": "execute-kotlin" + } + }, + "outputs": { + "response-data": { + "type": "string", + "value": { + "get_attribute": [ + "execute-kotlin", + "response-data" + ] + } + } + } + } + }, + "node_templates": { + "resource-resolution": { + "type": "component-resource-resolution", + "interfaces": { + "ResourceResolutionComponent": { + "operations": { + "process": { + "inputs": { + "artifact-prefix-names": [ + "base" + ], + "resolution-summary": true + } + } + } + } + }, + "artifacts": { + "base-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/base-mapping.json" + } + } + }, + "execute-kotlin": { + "type": "component-script-executor", + "interfaces": { + "ComponentScriptExecutor": { + "operations": { + "process": { + "implementation": { + "primary": "component-script", + "lock": { + "key": { + "get_attribute": [ + "resource-resolution", + "", + "assignment-map", + "base", + "vnf-id" + ] + }, + "acquireTimeout": { + "get_input": "lock-acquire-timeout" + } + } + }, + "inputs": { + "script-type": "kotlin", + "script-class-reference": "cba.cds.RT.ProcessOperation" + }, + "outputs": {} + } + } + } + } + } + } + } +} diff --git a/cds-regression-test/cba/cba/lock-device/Scripts/kotlin/ProcessOperation.kt b/cds-regression-test/cba/cba/lock-device/Scripts/kotlin/ProcessOperation.kt new file mode 100755 index 0000000..4c795e4 --- /dev/null +++ b/cds-regression-test/cba/cba/lock-device/Scripts/kotlin/ProcessOperation.kt @@ -0,0 +1,49 @@ +/* + * Copyright © 2019 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. + */ + +package cba.cds.RT + +import org.onap.ccsdk.cds.controllerblueprints.core.logger +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService +import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties +import kotlinx.coroutines.delay + +open class ProcessOperation : AbstractScriptComponentFunction() { + + private val log = logger(ProcessOperation::class) + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + val time : Long = 15_000 + try { + log.info("Processing for $time ms... ${executionRequest.commonHeader.requestId}") + delay(time) + log.info("Done processing ${executionRequest.commonHeader.requestId}!") + setAttribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, "Success: ${executionRequest.commonHeader.requestId}".asJsonType()) + } catch (e: Exception) { + e.message?.let { addError(it) } + } + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + setAttribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, runtimeException.message!!.asJsonType()) + addError(runtimeException.message!!) + log.info("Executing Recovery") + } +} diff --git a/cds-regression-test/cba/cba/lock-device/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/cba/lock-device/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..e182865 --- /dev/null +++ b/cds-regression-test/cba/cba/lock-device/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/lock-device.json +Template-Tags: test, regression +Template-Name: RT-lock-device +Template-Version: 1.0.0 +Template-Type: DEFAULT
\ No newline at end of file diff --git a/cds-regression-test/cba/cba/lock-device/Templates/base-mapping.json b/cds-regression-test/cba/cba/lock-device/Templates/base-mapping.json new file mode 100644 index 0000000..b5b64a8 --- /dev/null +++ b/cds-regression-test/cba/cba/lock-device/Templates/base-mapping.json @@ -0,0 +1,23 @@ +[ + { + "name": "vnf-id", + "input-param": true, + "property": { + "type": "string", + "default": "rt-vnf-xyz-123" + }, + "dictionary-name": "input-source", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "lock-acquire-timeout", + "input-param": true, + "property": { + "type": "integer" + }, + "dictionary-name": "input-source", + "dictionary-source": "input", + "dependencies": [] + } +] diff --git a/cds-regression-test/cba/cba/netconf/Definitions/netconf.json b/cds-regression-test/cba/cba/netconf/Definitions/netconf.json new file mode 100644 index 0000000..74a98c1 --- /dev/null +++ b/cds-regression-test/cba/cba/netconf/Definitions/netconf.json @@ -0,0 +1,137 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-netconf", + "template_version": "1.0.0", + "template_tags": "Bell, CBA, test" + }, + "topology_template": { + "workflows": { + "netconf-jython": { + "steps": { + "netconf-jython": { + "description": "deploy config", + "target": "execute-jython-netconf" + } + }, + "inputs": { + "netconf-host": { + "required": true, + "type": "string" + }, + "netconf-timeout": { + "required": true, + "type": "string" + } + }, + "outputs": { + "response-data": { + "type": "string", + "value": { + "get_attribute": [ + "execute-jython-netconf", + "response-data" + ] + } + } + } + }, + "netconf-kotlin": { + "steps": { + "netconf-kotlin": { + "description": "deploy config", + "target": "execute-kotlin-netconf" + } + }, + "inputs": { + "netconf-host": { + "required": true, + "type": "string" + }, + "netconf-timeout": { + "required": true, + "type": "string" + } + }, + "outputs": { + "response-data": { + "type": "string", + "value": { + "get_attribute": [ + "execute-kotlin-netconf", + "response-data" + ] + } + } + } + } + }, + "node_templates": { + "execute-jython-netconf": { + "type": "component-netconf-executor", + "requirements": { + "netconf-connection": { + "capability": "netconf", + "node": "netconf-device", + "relationship": "tosca.relationships.ConnectsTo" + } + }, + "interfaces": { + "ComponentNetconfExecutor": { + "operations": { + "process": { + "inputs": { + "script-type": "jython", + "script-class-reference": "Scripts/python/NetconfTest.py", + "instance-dependencies": [] + } + } + } + } + } + }, + "execute-kotlin-netconf": { + "type": "component-netconf-executor", + "requirements": { + "netconf-connection": { + "capability": "netconf", + "node": "netconf-device", + "relationship": "tosca.relationships.ConnectsTo" + } + }, + "interfaces": { + "ComponentNetconfExecutor": { + "operations": { + "process": { + "inputs": { + "script-type": "kotlin", + "script-class-reference": "org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.ConfigDeploy", + "instance-dependencies": [] + } + } + } + } + } + }, + "netconf-device": { + "type": "vnf-netconf-device", + "capabilities": { + "netconf": { + "properties": { + "login-key": "password", + "login-account": "admin", + "target-ip-address": { + "get_input": "netconf-host" + }, + "port-number": 17830, + "connection-time-out": { + "get_input": "netconf-timeout" + } + } + } + } + } + } + } +} diff --git a/cds-regression-test/cba/cba/netconf/Scripts/kotlin/kotlin.kt b/cds-regression-test/cba/cba/netconf/Scripts/kotlin/kotlin.kt new file mode 100644 index 0000000..956890a --- /dev/null +++ b/cds-regression-test/cba/cba/netconf/Scripts/kotlin/kotlin.kt @@ -0,0 +1,47 @@ +package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor + +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifactNB +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils +import org.slf4j.LoggerFactory + +open class ConfigDeploy : AbstractScriptComponentFunction() { + + private val log = LoggerFactory.getLogger(ConfigDeploy::class.java)!! + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + val device = netconfDevice("netconf-connection") + val client = device.netconfRpcService + val session = device.netconfSession + + val payload=""" + <configuration xmlns:junos="http://xml.juniper.net/junos/17.4R1/junos"> + <system xmlns="http://yang.juniper.net/junos-qfx/conf/system"> + <host-name operation="delete" /> + <host-name operation="create">Regression-Mock</host-name> + </system> + </configuration> + """ + + val response: MutableMap<String, Boolean> = mutableMapOf("deploySuccess" to false) + + try { + session.connect() + client.lock() + client.editConfig(payload) + client.commit() + client.unLock() + session.disconnect() + response["deploySuccess"] = true + } catch (e: Exception) { + e.message?.let { super.addError(it) } + } + + super.setAttribute("response-data", JacksonUtils.jsonNodeFromObject(response)) + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Executing Recovery") + } +} diff --git a/cds-regression-test/cba/cba/netconf/Scripts/python/NetconfTest.py b/cds-regression-test/cba/cba/netconf/Scripts/python/NetconfTest.py new file mode 100644 index 0000000..7b743d6 --- /dev/null +++ b/cds-regression-test/cba/cba/netconf/Scripts/python/NetconfTest.py @@ -0,0 +1,53 @@ +# Copyright (c) 2019 IBM, 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 netconf_constant +from java.lang import Exception as JavaException +from netconfclient import NetconfClient +import json +from org.onap.ccsdk.cds.blueprintsprocessor.services.execution import AbstractScriptComponentFunction + +class NetconfTest(AbstractScriptComponentFunction): + + def process(self): + log = globals()[netconf_constant.SERVICE_LOG] + payload=""" + <configuration xmlns:junos="http://xml.juniper.net/junos/17.4R1/junos"> + <system xmlns="http://yang.juniper.net/junos-qfx/conf/system"> + <host-name operation="delete" /> + <host-name operation="create">Regression-Mock</host-name> + </system> + </configuration> + """ + responsePayload = '{"deploySuccess": false}' + print(responsePayload) + + try: + nc = NetconfClient(log, self, "netconf-connection") + nc.connect() + nc.lock() + nc.edit_config(message_content=payload, config_target="candidate") + operationResponse = nc.commit() + nc.unlock() + nc.disconnect() + responsePayload = json.dumps({"deploySuccess": operationResponse.isSuccess()}) + except JavaException as err: + self.addError(err.message) + except Exception as err: + self.addError("Python error: {}".format(err)) + + # self.setAttribute("response-data", ObjectMapper().readTree(responsePayload)) + return None + + def recover(self): + return None diff --git a/cds-regression-test/cba/cba/netconf/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/cba/netconf/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..1155ae8 --- /dev/null +++ b/cds-regression-test/cba/cba/netconf/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/netconf.json +Template-Tags: test, regression +Template-Name: RT-netconf +Template-Version: 1.0.0 +Template-Type: DEFAULT
\ No newline at end of file diff --git a/cds-regression-test/cba/cba/py-executor/.DS_Store b/cds-regression-test/cba/cba/py-executor/.DS_Store Binary files differnew file mode 100644 index 0000000..5008ddf --- /dev/null +++ b/cds-regression-test/cba/cba/py-executor/.DS_Store diff --git a/cds-regression-test/cba/cba/py-executor/Definitions/py-executor.json b/cds-regression-test/cba/cba/py-executor/Definitions/py-executor.json new file mode 100644 index 0000000..b28162c --- /dev/null +++ b/cds-regression-test/cba/cba/py-executor/Definitions/py-executor.json @@ -0,0 +1,174 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-py-executor", + "template_version": "1.0.0", + "template_tags": "Bell, CBA, test" + }, + "dsl_definitions": { + "py-executor": { + "type": "tls-auth", + "host": "cds-py-executor-py-exec", + "port": "50052", + "trustCertCollection": "/opt/app/onap/config/certs/py-executor/py-executor-chain.pem" + }, + "invalid-py-executor": { + "type": "tls-auth", + "host": "127.0.0.1", + "port": "12345", + "trustCertCollection": "/opt/app/onap/config/certs/py-executor/py-executor-chain.pem" + }, + "parameters": { + "hello": "world" + } + }, + "topology_template": { + "workflows": { + "remote-python": { + "steps": { + "execute-script": { + "description": "Execute Remote Python Script", + "target": "execute-remote-python" + } + }, + "inputs": {}, + "outputs": { + "status": { + "type": "string", + "value": { + "get_attribute": [ + "execute-remote-python", + "status" + ] + } + }, + "response-data": { + "type": "json", + "value": { + "get_attribute": [ + "execute-remote-python", + "response-data" + ] + } + } + } + }, + "connection-fail": { + "steps": { + "execute-script": { + "description": "Execute Remote Python Script to an invalid endpoint", + "target": "execute-connection-fail" + } + }, + "inputs": {}, + "outputs": { + "status": { + "type": "string", + "value": { + "get_attribute": [ + "execute-connection-fail", + "status" + ] + } + }, + "response-data": { + "type": "json", + "value": { + "get_attribute": [ + "execute-connection-fail", + "response-data" + ] + } + } + } + }, + "failing-remote-python": { + "steps": { + "execute-script": { + "description": "Execute Remote Python Script", + "target": "execute-failing-remote-python" + } + }, + "inputs": {}, + "outputs": { + "status": { + "type": "string", + "value": { + "get_attribute": [ + "execute-failing-remote-python", + "status" + ] + } + }, + "response-data": { + "type": "json", + "value": { + "get_attribute": [ + "execute-failing-remote-python", + "response-data" + ] + } + } + } + } + }, + "node_templates": { + "execute-remote-python": { + "type": "component-remote-script-executor", + "interfaces": { + "ComponentRemoteScriptExecutor": { + "operations": { + "process": { + "inputs": { + "selector": "*py-executor", + "blueprint-name": "RT-py-executor", + "blueprint-version": "1.0.0", + "blueprint-action": "HelloWorld", + "timeout": 1000, + "request-data": "*parameters" + } + } + } + } + } + }, + "execute-connection-fail": { + "type": "component-remote-script-executor", + "interfaces": { + "ComponentRemoteScriptExecutor": { + "operations": { + "process": { + "inputs": { + "selector": "*invalid-py-executor", + "blueprint-name": "RT-py-executor", + "blueprint-version": "1.0.0", + "blueprint-action": "HelloWorld", + "timeout": 1000 + } + } + } + } + } + }, + "execute-failing-remote-python": { + "type": "component-remote-script-executor", + "interfaces": { + "ComponentRemoteScriptExecutor": { + "operations": { + "process": { + "inputs": { + "selector": "*py-executor", + "blueprint-name": "RT-py-executor", + "blueprint-version": "1.0.0", + "blueprint-action": "FailingScript", + "timeout": 1000 + } + } + } + } + } + } + } + } +} diff --git a/cds-regression-test/cba/cba/py-executor/Scripts/python/__init__.py b/cds-regression-test/cba/cba/py-executor/Scripts/python/__init__.py new file mode 100644 index 0000000..dcef3a9 --- /dev/null +++ b/cds-regression-test/cba/cba/py-executor/Scripts/python/__init__.py @@ -0,0 +1,16 @@ +# Copyright © 2018-2019 AT&T Intellectual Property. +# +# 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. + +from .hello_world import * +from .failing_script import * diff --git a/cds-regression-test/cba/cba/py-executor/Scripts/python/failing_script.py b/cds-regression-test/cba/cba/py-executor/Scripts/python/failing_script.py new file mode 100644 index 0000000..66efd3f --- /dev/null +++ b/cds-regression-test/cba/cba/py-executor/Scripts/python/failing_script.py @@ -0,0 +1,34 @@ +#!/usr/bin/python +# +# Copyright © 2018-2019 AT&T Intellectual Property. +# +# 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 logging +from blueprints_grpc import executor_utils +from blueprints_grpc.blueprint_processing_server import AbstractScriptFunction + + +class FailingScript(AbstractScriptFunction): + def __init__(self): + self.logger = logging.getLogger(self.__class__.__name__) + + def process(self, execution_request): + self.logger.info("Request Received in Script : {}".format(execution_request)) + raise RuntimeError('Script raised an exception') + + def recover(self): + return None + + def send_notification(self, execution_request): + yield executor_utils.send_notification(execution_request, "I am notification") diff --git a/cds-regression-test/cba/cba/py-executor/Scripts/python/hello_world.py b/cds-regression-test/cba/cba/py-executor/Scripts/python/hello_world.py new file mode 100644 index 0000000..1d308ee --- /dev/null +++ b/cds-regression-test/cba/cba/py-executor/Scripts/python/hello_world.py @@ -0,0 +1,41 @@ +#!/usr/bin/python +# +# Copyright © 2018-2019 AT&T Intellectual Property. +# +# 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 logging +from blueprints_grpc import executor_utils +from blueprints_grpc.blueprint_processing_server import AbstractScriptFunction +import json +from google.protobuf import json_format + +class HelloWorld(AbstractScriptFunction): + def __init__(self): + self.logger = logging.getLogger(self.__class__.__name__) + + def process(self, execution_request): + self.logger.info("Request Received in Script : {}".format(execution_request)) + + inputs = json_format.MessageToJson(execution_request.payload) + response_payload_json = json.loads(inputs) + + execution_response = executor_utils.success_response(execution_request, response_payload_json, 200) + self.logger.info("Response returned : {}".format(execution_response)) + yield execution_response + + def recover(self): + return None + + def send_notification(self, execution_request): + yield executor_utils.send_notification(execution_request, "I am notification") diff --git a/cds-regression-test/cba/cba/py-executor/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/cba/py-executor/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..8389ebb --- /dev/null +++ b/cds-regression-test/cba/cba/py-executor/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/py-executor.json +Template-Tags: test, regression +Template-Name: RT-py-executor +Template-Version: 1.0.0 +Template-Type: DEFAULT diff --git a/cds-regression-test/cba/cba/remote-ansible/Definitions/remote-ansible.json b/cds-regression-test/cba/cba/remote-ansible/Definitions/remote-ansible.json new file mode 100644 index 0000000..ee0d466 --- /dev/null +++ b/cds-regression-test/cba/cba/remote-ansible/Definitions/remote-ansible.json @@ -0,0 +1,317 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-remote-ansible", + "template_version": "1.0.0", + "template_tags": "Bell, CBA, test" + }, + "dsl_definitions": { + "ansible-remote-success-endpoint": { + "type": "token-auth", + "url": "http://cds-regression-mockserver/remote-ansible/success", + "token": "Bearer J9gEtMDqf7P4YsJ7444fioY9VAhLDIs1" + }, + "ansible-remote-failure-endpoint": { + "type": "token-auth", + "url": "http://cds-regression-mockserver/remote-ansible/failure", + "token": "Bearer J9gEtMDqf7P4YsJ7444fioY9VAhLDIs1" + }, + "ansible-remote-invalid-endpoint": { + "type": "token-auth", + "url": "http://localhost:12345", + "token": "Bearer J9gEtMDqf7P4YsJ7444fioY9VAhLDIs1" + } + }, + "topology_template": { + "workflows": { + "execute-remote-ansible-success": { + "steps": { + "process": { + "description": "Execute Remote Ansible Script", + "target": "execute-remote-ansible-success", + "activities": [ + { + "call_operation": "" + } + ] + } + }, + "inputs": { + "endpoint-selector": { + "required": true, + "type": "string" + }, + "job-template-name": { + "required": true, + "type": "string" + }, + "limit": { + "required": false, + "type": "string" + }, + "inventory": { + "required": false, + "type": "string" + }, + "tags": { + "required": false, + "type": "string" + }, + "skip-tags": { + "required": false, + "type": "string" + }, + "extra-vars": { + "required": false, + "type": "json" + } + }, + "outputs": { + "ansible-command-status": { + "type": "string", + "value": { + "get_attribute": [ + "execute-remote-ansible-success", + "ansible-command-status" + ] + } + }, + "ansible-command-logs": { + "type": "string", + "value": { + "get_attribute": [ + "execute-remote-ansible-success", + "ansible-command-logs" + ] + } + } + } + }, + "connection-fail": { + "steps": { + "process": { + "description": "Execute Remote Ansible Script", + "target": "connection-fail", + "activities": [ + { + "call_operation": "" + } + ] + } + }, + "inputs": { + "endpoint-selector": { + "required": true, + "type": "string" + }, + "job-template-name": { + "required": true, + "type": "string" + }, + "limit": { + "required": false, + "type": "string" + }, + "inventory": { + "required": false, + "type": "string" + }, + "tags": { + "required": false, + "type": "string" + }, + "skip-tags": { + "required": false, + "type": "string" + }, + "extra-vars": { + "required": false, + "type": "json" + } + }, + "outputs": { + "ansible-command-status": { + "type": "string", + "value": { + "get_attribute": [ + "connection-fail", + "ansible-command-status" + ] + } + }, + "ansible-command-logs": { + "type": "string", + "value": { + "get_attribute": [ + "connection-fail", + "ansible-command-logs" + ] + } + } + } + }, + "execute-remote-ansible-failure": { + "steps": { + "process": { + "description": "Execute Remote Ansible Script", + "target": "execute-remote-ansible-failure", + "activities": [ + { + "call_operation": "" + } + ] + } + }, + "inputs": { + "endpoint-selector": { + "required": true, + "type": "string" + }, + "job-template-name": { + "required": true, + "type": "string" + }, + "limit": { + "required": false, + "type": "string" + }, + "inventory": { + "required": false, + "type": "string" + }, + "tags": { + "required": false, + "type": "string" + }, + "skip-tags": { + "required": false, + "type": "string" + }, + "extra-vars": { + "required": false, + "type": "json" + } + }, + "outputs": { + "ansible-command-status": { + "type": "string", + "value": { + "get_attribute": [ + "execute-remote-ansible-failure", + "ansible-command-status" + ] + } + }, + "ansible-command-logs": { + "type": "string", + "value": { + "get_attribute": [ + "execute-remote-ansible-failure", + "ansible-command-logs" + ] + } + } + } + } + }, + "node_templates": { + "execute-remote-ansible-success": { + "type": "component-remote-ansible-executor", + "interfaces": { + "ComponentRemoteAnsibleExecutor": { + "operations": { + "process": { + "inputs": { + "endpoint-selector": "*ansible-remote-success-endpoint", + "job-template-name": { + "get_input": "job-template-name" + }, + "limit": { + "get_input": "limit" + }, + "inventory": { + "get_input": "inventory" + }, + "extra-vars": { + "get_input": "extra-vars" + }, + "tags": { + "get_input": "tags" + }, + "skip-tags": { + "get_input": "skip-tags" + } + } + } + } + } + } + }, + "connection-fail": { + "type": "component-remote-ansible-executor", + "interfaces": { + "ComponentRemoteAnsibleExecutor": { + "operations": { + "process": { + "inputs": { + "endpoint-selector": "*ansible-remote-invalid-endpoint", + "job-template-name": { + "get_input": "job-template-name" + }, + "limit": { + "get_input": "limit" + }, + "inventory": { + "get_input": "inventory" + }, + "extra-vars": { + "get_input": "extra-vars" + }, + "tags": { + "get_input": "tags" + }, + "skip-tags": { + "get_input": "skip-tags" + } + } + } + } + } + } + }, + "execute-remote-ansible-failure": { + "type": "component-remote-ansible-executor", + "interfaces": { + "ComponentRemoteAnsibleExecutor": { + "operations": { + "process": { + "inputs": { + "endpoint-selector": "*ansible-remote-failure-endpoint", + "job-template-name": { + "get_input": "job-template-name" + }, + "limit": { + "get_input": "limit" + }, + "inventory": { + "get_input": "inventory" + }, + "extra-vars": { + "get_input": "extra-vars" + }, + "tags": { + "get_input": "tags" + }, + "skip-tags": { + "get_input": "skip-tags" + } + } + } + } + } + } + } + } + } +} diff --git a/cds-regression-test/cba/cba/remote-ansible/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/cba/remote-ansible/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..1b4ba50 --- /dev/null +++ b/cds-regression-test/cba/cba/remote-ansible/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-ansible.json +Template-Tags: test, regression +Template-Name: RT-remote-ansible +Template-Version: 1.0.0 +Template-Type: DEFAULT diff --git a/cds-regression-test/cba/cba/remote-python/Definitions/remote-python.json b/cds-regression-test/cba/cba/remote-python/Definitions/remote-python.json new file mode 100644 index 0000000..456c14d --- /dev/null +++ b/cds-regression-test/cba/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": "regression-cdsce-cds-ce", + "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/cds-regression-test/cba/cba/remote-python/Scripts/python/EchoRemotePython.py b/cds-regression-test/cba/cba/remote-python/Scripts/python/EchoRemotePython.py new file mode 100644 index 0000000..08488da --- /dev/null +++ b/cds-regression-test/cba/cba/remote-python/Scripts/python/EchoRemotePython.py @@ -0,0 +1,13 @@ +#!/usr/bin/python + +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/cds-regression-test/cba/cba/remote-python/Scripts/python/FailingRemotePython.py b/cds-regression-test/cba/cba/remote-python/Scripts/python/FailingRemotePython.py new file mode 100644 index 0000000..672492d --- /dev/null +++ b/cds-regression-test/cba/cba/remote-python/Scripts/python/FailingRemotePython.py @@ -0,0 +1,15 @@ +#!/usr/bin/python + +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/cds-regression-test/cba/cba/remote-python/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/cba/remote-python/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..85fa3bd --- /dev/null +++ b/cds-regression-test/cba/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 diff --git a/cds-regression-test/cba/cba/resource-resolution/Definitions/resource-resolution.json b/cds-regression-test/cba/cba/resource-resolution/Definitions/resource-resolution.json new file mode 100644 index 0000000..af804a2 --- /dev/null +++ b/cds-regression-test/cba/cba/resource-resolution/Definitions/resource-resolution.json @@ -0,0 +1,99 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-resource-resolution", + "template_version": "1.0.0", + "template_tags": "Bell, CBA, test" + }, + "dsl_definitions": { + "rest-endpoint": { + "type": "token-auth", + "url": "http://cds-regression-mockserver", + "token": "NoTokenRequired" + }, + "db-endpoint": { + "type": "maria-db", + "url": "jdbc:mysql://cds-db:3306/sdnctl", + "username": "sdnctl", + "password": "sdnctl" + } + }, + "topology_template": { + "workflows": { + "resource-resolution": { + "steps": { + "helloworld": { + "description": "Component resource resolution regression test", + "target": "resource-resolution" + } + }, + "inputs": { + "resolution-key": { + "required": true, + "type": "string" + }, + "template-prefix": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "outputs": { + "meshed-template": { + "type": "json", + "value": { + "get_attribute": [ + "resource-resolution", + "assignment-params" + ] + } + } + } + } + }, + "node_templates": { + "resource-resolution": { + "type": "component-resource-resolution", + "interfaces": { + "ResourceResolutionComponent": { + "operations": { + "process": { + "inputs": { + "artifact-prefix-names": { + "get_input": "template-prefix" + }, + "store-result": true, + "force-resolution": true, + "resolution-key": { + "get_input": "resolution-key" + } + } + } + } + } + }, + "artifacts": { + "helloworld-velocity-template": { + "type": "artifact-template-velocity", + "file": "Templates/hello-world-template.vtl" + }, + "helloworld-velocity-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/hello-world-velocity-mapping.json" + }, + "helloworld-jinja-template": { + "type": "artifact-template-jinja", + "file": "Templates/hello-world-template.jinja" + }, + "helloworld-jinja-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/hello-world-jinja-mapping.json" + } + } + } + } + } +} diff --git a/cds-regression-test/cba/cba/resource-resolution/Scripts/kotlin/ResolvProperties.kt b/cds-regression-test/cba/cba/resource-resolution/Scripts/kotlin/ResolvProperties.kt new file mode 100644 index 0000000..5dd8a86 --- /dev/null +++ b/cds-regression-test/cba/cba/resource-resolution/Scripts/kotlin/ResolvProperties.kt @@ -0,0 +1,49 @@ +package cba.cds.RT + +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment +import org.slf4j.LoggerFactory + +open class ResolvPropertiesKt() : ResourceAssignmentProcessor() { + + private val log = LoggerFactory.getLogger(ResolvPropertiesKt::class.java)!! + + override fun getName(): String { + return "ResolvPropertiesKt" + } + + override suspend fun processNB(resourceAssignment: ResourceAssignment) { + + var retValue = "undefined" + val resourceAssignmentNames = listOf<String>("j_kotlin","v_kotlin") + + try { + if(resourceAssignment.name == "from_suspend_function") { + retValue = getResolvedValue(resourceAssignment) + } + if(resourceAssignmentNames.contains(resourceAssignment.name)) { + retValue = "ok" + } + ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, retValue) + + } catch (e: Exception) { + log.error(e.message, e) + ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, "ERROR") + + throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments, cause: ${e.message}", e) + } + } + + /* + * CCSDK-2150 : https://jira.onap.org/browse/CCSDK-2150 + */ + suspend fun getResolvedValue(resourceAssignment: ResourceAssignment): String { + return "ok" + } + + override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { + raRuntimeService.getBluePrintError().addError("Failed in ResolvPropertiesKt-ResourceAssignmentProcessor : ${runtimeException.message}") + } +} diff --git a/cds-regression-test/cba/cba/resource-resolution/Scripts/python/ResolvProperties.py b/cds-regression-test/cba/cba/resource-resolution/Scripts/python/ResolvProperties.py new file mode 100644 index 0000000..5fac59f --- /dev/null +++ b/cds-regression-test/cba/cba/resource-resolution/Scripts/python/ResolvProperties.py @@ -0,0 +1,40 @@ +# Copyright (c) 2019 IBM, 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. +from abstract_ra_processor import AbstractRAProcessor +from blueprint_constants import * + +class ResolvProperties(AbstractRAProcessor): + + def process(self, resource_assignment): + + resource_assignment_names = ["v_python","j_python"] + script_value = "undefined" + + try: + if resource_assignment.name in resource_assignment_names : + script_value = "ok" + # set value for resource getting currently resolved + self.set_resource_data_value(resource_assignment, script_value) + # except JavaException as err: + # print("Java Exception in the script {}", err) + # # self.set_resource_data_value(resource_assignment, "ERROR") + except Exception as err: + print("Python Exception in the script {}", err) + # self.set_resource_data_value(resource_assignment, "ERROR") + return None + + def recover(self, runtime_exception): + print("Exception in the script {}", runtime_exception) + # print self.addError(runtime_exception.cause.message) + return None diff --git a/cds-regression-test/cba/cba/resource-resolution/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/cba/resource-resolution/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..bb9b59a --- /dev/null +++ b/cds-regression-test/cba/cba/resource-resolution/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/resource-resolution.json +Template-Tags: test, regression +Template-Name: RT-resource-resolution +Template-Version: 1.0.0 +Template-Type: DEFAULT
\ No newline at end of file diff --git a/cds-regression-test/cba/cba/resource-resolution/Templates/hello-world-jinja-mapping.json b/cds-regression-test/cba/cba/resource-resolution/Templates/hello-world-jinja-mapping.json new file mode 100644 index 0000000..395e7a1 --- /dev/null +++ b/cds-regression-test/cba/cba/resource-resolution/Templates/hello-world-jinja-mapping.json @@ -0,0 +1,115 @@ +[ + { + "name": "j_default", + "input-param": true, + "property": { + "type": "string", + "default": "ok" + }, + "dictionary-name": "input-source", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "j_input", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "input-source", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "j_python", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "properties-capability-source", + "dictionary-source": "capability", + "dependencies": [] + }, + { + "name": "j_kotlin", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "kotlin-script", + "dictionary-source": "capability", + "dependencies": [] + }, + { + "name": "from_suspend_function", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "kotlin-script", + "dictionary-source": "capability", + "dependencies": [] + }, + { + "name": "j_db", + "input-param": true, + "property": { + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "dictionary-name": "RT-db", + "dictionary-source": "processor-db" + }, + { + "name": "j_get", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-get", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "j_post", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-post", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "j_put", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-put", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "j_patch", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-patch", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "j_del", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-delete", + "dictionary-source": "sdnc", + "dependencies": [] + } +] diff --git a/cds-regression-test/cba/cba/resource-resolution/Templates/hello-world-template.jinja b/cds-regression-test/cba/cba/resource-resolution/Templates/hello-world-template.jinja new file mode 100644 index 0000000..19947b5 --- /dev/null +++ b/cds-regression-test/cba/cba/resource-resolution/Templates/hello-world-template.jinja @@ -0,0 +1,19 @@ +{ + "default": "{{ j_default }}", + "input": "{{ j_input }}", + "script": { + "python": "{{ j_python }}", + "kotlin": { + "base": "{{ j_kotlin }}" + "from suspend function": "{{ from_suspend_function }}" + } + }, + "db": "{{ j_db[0].value }}", + "rest": { + "GET": "{{j_get}}", + "POST": "{{j_post}}", + "PUT": "{{j_put}}", + "PATCH": "{{j_patch}}", + "DELETE": "{{j_del}}" + } +} diff --git a/cds-regression-test/cba/cba/resource-resolution/Templates/hello-world-template.vtl b/cds-regression-test/cba/cba/resource-resolution/Templates/hello-world-template.vtl new file mode 100644 index 0000000..f821770 --- /dev/null +++ b/cds-regression-test/cba/cba/resource-resolution/Templates/hello-world-template.vtl @@ -0,0 +1,16 @@ +{ + "default": "${v_default}", + "input": "${v_input}", + "script": { + "python": "${v_python}", + "kotlin": "${v_kotlin}" + }, + "db": "${v_db.get(0).value}", + "rest": { + "GET": "${v_get}", + "POST": "${v_post}", + "PUT": "${v_put}", + "PATCH": "${v_patch}", + "DELETE": "${v_del}" + } +} diff --git a/cds-regression-test/cba/cba/resource-resolution/Templates/hello-world-velocity-mapping.json b/cds-regression-test/cba/cba/resource-resolution/Templates/hello-world-velocity-mapping.json new file mode 100644 index 0000000..4314908 --- /dev/null +++ b/cds-regression-test/cba/cba/resource-resolution/Templates/hello-world-velocity-mapping.json @@ -0,0 +1,105 @@ +[ + { + "name": "v_default", + "input-param": true, + "property": { + "type": "string", + "default": "ok" + }, + "dictionary-name": "input-source", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "v_input", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "input-source", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "v_python", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "properties-capability-source", + "dictionary-source": "capability", + "dependencies": [] + }, + { + "name": "v_kotlin", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "kotlin-script", + "dictionary-source": "capability", + "dependencies": [] + }, + { + "name": "v_db", + "input-param": true, + "property": { + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "dictionary-name": "RT-db", + "dictionary-source": "processor-db" + }, + { + "name": "v_get", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-get", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "v_post", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-post", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "v_put", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-put", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "v_patch", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-patch", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "v_del", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-delete", + "dictionary-source": "sdnc", + "dependencies": [] + } +] diff --git a/cds-regression-test/cba/cli/elalto/Definitions/cli.json b/cds-regression-test/cba/cli/elalto/Definitions/cli.json new file mode 100644 index 0000000..722663e --- /dev/null +++ b/cds-regression-test/cba/cli/elalto/Definitions/cli.json @@ -0,0 +1,106 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-cli", + "template_version": "1.0.0", + "template_tags": "test, regression" + }, + "dsl_definitions": { + "device-properties": { + "type": "basic-auth", + "host": { + "get_input": "host" + }, + "username": { + "get_input": "username" + }, + "password": { + "get_input": "password" + }, + "port": { + "get_input": "port" + }, + "connectionTimeOut": { + "get_input": "connectionTimeOut" + } + } + }, + "topology_template": { + "workflows": { + "cli": { + "steps": { + "cli": { + "description": "CLI Workflow", + "target": "cli" + } + }, + "inputs": { + "resolution-key": { + "required": false, + "type": "string" + }, + "password": { + "required": true, + "type": "string" + }, + "username": { + "required": true, + "type": "string" + }, + "host": { + "required": true, + "type": "string" + }, + "port": { + "required": false, + "type": "string" + }, + "connectionTimeOut": { + "required": true, + "type": "string" + }, + "commands": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "outputs": { + "response-data": { + "type": "string", + "value": { + "get_attribute": [ + "cli", + "response-data" + ] + } + } + } + } + }, + "node_templates": { + "cli": { + "type": "component-script-executor", + "interfaces": { + "ComponentScriptExecutor": { + "operations": { + "process": { + "implementation": { + "primary": "component-script" + }, + "inputs": { + "script-type": "kotlin", + "script-class-reference": "cli.CliRegressionTest" + }, + "outputs": {} + } + } + } + } + } + } + } +} diff --git a/cds-regression-test/cba/cli/elalto/Scripts/kotlin/cli/cli.kt b/cds-regression-test/cba/cli/elalto/Scripts/kotlin/cli/cli.kt new file mode 100755 index 0000000..12786c8 --- /dev/null +++ b/cds-regression-test/cba/cli/elalto/Scripts/kotlin/cli/cli.kt @@ -0,0 +1,59 @@ +/*
+ * Copyright © 2019 IBM, 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.
+ */
+
+package cli
+
+import org.onap.ccsdk.cds.controllerblueprints.core.logger
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.cli.executor.cliDeviceInfo
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.cli.executor.getSshClientService
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+
+
+open class CliRegressionTest : AbstractScriptComponentFunction() {
+
+ private val log = logger(CliRegressionTest::class)
+
+ override suspend fun processNB(executionRequest: ExecutionServiceInput) {
+ // Get Client Service
+ val sshClientService = getSshClientService(cliDeviceInfo("device-properties"))
+ sshClientService.startSession()
+
+ // Read Commands
+ val timeout = bluePrintRuntimeService.getInputValue("connectionTimeOut").asText()
+ val commands = bluePrintRuntimeService.getInputValue("commands")
+ .let { JacksonUtils.getListFromJsonNode(it, String::class.java) }
+
+ // Execute
+ var responsesLog = "Error"
+ try {
+ responsesLog = sshClientService.executeCommands(commands, timeout.toLong())
+ log.info(responsesLog)
+ } catch (e: Exception) {
+ e.message?.let { addError(it) }
+ } finally {
+ setAttribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, responsesLog.asJsonPrimitive())
+ sshClientService.closeSession()
+ }
+ }
+
+ override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ log.info("Executing Recovery")
+ }
+}
\ No newline at end of file diff --git a/cds-regression-test/cba/cli/elalto/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/cli/elalto/TOSCA-Metadata/TOSCA.meta new file mode 100755 index 0000000..7bb2d45 --- /dev/null +++ b/cds-regression-test/cba/cli/elalto/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/cli.json +Template-Tags: test, regression +Template-Name: RT-cli +Template-Version: 1.0.0 +Template-Type: DEFAULT
\ No newline at end of file diff --git a/cds-regression-test/cba/cli/frankfurt/Definitions/cli.json b/cds-regression-test/cba/cli/frankfurt/Definitions/cli.json new file mode 100644 index 0000000..c0070da --- /dev/null +++ b/cds-regression-test/cba/cli/frankfurt/Definitions/cli.json @@ -0,0 +1,113 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-cli", + "template_version": "1.0.0", + "template_tags": "test, regression" + }, + "dsl_definitions": { + "device-properties": { + "type": "basic-auth", + "host": { + "get_input": "host" + }, + "username": { + "get_input": "username" + }, + "password": { + "get_input": "password" + }, + "port": { + "get_input": "port" + }, + "logging": { + "get_input": "logging" + }, + "connectionTimeOut": { + "get_input": "connectionTimeOut" + } + } + }, + "topology_template": { + "workflows": { + "cli": { + "steps": { + "cli": { + "description": "CLI Workflow", + "target": "cli" + } + }, + "inputs": { + "resolution-key": { + "required": false, + "type": "string" + }, + "password": { + "required": true, + "type": "string" + }, + "username": { + "required": true, + "type": "string" + }, + "host": { + "required": true, + "type": "string" + }, + "port": { + "required": false, + "type": "string" + }, + "connectionTimeOut": { + "required": true, + "type": "string" + }, + "logging": { + "required": true, + "type": "boolean" + }, + "commands": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "outputs": { + "response-data": { + "type": "string", + "value": { + "get_attribute": [ + "cli", + "response-data" + ] + } + } + } + } + }, + "node_templates": { + "cli": { + "type": "component-script-executor", + "interfaces": { + "ComponentScriptExecutor": { + "operations": { + "process": { + "implementation": { + "primary": "component-script" + }, + "inputs": { + "script-type": "kotlin", + "script-class-reference": "cli.CliRegressionTest" + }, + "outputs": {} + } + } + } + } + } + } + } +} diff --git a/cds-regression-test/cba/cli/frankfurt/Scripts/kotlin/cli/cli.kt b/cds-regression-test/cba/cli/frankfurt/Scripts/kotlin/cli/cli.kt new file mode 100755 index 0000000..1e1ade0 --- /dev/null +++ b/cds-regression-test/cba/cli/frankfurt/Scripts/kotlin/cli/cli.kt @@ -0,0 +1,59 @@ +/* + * Copyright © 2019 IBM, 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. + */ + +package cli + +import org.onap.ccsdk.cds.controllerblueprints.core.logger +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.functions.cli.executor.cliDeviceInfo +import org.onap.ccsdk.cds.blueprintsprocessor.functions.cli.executor.getSshClientService +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor +import org.onap.ccsdk.cds.blueprintsprocessor.ssh.service.CommandResult +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType + +open class CliRegressionTest : AbstractScriptComponentFunction() { + + private val log = logger(CliRegressionTest::class) + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + // Get Client Service + val sshClientService = getSshClientService(cliDeviceInfo("device-properties")) + sshClientService.startSession() + + // Read Commands + val timeout = bluePrintRuntimeService.getInputValue("connectionTimeOut").asText() + val commands = bluePrintRuntimeService.getInputValue("commands") + .let { JacksonUtils.getListFromJsonNode(it, String::class.java) } + + // Execute + var responsesLog: List<CommandResult>? = null + try { + responsesLog = sshClientService.executeCommands(commands, timeout.toLong()) + log.info(responsesLog.toString()) + } catch (e: Exception) { + e.message?.let { addError(it) } + } finally { + setAttribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, responsesLog?.map { it->it.asJsonType()}.asJsonType()) + sshClientService.closeSession() + } + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Executing Recovery") + } +} diff --git a/cds-regression-test/cba/cli/frankfurt/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/cli/frankfurt/TOSCA-Metadata/TOSCA.meta new file mode 100755 index 0000000..7bb2d45 --- /dev/null +++ b/cds-regression-test/cba/cli/frankfurt/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/cli.json +Template-Tags: test, regression +Template-Name: RT-cli +Template-Version: 1.0.0 +Template-Type: DEFAULT
\ No newline at end of file diff --git a/cds-regression-test/cba/lock-device/Definitions/lock-device.json b/cds-regression-test/cba/lock-device/Definitions/lock-device.json new file mode 100644 index 0000000..c90021c --- /dev/null +++ b/cds-regression-test/cba/lock-device/Definitions/lock-device.json @@ -0,0 +1,98 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-lock-device", + "template_version": "1.0.0", + "template_tags": "Bell, CBA, test" + }, + "dsl_definitions": {}, + "topology_template": { + "workflows": { + "resolve-deploy-kotlin": { + "steps": { + "resolve": { + "description": "resolve vnf-id", + "target": "resource-resolution", + "on_success": [ + "execute-script" + ] + }, + "execute-script": { + "description": "Execute Kotlin Script", + "target": "execute-kotlin" + } + }, + "outputs": { + "response-data": { + "type": "string", + "value": { + "get_attribute": [ + "execute-kotlin", + "response-data" + ] + } + } + } + } + }, + "node_templates": { + "resource-resolution": { + "type": "component-resource-resolution", + "interfaces": { + "ResourceResolutionComponent": { + "operations": { + "process": { + "inputs": { + "artifact-prefix-names": [ + "base" + ], + "resolution-summary": true + } + } + } + } + }, + "artifacts": { + "base-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/base-mapping.json" + } + } + }, + "execute-kotlin": { + "type": "component-script-executor", + "interfaces": { + "ComponentScriptExecutor": { + "operations": { + "process": { + "implementation": { + "primary": "component-script", + "lock": { + "key": { + "get_attribute": [ + "resource-resolution", + "", + "assignment-map", + "base", + "vnf-id" + ] + }, + "acquireTimeout": { + "get_input": "lock-acquire-timeout" + } + } + }, + "inputs": { + "script-type": "kotlin", + "script-class-reference": "cba.cds.RT.ProcessOperation" + }, + "outputs": {} + } + } + } + } + } + } + } +} diff --git a/cds-regression-test/cba/lock-device/Scripts/kotlin/ProcessOperation.kt b/cds-regression-test/cba/lock-device/Scripts/kotlin/ProcessOperation.kt new file mode 100755 index 0000000..4c795e4 --- /dev/null +++ b/cds-regression-test/cba/lock-device/Scripts/kotlin/ProcessOperation.kt @@ -0,0 +1,49 @@ +/* + * Copyright © 2019 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. + */ + +package cba.cds.RT + +import org.onap.ccsdk.cds.controllerblueprints.core.logger +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService +import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties +import kotlinx.coroutines.delay + +open class ProcessOperation : AbstractScriptComponentFunction() { + + private val log = logger(ProcessOperation::class) + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + val time : Long = 15_000 + try { + log.info("Processing for $time ms... ${executionRequest.commonHeader.requestId}") + delay(time) + log.info("Done processing ${executionRequest.commonHeader.requestId}!") + setAttribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, "Success: ${executionRequest.commonHeader.requestId}".asJsonType()) + } catch (e: Exception) { + e.message?.let { addError(it) } + } + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + setAttribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, runtimeException.message!!.asJsonType()) + addError(runtimeException.message!!) + log.info("Executing Recovery") + } +} diff --git a/cds-regression-test/cba/lock-device/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/lock-device/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..e182865 --- /dev/null +++ b/cds-regression-test/cba/lock-device/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/lock-device.json +Template-Tags: test, regression +Template-Name: RT-lock-device +Template-Version: 1.0.0 +Template-Type: DEFAULT
\ No newline at end of file diff --git a/cds-regression-test/cba/lock-device/Templates/base-mapping.json b/cds-regression-test/cba/lock-device/Templates/base-mapping.json new file mode 100644 index 0000000..b5b64a8 --- /dev/null +++ b/cds-regression-test/cba/lock-device/Templates/base-mapping.json @@ -0,0 +1,23 @@ +[ + { + "name": "vnf-id", + "input-param": true, + "property": { + "type": "string", + "default": "rt-vnf-xyz-123" + }, + "dictionary-name": "input-source", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "lock-acquire-timeout", + "input-param": true, + "property": { + "type": "integer" + }, + "dictionary-name": "input-source", + "dictionary-source": "input", + "dependencies": [] + } +] diff --git a/cds-regression-test/cba/netconf/Definitions/netconf.json b/cds-regression-test/cba/netconf/Definitions/netconf.json new file mode 100644 index 0000000..74a98c1 --- /dev/null +++ b/cds-regression-test/cba/netconf/Definitions/netconf.json @@ -0,0 +1,137 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-netconf", + "template_version": "1.0.0", + "template_tags": "Bell, CBA, test" + }, + "topology_template": { + "workflows": { + "netconf-jython": { + "steps": { + "netconf-jython": { + "description": "deploy config", + "target": "execute-jython-netconf" + } + }, + "inputs": { + "netconf-host": { + "required": true, + "type": "string" + }, + "netconf-timeout": { + "required": true, + "type": "string" + } + }, + "outputs": { + "response-data": { + "type": "string", + "value": { + "get_attribute": [ + "execute-jython-netconf", + "response-data" + ] + } + } + } + }, + "netconf-kotlin": { + "steps": { + "netconf-kotlin": { + "description": "deploy config", + "target": "execute-kotlin-netconf" + } + }, + "inputs": { + "netconf-host": { + "required": true, + "type": "string" + }, + "netconf-timeout": { + "required": true, + "type": "string" + } + }, + "outputs": { + "response-data": { + "type": "string", + "value": { + "get_attribute": [ + "execute-kotlin-netconf", + "response-data" + ] + } + } + } + } + }, + "node_templates": { + "execute-jython-netconf": { + "type": "component-netconf-executor", + "requirements": { + "netconf-connection": { + "capability": "netconf", + "node": "netconf-device", + "relationship": "tosca.relationships.ConnectsTo" + } + }, + "interfaces": { + "ComponentNetconfExecutor": { + "operations": { + "process": { + "inputs": { + "script-type": "jython", + "script-class-reference": "Scripts/python/NetconfTest.py", + "instance-dependencies": [] + } + } + } + } + } + }, + "execute-kotlin-netconf": { + "type": "component-netconf-executor", + "requirements": { + "netconf-connection": { + "capability": "netconf", + "node": "netconf-device", + "relationship": "tosca.relationships.ConnectsTo" + } + }, + "interfaces": { + "ComponentNetconfExecutor": { + "operations": { + "process": { + "inputs": { + "script-type": "kotlin", + "script-class-reference": "org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.ConfigDeploy", + "instance-dependencies": [] + } + } + } + } + } + }, + "netconf-device": { + "type": "vnf-netconf-device", + "capabilities": { + "netconf": { + "properties": { + "login-key": "password", + "login-account": "admin", + "target-ip-address": { + "get_input": "netconf-host" + }, + "port-number": 17830, + "connection-time-out": { + "get_input": "netconf-timeout" + } + } + } + } + } + } + } +} diff --git a/cds-regression-test/cba/netconf/Scripts/kotlin/kotlin.kt b/cds-regression-test/cba/netconf/Scripts/kotlin/kotlin.kt new file mode 100644 index 0000000..956890a --- /dev/null +++ b/cds-regression-test/cba/netconf/Scripts/kotlin/kotlin.kt @@ -0,0 +1,47 @@ +package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor + +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifactNB +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils +import org.slf4j.LoggerFactory + +open class ConfigDeploy : AbstractScriptComponentFunction() { + + private val log = LoggerFactory.getLogger(ConfigDeploy::class.java)!! + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + val device = netconfDevice("netconf-connection") + val client = device.netconfRpcService + val session = device.netconfSession + + val payload=""" + <configuration xmlns:junos="http://xml.juniper.net/junos/17.4R1/junos"> + <system xmlns="http://yang.juniper.net/junos-qfx/conf/system"> + <host-name operation="delete" /> + <host-name operation="create">Regression-Mock</host-name> + </system> + </configuration> + """ + + val response: MutableMap<String, Boolean> = mutableMapOf("deploySuccess" to false) + + try { + session.connect() + client.lock() + client.editConfig(payload) + client.commit() + client.unLock() + session.disconnect() + response["deploySuccess"] = true + } catch (e: Exception) { + e.message?.let { super.addError(it) } + } + + super.setAttribute("response-data", JacksonUtils.jsonNodeFromObject(response)) + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Executing Recovery") + } +} diff --git a/cds-regression-test/cba/netconf/Scripts/python/NetconfTest.py b/cds-regression-test/cba/netconf/Scripts/python/NetconfTest.py new file mode 100644 index 0000000..c52c8af --- /dev/null +++ b/cds-regression-test/cba/netconf/Scripts/python/NetconfTest.py @@ -0,0 +1,53 @@ +# Copyright (c) 2019 IBM, 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 netconf_constant +from java.lang import Exception as JavaException +from netconfclient import NetconfClient +import json +from org.onap.ccsdk.cds.blueprintsprocessor.services.execution import AbstractScriptComponentFunction +from com.fasterxml.jackson.databind import ObjectMapper + +class NetconfTest(AbstractScriptComponentFunction): + + def process(self): + log = globals()[netconf_constant.SERVICE_LOG] + payload=""" + <configuration xmlns:junos="http://xml.juniper.net/junos/17.4R1/junos"> + <system xmlns="http://yang.juniper.net/junos-qfx/conf/system"> + <host-name operation="delete" /> + <host-name operation="create">Regression-Mock</host-name> + </system> + </configuration> + """ + responsePayload = '{"deploySuccess": false}' + + try: + nc = NetconfClient(log, self, "netconf-connection") + nc.connect() + nc.lock() + nc.edit_config(message_content=payload, config_target="candidate") + operationResponse = nc.commit() + nc.unlock() + nc.disconnect() + responsePayload = json.dumps({"deploySuccess": operationResponse.isSuccess()}) + except JavaException as err: + self.addError(err.message) + except Exception as err: + self.addError("Python error: {}".format(err)) + + self.setAttribute("response-data", ObjectMapper().readTree(responsePayload)) + return None + + def recover(self): + return None diff --git a/cds-regression-test/cba/netconf/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/netconf/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..1155ae8 --- /dev/null +++ b/cds-regression-test/cba/netconf/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/netconf.json +Template-Tags: test, regression +Template-Name: RT-netconf +Template-Version: 1.0.0 +Template-Type: DEFAULT
\ No newline at end of file diff --git a/cds-regression-test/cba/py-executor/.DS_Store b/cds-regression-test/cba/py-executor/.DS_Store Binary files differnew file mode 100644 index 0000000..5008ddf --- /dev/null +++ b/cds-regression-test/cba/py-executor/.DS_Store diff --git a/cds-regression-test/cba/py-executor/Definitions/py-executor.json b/cds-regression-test/cba/py-executor/Definitions/py-executor.json new file mode 100644 index 0000000..b28162c --- /dev/null +++ b/cds-regression-test/cba/py-executor/Definitions/py-executor.json @@ -0,0 +1,174 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-py-executor", + "template_version": "1.0.0", + "template_tags": "Bell, CBA, test" + }, + "dsl_definitions": { + "py-executor": { + "type": "tls-auth", + "host": "cds-py-executor-py-exec", + "port": "50052", + "trustCertCollection": "/opt/app/onap/config/certs/py-executor/py-executor-chain.pem" + }, + "invalid-py-executor": { + "type": "tls-auth", + "host": "127.0.0.1", + "port": "12345", + "trustCertCollection": "/opt/app/onap/config/certs/py-executor/py-executor-chain.pem" + }, + "parameters": { + "hello": "world" + } + }, + "topology_template": { + "workflows": { + "remote-python": { + "steps": { + "execute-script": { + "description": "Execute Remote Python Script", + "target": "execute-remote-python" + } + }, + "inputs": {}, + "outputs": { + "status": { + "type": "string", + "value": { + "get_attribute": [ + "execute-remote-python", + "status" + ] + } + }, + "response-data": { + "type": "json", + "value": { + "get_attribute": [ + "execute-remote-python", + "response-data" + ] + } + } + } + }, + "connection-fail": { + "steps": { + "execute-script": { + "description": "Execute Remote Python Script to an invalid endpoint", + "target": "execute-connection-fail" + } + }, + "inputs": {}, + "outputs": { + "status": { + "type": "string", + "value": { + "get_attribute": [ + "execute-connection-fail", + "status" + ] + } + }, + "response-data": { + "type": "json", + "value": { + "get_attribute": [ + "execute-connection-fail", + "response-data" + ] + } + } + } + }, + "failing-remote-python": { + "steps": { + "execute-script": { + "description": "Execute Remote Python Script", + "target": "execute-failing-remote-python" + } + }, + "inputs": {}, + "outputs": { + "status": { + "type": "string", + "value": { + "get_attribute": [ + "execute-failing-remote-python", + "status" + ] + } + }, + "response-data": { + "type": "json", + "value": { + "get_attribute": [ + "execute-failing-remote-python", + "response-data" + ] + } + } + } + } + }, + "node_templates": { + "execute-remote-python": { + "type": "component-remote-script-executor", + "interfaces": { + "ComponentRemoteScriptExecutor": { + "operations": { + "process": { + "inputs": { + "selector": "*py-executor", + "blueprint-name": "RT-py-executor", + "blueprint-version": "1.0.0", + "blueprint-action": "HelloWorld", + "timeout": 1000, + "request-data": "*parameters" + } + } + } + } + } + }, + "execute-connection-fail": { + "type": "component-remote-script-executor", + "interfaces": { + "ComponentRemoteScriptExecutor": { + "operations": { + "process": { + "inputs": { + "selector": "*invalid-py-executor", + "blueprint-name": "RT-py-executor", + "blueprint-version": "1.0.0", + "blueprint-action": "HelloWorld", + "timeout": 1000 + } + } + } + } + } + }, + "execute-failing-remote-python": { + "type": "component-remote-script-executor", + "interfaces": { + "ComponentRemoteScriptExecutor": { + "operations": { + "process": { + "inputs": { + "selector": "*py-executor", + "blueprint-name": "RT-py-executor", + "blueprint-version": "1.0.0", + "blueprint-action": "FailingScript", + "timeout": 1000 + } + } + } + } + } + } + } + } +} diff --git a/cds-regression-test/cba/py-executor/Scripts/python/__init__.py b/cds-regression-test/cba/py-executor/Scripts/python/__init__.py new file mode 100644 index 0000000..dcef3a9 --- /dev/null +++ b/cds-regression-test/cba/py-executor/Scripts/python/__init__.py @@ -0,0 +1,16 @@ +# Copyright © 2018-2019 AT&T Intellectual Property. +# +# 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. + +from .hello_world import * +from .failing_script import * diff --git a/cds-regression-test/cba/py-executor/Scripts/python/failing_script.py b/cds-regression-test/cba/py-executor/Scripts/python/failing_script.py new file mode 100644 index 0000000..66efd3f --- /dev/null +++ b/cds-regression-test/cba/py-executor/Scripts/python/failing_script.py @@ -0,0 +1,34 @@ +#!/usr/bin/python +# +# Copyright © 2018-2019 AT&T Intellectual Property. +# +# 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 logging +from blueprints_grpc import executor_utils +from blueprints_grpc.blueprint_processing_server import AbstractScriptFunction + + +class FailingScript(AbstractScriptFunction): + def __init__(self): + self.logger = logging.getLogger(self.__class__.__name__) + + def process(self, execution_request): + self.logger.info("Request Received in Script : {}".format(execution_request)) + raise RuntimeError('Script raised an exception') + + def recover(self): + return None + + def send_notification(self, execution_request): + yield executor_utils.send_notification(execution_request, "I am notification") diff --git a/cds-regression-test/cba/py-executor/Scripts/python/hello_world.py b/cds-regression-test/cba/py-executor/Scripts/python/hello_world.py new file mode 100644 index 0000000..1d308ee --- /dev/null +++ b/cds-regression-test/cba/py-executor/Scripts/python/hello_world.py @@ -0,0 +1,41 @@ +#!/usr/bin/python +# +# Copyright © 2018-2019 AT&T Intellectual Property. +# +# 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 logging +from blueprints_grpc import executor_utils +from blueprints_grpc.blueprint_processing_server import AbstractScriptFunction +import json +from google.protobuf import json_format + +class HelloWorld(AbstractScriptFunction): + def __init__(self): + self.logger = logging.getLogger(self.__class__.__name__) + + def process(self, execution_request): + self.logger.info("Request Received in Script : {}".format(execution_request)) + + inputs = json_format.MessageToJson(execution_request.payload) + response_payload_json = json.loads(inputs) + + execution_response = executor_utils.success_response(execution_request, response_payload_json, 200) + self.logger.info("Response returned : {}".format(execution_response)) + yield execution_response + + def recover(self): + return None + + def send_notification(self, execution_request): + yield executor_utils.send_notification(execution_request, "I am notification") diff --git a/cds-regression-test/cba/py-executor/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/py-executor/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..8389ebb --- /dev/null +++ b/cds-regression-test/cba/py-executor/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/py-executor.json +Template-Tags: test, regression +Template-Name: RT-py-executor +Template-Version: 1.0.0 +Template-Type: DEFAULT diff --git a/cds-regression-test/cba/remote-ansible/Definitions/remote-ansible.json b/cds-regression-test/cba/remote-ansible/Definitions/remote-ansible.json new file mode 100644 index 0000000..ee0d466 --- /dev/null +++ b/cds-regression-test/cba/remote-ansible/Definitions/remote-ansible.json @@ -0,0 +1,317 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-remote-ansible", + "template_version": "1.0.0", + "template_tags": "Bell, CBA, test" + }, + "dsl_definitions": { + "ansible-remote-success-endpoint": { + "type": "token-auth", + "url": "http://cds-regression-mockserver/remote-ansible/success", + "token": "Bearer J9gEtMDqf7P4YsJ7444fioY9VAhLDIs1" + }, + "ansible-remote-failure-endpoint": { + "type": "token-auth", + "url": "http://cds-regression-mockserver/remote-ansible/failure", + "token": "Bearer J9gEtMDqf7P4YsJ7444fioY9VAhLDIs1" + }, + "ansible-remote-invalid-endpoint": { + "type": "token-auth", + "url": "http://localhost:12345", + "token": "Bearer J9gEtMDqf7P4YsJ7444fioY9VAhLDIs1" + } + }, + "topology_template": { + "workflows": { + "execute-remote-ansible-success": { + "steps": { + "process": { + "description": "Execute Remote Ansible Script", + "target": "execute-remote-ansible-success", + "activities": [ + { + "call_operation": "" + } + ] + } + }, + "inputs": { + "endpoint-selector": { + "required": true, + "type": "string" + }, + "job-template-name": { + "required": true, + "type": "string" + }, + "limit": { + "required": false, + "type": "string" + }, + "inventory": { + "required": false, + "type": "string" + }, + "tags": { + "required": false, + "type": "string" + }, + "skip-tags": { + "required": false, + "type": "string" + }, + "extra-vars": { + "required": false, + "type": "json" + } + }, + "outputs": { + "ansible-command-status": { + "type": "string", + "value": { + "get_attribute": [ + "execute-remote-ansible-success", + "ansible-command-status" + ] + } + }, + "ansible-command-logs": { + "type": "string", + "value": { + "get_attribute": [ + "execute-remote-ansible-success", + "ansible-command-logs" + ] + } + } + } + }, + "connection-fail": { + "steps": { + "process": { + "description": "Execute Remote Ansible Script", + "target": "connection-fail", + "activities": [ + { + "call_operation": "" + } + ] + } + }, + "inputs": { + "endpoint-selector": { + "required": true, + "type": "string" + }, + "job-template-name": { + "required": true, + "type": "string" + }, + "limit": { + "required": false, + "type": "string" + }, + "inventory": { + "required": false, + "type": "string" + }, + "tags": { + "required": false, + "type": "string" + }, + "skip-tags": { + "required": false, + "type": "string" + }, + "extra-vars": { + "required": false, + "type": "json" + } + }, + "outputs": { + "ansible-command-status": { + "type": "string", + "value": { + "get_attribute": [ + "connection-fail", + "ansible-command-status" + ] + } + }, + "ansible-command-logs": { + "type": "string", + "value": { + "get_attribute": [ + "connection-fail", + "ansible-command-logs" + ] + } + } + } + }, + "execute-remote-ansible-failure": { + "steps": { + "process": { + "description": "Execute Remote Ansible Script", + "target": "execute-remote-ansible-failure", + "activities": [ + { + "call_operation": "" + } + ] + } + }, + "inputs": { + "endpoint-selector": { + "required": true, + "type": "string" + }, + "job-template-name": { + "required": true, + "type": "string" + }, + "limit": { + "required": false, + "type": "string" + }, + "inventory": { + "required": false, + "type": "string" + }, + "tags": { + "required": false, + "type": "string" + }, + "skip-tags": { + "required": false, + "type": "string" + }, + "extra-vars": { + "required": false, + "type": "json" + } + }, + "outputs": { + "ansible-command-status": { + "type": "string", + "value": { + "get_attribute": [ + "execute-remote-ansible-failure", + "ansible-command-status" + ] + } + }, + "ansible-command-logs": { + "type": "string", + "value": { + "get_attribute": [ + "execute-remote-ansible-failure", + "ansible-command-logs" + ] + } + } + } + } + }, + "node_templates": { + "execute-remote-ansible-success": { + "type": "component-remote-ansible-executor", + "interfaces": { + "ComponentRemoteAnsibleExecutor": { + "operations": { + "process": { + "inputs": { + "endpoint-selector": "*ansible-remote-success-endpoint", + "job-template-name": { + "get_input": "job-template-name" + }, + "limit": { + "get_input": "limit" + }, + "inventory": { + "get_input": "inventory" + }, + "extra-vars": { + "get_input": "extra-vars" + }, + "tags": { + "get_input": "tags" + }, + "skip-tags": { + "get_input": "skip-tags" + } + } + } + } + } + } + }, + "connection-fail": { + "type": "component-remote-ansible-executor", + "interfaces": { + "ComponentRemoteAnsibleExecutor": { + "operations": { + "process": { + "inputs": { + "endpoint-selector": "*ansible-remote-invalid-endpoint", + "job-template-name": { + "get_input": "job-template-name" + }, + "limit": { + "get_input": "limit" + }, + "inventory": { + "get_input": "inventory" + }, + "extra-vars": { + "get_input": "extra-vars" + }, + "tags": { + "get_input": "tags" + }, + "skip-tags": { + "get_input": "skip-tags" + } + } + } + } + } + } + }, + "execute-remote-ansible-failure": { + "type": "component-remote-ansible-executor", + "interfaces": { + "ComponentRemoteAnsibleExecutor": { + "operations": { + "process": { + "inputs": { + "endpoint-selector": "*ansible-remote-failure-endpoint", + "job-template-name": { + "get_input": "job-template-name" + }, + "limit": { + "get_input": "limit" + }, + "inventory": { + "get_input": "inventory" + }, + "extra-vars": { + "get_input": "extra-vars" + }, + "tags": { + "get_input": "tags" + }, + "skip-tags": { + "get_input": "skip-tags" + } + } + } + } + } + } + } + } + } +} diff --git a/cds-regression-test/cba/remote-ansible/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/remote-ansible/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..1b4ba50 --- /dev/null +++ b/cds-regression-test/cba/remote-ansible/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-ansible.json +Template-Tags: test, regression +Template-Name: RT-remote-ansible +Template-Version: 1.0.0 +Template-Type: DEFAULT diff --git a/cds-regression-test/cba/remote-python/Definitions/remote-python.json b/cds-regression-test/cba/remote-python/Definitions/remote-python.json new file mode 100644 index 0000000..456c14d --- /dev/null +++ b/cds-regression-test/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": "regression-cdsce-cds-ce", + "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/cds-regression-test/cba/remote-python/Scripts/python/EchoRemotePython.py b/cds-regression-test/cba/remote-python/Scripts/python/EchoRemotePython.py new file mode 100644 index 0000000..08488da --- /dev/null +++ b/cds-regression-test/cba/remote-python/Scripts/python/EchoRemotePython.py @@ -0,0 +1,13 @@ +#!/usr/bin/python + +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/cds-regression-test/cba/remote-python/Scripts/python/FailingRemotePython.py b/cds-regression-test/cba/remote-python/Scripts/python/FailingRemotePython.py new file mode 100644 index 0000000..672492d --- /dev/null +++ b/cds-regression-test/cba/remote-python/Scripts/python/FailingRemotePython.py @@ -0,0 +1,15 @@ +#!/usr/bin/python + +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/cds-regression-test/cba/remote-python/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/remote-python/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..85fa3bd --- /dev/null +++ b/cds-regression-test/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 diff --git a/cds-regression-test/cba/resource-resolution/Definitions/resource-resolution.json b/cds-regression-test/cba/resource-resolution/Definitions/resource-resolution.json new file mode 100644 index 0000000..af804a2 --- /dev/null +++ b/cds-regression-test/cba/resource-resolution/Definitions/resource-resolution.json @@ -0,0 +1,99 @@ +{ + "metadata": { + "template_author": "Selffish", + "author-email": "test@bell.ca", + "template_name": "RT-resource-resolution", + "template_version": "1.0.0", + "template_tags": "Bell, CBA, test" + }, + "dsl_definitions": { + "rest-endpoint": { + "type": "token-auth", + "url": "http://cds-regression-mockserver", + "token": "NoTokenRequired" + }, + "db-endpoint": { + "type": "maria-db", + "url": "jdbc:mysql://cds-db:3306/sdnctl", + "username": "sdnctl", + "password": "sdnctl" + } + }, + "topology_template": { + "workflows": { + "resource-resolution": { + "steps": { + "helloworld": { + "description": "Component resource resolution regression test", + "target": "resource-resolution" + } + }, + "inputs": { + "resolution-key": { + "required": true, + "type": "string" + }, + "template-prefix": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "outputs": { + "meshed-template": { + "type": "json", + "value": { + "get_attribute": [ + "resource-resolution", + "assignment-params" + ] + } + } + } + } + }, + "node_templates": { + "resource-resolution": { + "type": "component-resource-resolution", + "interfaces": { + "ResourceResolutionComponent": { + "operations": { + "process": { + "inputs": { + "artifact-prefix-names": { + "get_input": "template-prefix" + }, + "store-result": true, + "force-resolution": true, + "resolution-key": { + "get_input": "resolution-key" + } + } + } + } + } + }, + "artifacts": { + "helloworld-velocity-template": { + "type": "artifact-template-velocity", + "file": "Templates/hello-world-template.vtl" + }, + "helloworld-velocity-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/hello-world-velocity-mapping.json" + }, + "helloworld-jinja-template": { + "type": "artifact-template-jinja", + "file": "Templates/hello-world-template.jinja" + }, + "helloworld-jinja-mapping": { + "type": "artifact-mapping-resource", + "file": "Templates/hello-world-jinja-mapping.json" + } + } + } + } + } +} diff --git a/cds-regression-test/cba/resource-resolution/Scripts/kotlin/ResolvProperties.kt b/cds-regression-test/cba/resource-resolution/Scripts/kotlin/ResolvProperties.kt new file mode 100644 index 0000000..5dd8a86 --- /dev/null +++ b/cds-regression-test/cba/resource-resolution/Scripts/kotlin/ResolvProperties.kt @@ -0,0 +1,49 @@ +package cba.cds.RT + +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment +import org.slf4j.LoggerFactory + +open class ResolvPropertiesKt() : ResourceAssignmentProcessor() { + + private val log = LoggerFactory.getLogger(ResolvPropertiesKt::class.java)!! + + override fun getName(): String { + return "ResolvPropertiesKt" + } + + override suspend fun processNB(resourceAssignment: ResourceAssignment) { + + var retValue = "undefined" + val resourceAssignmentNames = listOf<String>("j_kotlin","v_kotlin") + + try { + if(resourceAssignment.name == "from_suspend_function") { + retValue = getResolvedValue(resourceAssignment) + } + if(resourceAssignmentNames.contains(resourceAssignment.name)) { + retValue = "ok" + } + ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, retValue) + + } catch (e: Exception) { + log.error(e.message, e) + ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, "ERROR") + + throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments, cause: ${e.message}", e) + } + } + + /* + * CCSDK-2150 : https://jira.onap.org/browse/CCSDK-2150 + */ + suspend fun getResolvedValue(resourceAssignment: ResourceAssignment): String { + return "ok" + } + + override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { + raRuntimeService.getBluePrintError().addError("Failed in ResolvPropertiesKt-ResourceAssignmentProcessor : ${runtimeException.message}") + } +} diff --git a/cds-regression-test/cba/resource-resolution/Scripts/python/ResolvProperties.py b/cds-regression-test/cba/resource-resolution/Scripts/python/ResolvProperties.py new file mode 100644 index 0000000..4397a67 --- /dev/null +++ b/cds-regression-test/cba/resource-resolution/Scripts/python/ResolvProperties.py @@ -0,0 +1,40 @@ +# Copyright (c) 2019 IBM, 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. +from abstract_ra_processor import AbstractRAProcessor +from blueprint_constants import * + +class ResolvProperties(AbstractRAProcessor): + + def process(self, resource_assignment): + + resource_assignment_names = ["v_python","j_python"] + script_value = "undefined" + + try: + if resource_assignment.name in resource_assignment_names : + script_value = "ok" + # set value for resource getting currently resolved + self.set_resource_data_value(resource_assignment, script_value) + # except JavaException as err: + # print("Java Exception in the script {}", err) + # self.set_resource_data_value(resource_assignment, "ERROR") + except Exception as err: + print("Python Exception in the script {}", err) + # self.set_resource_data_value(resource_assignment, "ERROR") + return None + + def recover(self, runtime_exception): + print("Exception in the script {}", runtime_exception) + # print self.addError(runtime_exception.cause.message) + return None diff --git a/cds-regression-test/cba/resource-resolution/TOSCA-Metadata/TOSCA.meta b/cds-regression-test/cba/resource-resolution/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..bb9b59a --- /dev/null +++ b/cds-regression-test/cba/resource-resolution/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/resource-resolution.json +Template-Tags: test, regression +Template-Name: RT-resource-resolution +Template-Version: 1.0.0 +Template-Type: DEFAULT
\ No newline at end of file diff --git a/cds-regression-test/cba/resource-resolution/Templates/hello-world-jinja-mapping.json b/cds-regression-test/cba/resource-resolution/Templates/hello-world-jinja-mapping.json new file mode 100644 index 0000000..395e7a1 --- /dev/null +++ b/cds-regression-test/cba/resource-resolution/Templates/hello-world-jinja-mapping.json @@ -0,0 +1,115 @@ +[ + { + "name": "j_default", + "input-param": true, + "property": { + "type": "string", + "default": "ok" + }, + "dictionary-name": "input-source", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "j_input", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "input-source", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "j_python", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "properties-capability-source", + "dictionary-source": "capability", + "dependencies": [] + }, + { + "name": "j_kotlin", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "kotlin-script", + "dictionary-source": "capability", + "dependencies": [] + }, + { + "name": "from_suspend_function", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "kotlin-script", + "dictionary-source": "capability", + "dependencies": [] + }, + { + "name": "j_db", + "input-param": true, + "property": { + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "dictionary-name": "RT-db", + "dictionary-source": "processor-db" + }, + { + "name": "j_get", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-get", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "j_post", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-post", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "j_put", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-put", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "j_patch", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-patch", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "j_del", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-delete", + "dictionary-source": "sdnc", + "dependencies": [] + } +] diff --git a/cds-regression-test/cba/resource-resolution/Templates/hello-world-template.jinja b/cds-regression-test/cba/resource-resolution/Templates/hello-world-template.jinja new file mode 100644 index 0000000..19947b5 --- /dev/null +++ b/cds-regression-test/cba/resource-resolution/Templates/hello-world-template.jinja @@ -0,0 +1,19 @@ +{ + "default": "{{ j_default }}", + "input": "{{ j_input }}", + "script": { + "python": "{{ j_python }}", + "kotlin": { + "base": "{{ j_kotlin }}" + "from suspend function": "{{ from_suspend_function }}" + } + }, + "db": "{{ j_db[0].value }}", + "rest": { + "GET": "{{j_get}}", + "POST": "{{j_post}}", + "PUT": "{{j_put}}", + "PATCH": "{{j_patch}}", + "DELETE": "{{j_del}}" + } +} diff --git a/cds-regression-test/cba/resource-resolution/Templates/hello-world-template.vtl b/cds-regression-test/cba/resource-resolution/Templates/hello-world-template.vtl new file mode 100644 index 0000000..f821770 --- /dev/null +++ b/cds-regression-test/cba/resource-resolution/Templates/hello-world-template.vtl @@ -0,0 +1,16 @@ +{ + "default": "${v_default}", + "input": "${v_input}", + "script": { + "python": "${v_python}", + "kotlin": "${v_kotlin}" + }, + "db": "${v_db.get(0).value}", + "rest": { + "GET": "${v_get}", + "POST": "${v_post}", + "PUT": "${v_put}", + "PATCH": "${v_patch}", + "DELETE": "${v_del}" + } +} diff --git a/cds-regression-test/cba/resource-resolution/Templates/hello-world-velocity-mapping.json b/cds-regression-test/cba/resource-resolution/Templates/hello-world-velocity-mapping.json new file mode 100644 index 0000000..4314908 --- /dev/null +++ b/cds-regression-test/cba/resource-resolution/Templates/hello-world-velocity-mapping.json @@ -0,0 +1,105 @@ +[ + { + "name": "v_default", + "input-param": true, + "property": { + "type": "string", + "default": "ok" + }, + "dictionary-name": "input-source", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "v_input", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "input-source", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "v_python", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "properties-capability-source", + "dictionary-source": "capability", + "dependencies": [] + }, + { + "name": "v_kotlin", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "kotlin-script", + "dictionary-source": "capability", + "dependencies": [] + }, + { + "name": "v_db", + "input-param": true, + "property": { + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "dictionary-name": "RT-db", + "dictionary-source": "processor-db" + }, + { + "name": "v_get", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-get", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "v_post", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-post", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "v_put", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-put", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "v_patch", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-patch", + "dictionary-source": "sdnc", + "dependencies": [] + }, + { + "name": "v_del", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "RT-rest-delete", + "dictionary-source": "sdnc", + "dependencies": [] + } +] |