aboutsummaryrefslogtreecommitdiffstats
path: root/components/scripts/python
diff options
context:
space:
mode:
Diffstat (limited to 'components/scripts/python')
-rw-r--r--components/scripts/python/ccsdk_blueprints/__init__.py0
-rw-r--r--components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py15
-rw-r--r--components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py29
-rw-r--r--components/scripts/python/ccsdk_blueprints/blueprint_constants.py26
-rw-r--r--components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py21
-rw-r--r--components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py18
-rw-r--r--components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py14
-rw-r--r--components/scripts/python/ccsdk_netconf/__init__.py0
-rw-r--r--components/scripts/python/ccsdk_netconf/common.py28
-rw-r--r--components/scripts/python/ccsdk_netconf/netconf_constant.py15
-rw-r--r--components/scripts/python/ccsdk_netconf/netconfclient.py62
11 files changed, 228 insertions, 0 deletions
diff --git a/components/scripts/python/ccsdk_blueprints/__init__.py b/components/scripts/python/ccsdk_blueprints/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/components/scripts/python/ccsdk_blueprints/__init__.py
diff --git a/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py b/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py
new file mode 100644
index 000000000..1ffa75d4b
--- /dev/null
+++ b/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py
@@ -0,0 +1,15 @@
+from org.onap.ccsdk.apps.blueprintsprocessor.services.execution import AbstractComponentFunction
+
+
+class AbstractPythonComponentFunction(AbstractComponentFunction):
+
+ def __init__(self):
+ AbstractComponentFunction.__init__(self)
+
+ def process(self, execution_request):
+ print "Processing calling from parent..."
+ return None
+
+ def recover(self, runtime_exception, execution_request):
+ print "Recovering calling from parent..."
+ return None
diff --git a/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py b/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py
new file mode 100644
index 000000000..6489b1e73
--- /dev/null
+++ b/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py
@@ -0,0 +1,29 @@
+from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor import \
+ ResourceAssignmentProcessor
+from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils import \
+ ResourceAssignmentUtils
+from org.onap.ccsdk.apps.controllerblueprints.core import \
+ BluePrintProcessorException
+
+
+class AbstractRAProcessor(ResourceAssignmentProcessor):
+
+ def process(self, resource_assignment):
+ print "Processing.."
+ return None
+
+ def recover(self, runtime_exception, resource_assignment):
+ print "Recovering.."
+ return None
+
+ def set_resource_data_value(self, resource_assignment, value):
+ try:
+ if value is not None:
+ ResourceAssignmentUtils.Companion.setResourceDataValue(
+ resource_assignment, self.raRuntimeService, value)
+ else:
+ ResourceAssignmentUtils.Companion.setFailedResourceDataValue(
+ resource_assignment, "Fail to resolve value")
+ except BluePrintProcessorException, err:
+ raise BluePrintProcessorException(
+ "Error on resource assignment. Message = " + err.message)
diff --git a/components/scripts/python/ccsdk_blueprints/blueprint_constants.py b/components/scripts/python/ccsdk_blueprints/blueprint_constants.py
new file mode 100644
index 000000000..50246773f
--- /dev/null
+++ b/components/scripts/python/ccsdk_blueprints/blueprint_constants.py
@@ -0,0 +1,26 @@
+
+PROPERTY_BLUEPRINT_PROCESS_ID= "blueprint-process-id"
+PROPERTY_BLUEPRINT_BASE_PATH= "blueprint-basePath"
+PROPERTY_BLUEPRINT_RUNTIME= "blueprint-runtime"
+PROPERTY_BLUEPRINT_INPUTS_DATA= "blueprint-inputs-data"
+PROPERTY_BLUEPRINT_CONTEXT= "blueprint-context"
+PROPERTY_BLUEPRINT_NAME= "template_name"
+PROPERTY_BLUEPRINT_VERSION= "template_version"
+PROPERTY_BLUEPRINT_USER_SYSTEM= "System"
+PROPERTY_BLUEPRINT_STATUS_SUCCESS= "success"
+PROPERTY_BLUEPRINT_STATUS_FAILURE= "failure"
+
+METADATA_USER_GROUPS = "user-groups"
+METADATA_TEMPLATE_NAME = "template_name"
+METADATA_TEMPLATE_VERSION = "template_version"
+METADATA_TEMPLATE_AUTHOR = "template_author"
+METADATA_TEMPLATE_TAGS = "template_tags"
+METADATA_WORKFLOW_NAME = "workflow_name"
+
+PAYLOAD_DATA = "payload-data"
+PROPERTY_CURRENT_STEP = "current-step"
+PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template"
+PROPERTY_CURRENT_INTERFACE = "current-interface"
+PROPERTY_CURRENT_OPERATION = "current-operation"
+PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation"
+PROPERTY_EXECUTION_REQUEST = "execution-request"
diff --git a/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py b/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py
new file mode 100644
index 000000000..7c7beff7f
--- /dev/null
+++ b/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py
@@ -0,0 +1,21 @@
+class BluePrintRuntimeService:
+
+ def __init__(self, bps):
+ self.bps = bps
+
+ def resolveNodeTemplateArtifact(self, node_template_name, artifact_name):
+ return self.bps.resolveNodeTemplateArtifact(node_template_name, artifact_name)
+
+ def setNodeTemplateAttributeValue(self, nodeTemplateName, attributeName, value):
+ return self.bps.setNodeTemplateAttributeValue(nodeTemplateName, attributeName, value)
+
+ def setNodeTemplatePropertyValue(self, nodeTemplateName, propertyName, value):
+ return self.bps.setNodeTemplatePropertyValue(nodeTemplateName, propertyName, value)
+
+ def put_resolution_store(self, ra_name, value):
+ self.bps.putResolutionStore(ra_name, value)
+ return None
+
+ def put_dictionary_store(self, ra_dictionary_name, value):
+ self.bps.putResolutionStore(ra_dictionary_name, value)
+ return None
diff --git a/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py b/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py
new file mode 100644
index 000000000..a1e6c5d3b
--- /dev/null
+++ b/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py
@@ -0,0 +1,18 @@
+from abstract_blueprint_function import AbstractPythonComponentFunction
+from blueprint_constants import *
+
+
+class SampleBlueprintComponent(AbstractPythonComponentFunction):
+
+ def __init__(self):
+ AbstractPythonComponentFunction.__init__(self)
+
+ def process(self, execution_request):
+ super(SamplePythonComponentNode, self).process(execution_request)
+ print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None
+
+ def recover(self, runtime_exception, execution_request):
+ super(SamplePythonComponentNode, self).recover(runtime_exception, execution_request)
+ print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None
diff --git a/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py b/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py
new file mode 100644
index 000000000..fa821082e
--- /dev/null
+++ b/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py
@@ -0,0 +1,14 @@
+from abstract_ra_processor import AbstractRAProcessor
+from blueprint_constants import *
+
+
+class SampleRAProcessorFunction(AbstractRAProcessor):
+
+ def process(self, resource_assignment):
+ print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+ self.set_resource_data_value(resource_assignment, "")
+ return None
+
+ def recover(self, runtime_exception, resource_assignment):
+ print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+ return None
diff --git a/components/scripts/python/ccsdk_netconf/__init__.py b/components/scripts/python/ccsdk_netconf/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/components/scripts/python/ccsdk_netconf/__init__.py
diff --git a/components/scripts/python/ccsdk_netconf/common.py b/components/scripts/python/ccsdk_netconf/common.py
new file mode 100644
index 000000000..f161e29ff
--- /dev/null
+++ b/components/scripts/python/ccsdk_netconf/common.py
@@ -0,0 +1,28 @@
+# 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.
+
+class ResolutionHelper:
+
+ def __init__(self, component_function):
+ self.component_function = component_function
+
+ def resolve_and_generate_message_from_template_prefix(self, artifact_prefix):
+ return self.component_function.resolveAndGenerateMessage(artifact_prefix)
+
+ def resolve_and_generate_message(self, artifact_mapping, artifact_template):
+ return self.component_function.resolveAndGenerateMessage(artifact_mapping,
+ artifact_template)
+
+ def retrieve_resolved_template_from_database(self, key, artifact_template):
+ return self.component_function.resolveFromDatabase(key, artifact_template)
diff --git a/components/scripts/python/ccsdk_netconf/netconf_constant.py b/components/scripts/python/ccsdk_netconf/netconf_constant.py
new file mode 100644
index 000000000..534ca9e13
--- /dev/null
+++ b/components/scripts/python/ccsdk_netconf/netconf_constant.py
@@ -0,0 +1,15 @@
+SERVICE_LOG = "log"
+SERVICE_NETCONF = "netconfService"
+SERVICE_MESSAGE = "messageService"
+
+PARAM_REQUEST_ID = "requestId"
+PARAM_ACTION = "action"
+
+STATUS_SUCCESS = "success"
+STATUS_FAILURE = "failure"
+
+CONFIG_TARGET_RUNNING = "running"
+CONFIG_TARGET_CANDIDATE = "candidate"
+CONFIG_DEFAULT_OPERATION_MERGE = "merge"
+CONFIG_DEFAULT_OPERATION_REPLACE = "replace"
+CONFIG_DEFAULT_OPERATION_NONE = "none"
diff --git a/components/scripts/python/ccsdk_netconf/netconfclient.py b/components/scripts/python/ccsdk_netconf/netconfclient.py
new file mode 100644
index 000000000..e263ba8f7
--- /dev/null
+++ b/components/scripts/python/ccsdk_netconf/netconfclient.py
@@ -0,0 +1,62 @@
+from netconf_constant import CONFIG_TARGET_RUNNING, CONFIG_TARGET_CANDIDATE, \
+ CONFIG_DEFAULT_OPERATION_REPLACE
+
+
+class NetconfClient:
+
+ def __init__(self, log, component_function, requirement_name):
+ self.log = log
+ self.component_function = component_function
+ netconf_device = self.component_function.initializeNetconfConnection(
+ requirement_name)
+ self.netconf_rpc_client = netconf_device.netconfRpcService
+ self.netconf_session = netconf_device.netconfSession
+
+ def disconnect(self):
+ self.netconf_session.disconnect()
+ return
+
+ def connect(self):
+ self.netconf_session.connect()
+ return
+
+ def lock(self, config_target=CONFIG_TARGET_CANDIDATE):
+ device_response = self.netconf_rpc_client.lock(config_target)
+ return device_response
+
+ def get_config(self, filter="", config_target=CONFIG_TARGET_RUNNING):
+ device_response = self.netconf_rpc_client.getConfig(filter, config_target)
+ return device_response
+
+ def edit_config(self, message_content, config_target=CONFIG_TARGET_CANDIDATE,
+ edit_default_peration=CONFIG_DEFAULT_OPERATION_REPLACE):
+ device_response = self.netconf_rpc_client.editConfig(message_content,
+ config_target,
+ edit_default_peration)
+ return device_response
+
+ def commit(self, confirmed=False, confirm_timeout=60, persist="",
+ persist_id=""):
+ device_response = self.netconf_rpc_client.commit(confirmed, confirm_timeout,
+ persist, persist_id)
+ return device_response
+
+ def invoke_rpc(self, rpc):
+ device_response = self.netconf_rpc_client.invokeRpc(rpc)
+ return device_response
+
+ def cancel_commit(self, persist_id=""):
+ device_response = self.netconf_rpc_client.cancelCommit(persist_id)
+ return device_response
+
+ def unlock(self, config_target=CONFIG_TARGET_CANDIDATE):
+ device_response = self.netconf_rpc_client.unLock(config_target)
+ return device_response
+
+ def validate(self, config_target=CONFIG_TARGET_CANDIDATE):
+ device_response = self.netconf_rpc_client.validate(config_target)
+ return device_response
+
+ def discard_change(self):
+ device_response = self.netconf_rpc_client.discardConfig()
+ return device_response