From 421823b343881c6d1690be8b1082a878764635f2 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Mon, 19 Nov 2018 12:48:31 -0500 Subject: Implement Base Jython Executor function. Change-Id: I3fb066a021de4a7b3aa1fce7f6c191bc3944fb51 Issue-ID: CCSDK-696 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../scripts/python/ccsdk_blueprints/__init__.py | 0 .../abstract_blueprint_function.py | 11 +++++++++++ .../python/ccsdk_blueprints/blueprint_constants.py | 23 ++++++++++++++++++++++ .../ccsdk_blueprints/blueprint_runtime_service.py | 13 ++++++++++++ .../ccsdk_blueprints/sample_blueprint_component.py | 12 +++++++++++ 5 files changed, 59 insertions(+) create mode 100644 components/scripts/python/ccsdk_blueprints/__init__.py create mode 100644 components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py create mode 100644 components/scripts/python/ccsdk_blueprints/blueprint_constants.py create mode 100644 components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py create mode 100644 components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py (limited to 'components/scripts/python/ccsdk_blueprints') 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 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..0ddab16e7 --- /dev/null +++ b/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py @@ -0,0 +1,11 @@ +from org.onap.ccsdk.apps.blueprintsprocessor.services.execution import AbstractComponentFunction + +class AbstractPythonComponentFunction(AbstractComponentFunction): + + def process(self, execution_request): + print "Processing calling.." + return None + + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + return None 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..2ec95f312 --- /dev/null +++ b/components/scripts/python/ccsdk_blueprints/blueprint_constants.py @@ -0,0 +1,23 @@ + +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" + +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..022b47244 --- /dev/null +++ b/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py @@ -0,0 +1,13 @@ +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) 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..62665dc8f --- /dev/null +++ b/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py @@ -0,0 +1,12 @@ +from abstract_blueprint_function import AbstractPythonComponentFunction +from blueprint_constants import * + +class SampleBlueprintComponent(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 -- cgit From d73ea79d225154e9edfd88901374cf5ed33947d1 Mon Sep 17 00:00:00 2001 From: Steve Alphonse Siani Date: Mon, 11 Feb 2019 23:35:16 -0500 Subject: Jython execution component and service Change-Id: I2610e73a9c7ba073b5fa9d148dcd6fb5b9ad9ae3 Issue-ID: CCSDK-696 Signed-off-by: Steve Alphonse Siani --- .../python/ccsdk_blueprints/abstract_ra_processor.py | 12 ++++++++++++ .../python/ccsdk_blueprints/resource_assignment_utils.py | 14 ++++++++++++++ .../ccsdk_blueprints/sample_ra_processor_function.py | 12 ++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py create mode 100644 components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py create mode 100644 components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py (limited to 'components/scripts/python/ccsdk_blueprints') 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..f7d54ea88 --- /dev/null +++ b/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py @@ -0,0 +1,12 @@ +from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor import ResourceAssignmentProcessor + + +class AbstractRAProcessor(ResourceAssignmentProcessor): + + def process(self, execution_request): + print "Processing calling.." + return None + + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + return None diff --git a/components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py b/components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py new file mode 100644 index 000000000..53cc5d708 --- /dev/null +++ b/components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py @@ -0,0 +1,14 @@ +class ResourceAssignmentUtils: + + + @classmethod + def set_ressource_data_value(cls, ra, runtime_exception, value): + print "Set resource here..." + # TODO + return None + + @staticmethod + def set_ressource_value(ra, runtime_exception, value): + print "Set resource here..." + # TODO + return None \ No newline at end of file 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..8f68bfec0 --- /dev/null +++ b/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py @@ -0,0 +1,12 @@ +from abstract_ra_processor import AbstractRAProcessor + + +class SampleRAProcessorFunction(AbstractRAProcessor): + + def process(self, execution_request): + print "Processing calling.." + return None + + def recover(self, runtime_exception, execution_request): + print "Recovering calling.." + return None -- cgit From 1f53e61c6f5af7fdcd6be97ba3aff4d84694dc05 Mon Sep 17 00:00:00 2001 From: Steve Alphonse Siani Date: Wed, 13 Feb 2019 15:45:50 -0500 Subject: Python library for Jython execution Change-Id: Iee2701b4dade7207950f17c92ea1265c361cf803 Issue-ID: CCSDK-696 Signed-off-by: Steve Alphonse Siani --- .../abstract_blueprint_function.py | 8 +++- .../ccsdk_blueprints/abstract_ra_processor.py | 43 ++++++++++++++++++++-- .../python/ccsdk_blueprints/blueprint_constants.py | 3 ++ .../ccsdk_blueprints/blueprint_runtime_service.py | 8 ++++ .../ccsdk_blueprints/resource_assignment_utils.py | 14 ------- .../ccsdk_blueprints/sample_blueprint_component.py | 10 ++++- .../sample_ra_processor_function.py | 10 ++++- 7 files changed, 73 insertions(+), 23 deletions(-) delete mode 100644 components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py (limited to 'components/scripts/python/ccsdk_blueprints') diff --git a/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py b/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py index 0ddab16e7..1ffa75d4b 100644 --- a/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py +++ b/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py @@ -1,11 +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.." + print "Processing calling from parent..." return None def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + 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 index f7d54ea88..2cacaf526 100644 --- a/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py +++ b/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py @@ -1,12 +1,49 @@ from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor import ResourceAssignmentProcessor +from blueprint_constants import * +from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils import ResourceAssignmentUtils +from org.onap.ccsdk.apps.controllerblueprints.core import BluePrintProcessorException +from java.lang import Exception class AbstractRAProcessor(ResourceAssignmentProcessor): + def __init__(self): + ResourceAssignmentProcessor.__init__(self) + self.status = PROPERTY_BLUEPRINT_STATUS_SUCCESS + self.error_message = None + self.ra_valid = False + self.value_to_resolve = None + def process(self, execution_request): - print "Processing calling.." - return None + print "Processing calling from parent..." + try: + self.ra_valid = self.validate(execution_request) + self.value_to_resolve = execution_request.name + except Exception, e: + self.status = PROPERTY_BLUEPRINT_STATUS_FAILURE + self.error_message = "Get Running python scripting Failure :" + e.getMessage() def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + print "Recovering calling from parent.." + return None + + def set_resource_data_value(self, execution_request, value): + try: + if value is not None: + ResourceAssignmentUtils.Companion.setResourceDataValue(execution_request, self.raRuntimeService, value) + else: + ResourceAssignmentUtils.Companion.setFailedResourceDataValue(execution_request, "Fail to resole value") + except BluePrintProcessorException, err: + raise BluePrintProcessorException("Error on resource assignment. Message = " + err.message) + return None + + @staticmethod + def validate(ra): + if ra.name is None or ra.name is None: + raise Exception("Failed getting value for template key (" + ra.name + ") and " + + "dictionary key (" + ra.dictionaryName + + ") of type (" + ra.type + ")") + else: + pass + return True diff --git a/components/scripts/python/ccsdk_blueprints/blueprint_constants.py b/components/scripts/python/ccsdk_blueprints/blueprint_constants.py index 2ec95f312..50246773f 100644 --- a/components/scripts/python/ccsdk_blueprints/blueprint_constants.py +++ b/components/scripts/python/ccsdk_blueprints/blueprint_constants.py @@ -6,6 +6,9 @@ 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" diff --git a/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py b/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py index 022b47244..7c7beff7f 100644 --- a/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py +++ b/components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py @@ -11,3 +11,11 @@ class BluePrintRuntimeService: 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/resource_assignment_utils.py b/components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py deleted file mode 100644 index 53cc5d708..000000000 --- a/components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py +++ /dev/null @@ -1,14 +0,0 @@ -class ResourceAssignmentUtils: - - - @classmethod - def set_ressource_data_value(cls, ra, runtime_exception, value): - print "Set resource here..." - # TODO - return None - - @staticmethod - def set_ressource_value(ra, runtime_exception, value): - print "Set resource here..." - # TODO - return None \ No newline at end of file diff --git a/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py b/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py index 62665dc8f..a1e6c5d3b 100644 --- a/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py +++ b/components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py @@ -1,12 +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): - print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH + super(SamplePythonComponentNode, self).process(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 + 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 index 8f68bfec0..6ec5d82ab 100644 --- a/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py +++ b/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py @@ -1,12 +1,18 @@ from abstract_ra_processor import AbstractRAProcessor +from blueprint_constants import * class SampleRAProcessorFunction(AbstractRAProcessor): + def __init__(self): + AbstractRAProcessor.__init__(self) + def process(self, execution_request): - print "Processing calling.." + AbstractRAProcessor.process(self, execution_request) + print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH return None def recover(self, runtime_exception, execution_request): - print "Recovering calling.." + AbstractRAProcessor.recover(self, runtime_exception, execution_request) + print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH return None -- cgit From e950b19db14ee325416f8e73420d682d07e5e6cf Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Thu, 28 Feb 2019 08:59:20 -0500 Subject: Adjust python script for resource-assignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie96b4dc99c4da461a5fe7dfb424fdec6c221f9e0 Issue-ID: CCSDK-1091 Signed-off-by: Alexis de Talhouët --- .../ccsdk_blueprints/abstract_ra_processor.py | 56 +++++++--------------- .../sample_ra_processor_function.py | 10 ++-- 2 files changed, 21 insertions(+), 45 deletions(-) (limited to 'components/scripts/python/ccsdk_blueprints') diff --git a/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py b/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py index 2cacaf526..6489b1e73 100644 --- a/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py +++ b/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py @@ -1,49 +1,29 @@ -from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor import ResourceAssignmentProcessor -from blueprint_constants import * -from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils import ResourceAssignmentUtils -from org.onap.ccsdk.apps.controllerblueprints.core import BluePrintProcessorException -from java.lang import Exception +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 __init__(self): - ResourceAssignmentProcessor.__init__(self) - self.status = PROPERTY_BLUEPRINT_STATUS_SUCCESS - self.error_message = None - self.ra_valid = False - self.value_to_resolve = None - - def process(self, execution_request): - print "Processing calling from parent..." - try: - self.ra_valid = self.validate(execution_request) - self.value_to_resolve = execution_request.name - except Exception, e: - self.status = PROPERTY_BLUEPRINT_STATUS_FAILURE - self.error_message = "Get Running python scripting Failure :" + e.getMessage() + def process(self, resource_assignment): + print "Processing.." + return None - def recover(self, runtime_exception, execution_request): - print "Recovering calling from parent.." + def recover(self, runtime_exception, resource_assignment): + print "Recovering.." return None - def set_resource_data_value(self, execution_request, value): + def set_resource_data_value(self, resource_assignment, value): try: if value is not None: - ResourceAssignmentUtils.Companion.setResourceDataValue(execution_request, self.raRuntimeService, value) + ResourceAssignmentUtils.Companion.setResourceDataValue( + resource_assignment, self.raRuntimeService, value) else: - ResourceAssignmentUtils.Companion.setFailedResourceDataValue(execution_request, "Fail to resole value") + ResourceAssignmentUtils.Companion.setFailedResourceDataValue( + resource_assignment, "Fail to resolve value") except BluePrintProcessorException, err: - raise BluePrintProcessorException("Error on resource assignment. Message = " + err.message) - - return None - - @staticmethod - def validate(ra): - if ra.name is None or ra.name is None: - raise Exception("Failed getting value for template key (" + ra.name + ") and " + - "dictionary key (" + ra.dictionaryName + - ") of type (" + ra.type + ")") - else: - pass - return True + raise BluePrintProcessorException( + "Error on resource assignment. Message = " + err.message) diff --git a/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py b/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py index 6ec5d82ab..fa821082e 100644 --- a/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py +++ b/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py @@ -4,15 +4,11 @@ from blueprint_constants import * class SampleRAProcessorFunction(AbstractRAProcessor): - def __init__(self): - AbstractRAProcessor.__init__(self) - - def process(self, execution_request): - AbstractRAProcessor.process(self, execution_request) + 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, execution_request): - AbstractRAProcessor.recover(self, runtime_exception, execution_request) + def recover(self, runtime_exception, resource_assignment): print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH return None -- cgit