aboutsummaryrefslogtreecommitdiffstats
path: root/components/scripts/python
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-02-15 21:25:27 +0000
committerGerrit Code Review <gerrit@onap.org>2019-02-15 21:25:27 +0000
commitb1a59abb5c37f0bf439bfc14fd5bdf27881784f5 (patch)
tree8b2fdfa1ad993f4fc20c746aa2e01eb18fa3316c /components/scripts/python
parent01174642f5c1a9b688e4d6713b3950642fc77836 (diff)
parentcfc807955c9cae60bce983e4f4ac951bf37ecc20 (diff)
Merge "Python library for Jython execution"
Diffstat (limited to 'components/scripts/python')
-rw-r--r--components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py8
-rw-r--r--components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py43
-rw-r--r--components/scripts/python/ccsdk_blueprints/blueprint_constants.py3
-rw-r--r--components/scripts/python/ccsdk_blueprints/blueprint_runtime_service.py8
-rw-r--r--components/scripts/python/ccsdk_blueprints/resource_assignment_utils.py14
-rw-r--r--components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py10
-rw-r--r--components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py10
7 files changed, 73 insertions, 23 deletions
diff --git a/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py b/components/scripts/python/ccsdk_blueprints/abstract_blueprint_function.py
index 0ddab16e..1ffa75d4 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 f7d54ea8..2cacaf52 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 2ec95f31..50246773 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 022b4724..7c7beff7 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 53cc5d70..00000000
--- 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 62665dc8..a1e6c5d3 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 8f68bfec..6ec5d82a 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