summaryrefslogtreecommitdiffstats
path: root/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python
diff options
context:
space:
mode:
Diffstat (limited to 'components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python')
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py54
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py18
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SampleRAProcessor.py29
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/__init__.py0
4 files changed, 101 insertions, 0 deletions
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py
new file mode 100644
index 000000000..94cd72a48
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/NetconfRpcExample.py
@@ -0,0 +1,54 @@
+# Copyright (c) 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.
+
+import netconf_constant
+from common import ResolutionHelper
+from java.lang import Exception as JavaException
+from netconfclient import NetconfClient
+from org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import \
+ NetconfComponentFunction
+
+
+class NetconfRpcExample(NetconfComponentFunction):
+
+ def process(self, execution_request):
+ try:
+ log = globals()[netconf_constant.SERVICE_LOG]
+ print(globals())
+ nc = NetconfClient(log, self, "netconf-connection")
+ rr = ResolutionHelper(self)
+
+ payload = rr.resolve_and_generate_message_from_template_prefix("hostname")
+
+ nc.connect()
+ response = nc.lock()
+ if not response.isSuccess():
+ log.error(response.errorMessage)
+
+ nc.edit_config(message_content=payload, edit_default_peration="none")
+ nc.validate()
+ nc.discard_change()
+ nc.validate()
+ nc.commit()
+ nc.unlock()
+ nc.disconnect()
+
+ except JavaException, err:
+ log.error("Java Exception in the script {}", err)
+ except Exception, err:
+ log.error("Python Exception in the script {}", err)
+
+ 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..890481219
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py
@@ -0,0 +1,18 @@
+from abstract_blueprint_function import AbstractPythonComponentFunction
+from blueprint_constants import *
+
+
+class SamplePythonComponentNode(AbstractPythonComponentFunction):
+
+ def __init__(self):
+ AbstractPythonComponentFunction.__init__(self)
+
+ def process(self, execution_request):
+ AbstractPythonComponentFunction.process(self, execution_request)
+ print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None
+
+ def recover(self, runtime_exception, execution_request):
+ AbstractPythonComponentFunction.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/SampleRAProcessor.py b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SampleRAProcessor.py
new file mode 100644
index 000000000..30b9ff951
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SampleRAProcessor.py
@@ -0,0 +1,29 @@
+from abstract_ra_processor import AbstractRAProcessor
+from blueprint_constants import *
+
+
+class SampleRAProcessor(AbstractRAProcessor):
+
+ def __init__(self):
+ AbstractRAProcessor.__init__(self)
+
+ def process(self, execution_request):
+
+ AbstractRAProcessor.process(self, execution_request)
+ print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+ if self.ra_valid is True:
+ value = self.resolve_values_script(execution_request, self.value_to_resolve)
+ self.set_resource_data_value(execution_request, value)
+ else:
+ raise BluePrintProcessorException("Error on resource assignment. Message = " + self.error_message)
+ return None
+
+ def recover(self, runtime_exception, execution_request):
+ AbstractRAProcessor.recover(self, runtime_exception, execution_request)
+ print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None
+
+ def resolve_values_script(self, execution_request, value_to_resolve):
+ # TODO : DO business logic here
+ print "Resolve value for " + value_to_resolve + " here..."
+ return "test_python"
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