aboutsummaryrefslogtreecommitdiffstats
path: root/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh <brindasanth@in.ibm.com>2019-02-08 12:15:11 -0500
committerMuthuramalingam, Brinda Santh <brindasanth@in.ibm.com>2019-02-08 12:44:58 -0500
commitada281414b25536118e7b59368d92817ac687c4f (patch)
tree61e7ee85c842c8608f528ae43c8d0411bdeaba7a /components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts
parentc8ec87c77de53f5933a6519e55c1c6d4c6be6530 (diff)
Refactor test blueprint catalog
Change-Id: I948067b25787c7a79f769ac4055c34ffdd2f172d Issue-ID: CCSDK-1047 Signed-off-by: Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts')
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts44
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts46
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py50
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py12
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/__init__.py0
5 files changed, 152 insertions, 0 deletions
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts
new file mode 100644
index 000000000..f1da61407
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ResourceAssignmentProcessor.cba.kts
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2017-2018 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 org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.*
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintScriptsService
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
+
+open class ScriptResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+
+ lateinit var resourceAssignment: ResourceAssignment
+
+ override fun getName(): String {
+ return "resource-assignment-processor-custom-capability"
+ }
+
+ override fun process(resourceAssignment: ResourceAssignment) {
+ this.resourceAssignment = resourceAssignment
+ }
+
+ override fun prepareResponse(): ResourceAssignment {
+ return resourceAssignment
+ }
+
+ override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
+ TODO("To Implement")
+ }
+
+} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts
new file mode 100644
index 000000000..184c49335
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/kotlin/ScriptComponent.cba.kts
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2017-2018 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 org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
+
+open class SampleKotlinComponent : BlueprintFunctionNode<String, String> {
+
+ override fun getName(): String {
+ return "my Name"
+ }
+
+ override fun prepareRequest(executionRequest: String): String {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun process(executionRequest: String) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: String) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun prepareResponse(): String {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun apply(t: String): String {
+ return "Successfully Executed Scripts"
+ }
+}
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py
new file mode 100644
index 000000000..4db7c731b
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/DefaultGetNetConfig.py
@@ -0,0 +1,50 @@
+import netconf_constant
+from netconfclient import NetconfClient
+from java.lang import Exception
+from abstract_blueprint_function import AbstractPythonComponentFunction
+from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import NetconfRpcService
+from org.onap.ccsdk.apps.controllerblueprints.core.utils import JacksonUtils
+from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces import DeviceInfo
+from org.onap.ccsdk.apps.controllerblueprints.core.service import BluePrintRuntimeService
+
+
+class DefaultGetNetConfig(AbstractPythonComponentFunction):
+ def process(self, execution_request):
+ try:
+ log = globals()[netconf_constant.SERVICE_LOG]
+ print(globals())
+ #requestId = globals()[netconf_constant.PARAM_REQUEST_ID]
+ requestId = '1234'
+
+ bluePrintRuntimeService = globals()['bluePrintRuntimeService']
+
+ capabilityProperty = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device","netconf")
+
+ log.info("capabilityProperty {}",capabilityProperty)
+ netconfService = NetconfRpcService()
+ nc = NetconfClient(log, netconfService)
+
+ nc.connect(netconfService.getNetconfDeviceInfo(capabilityProperty))
+ runningConfigTemplate = "runningconfig-template"
+
+ runningConfigMessageId = "get-config-" + requestId
+
+ deviceResponse = nc.getConfig(messageId=runningConfigMessageId,
+ filter=runningConfigTemplate)
+
+ log.info("Get Running Config Response {} ", deviceResponse.responseMessage)
+ if(deviceResponse !='null') :
+ status = deviceResponse.status
+ responseData = "{}"
+ if (deviceResponse.status != netconf_constant.STATUS_SUCCESS and deviceResponse.errorMessage != 'null'):
+ errorMessage = "Get Running Config Failure ::"+ deviceResponse.errorMessage
+
+ except Exception, err:
+ log.info("Exception in the script {}",err.getMessage())
+ status = netconf_constant.STATUS_FAILURE
+ errorMessage = "Get Running Config Failure ::"+err.getMessage()
+
+ def recover(self, runtime_exception, execution_request):
+ print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None
+
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py
new file mode 100644
index 000000000..0a583dc57
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py
@@ -0,0 +1,12 @@
+from abstract_blueprint_function import AbstractPythonComponentFunction
+from blueprint_constants import *
+
+class SamplePythonComponentNode(AbstractPythonComponentFunction):
+
+ def process(self, execution_request):
+ print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None
+
+ def recover(self, runtime_exception, execution_request):
+ print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/__init__.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/__init__.py