summaryrefslogtreecommitdiffstats
path: root/components/scripts
diff options
context:
space:
mode:
authorSteve Alphonse Siani <alphonse.steve.siani.djissitchi@ibm.com>2019-02-13 15:45:50 -0500
committerSteve Alphonse Siani <alphonse.steve.siani.djissitchi@ibm.com>2019-02-15 16:05:09 -0500
commit1f53e61c6f5af7fdcd6be97ba3aff4d84694dc05 (patch)
treebb75a137d0a42ae05441cad18816be9a7910ba05 /components/scripts
parentf7c657993d50ed855a1ac359b5dd325960a6051b (diff)
Python library for Jython execution
Change-Id: Iee2701b4dade7207950f17c92ea1265c361cf803 Issue-ID: CCSDK-696 Signed-off-by: Steve Alphonse Siani <alphonse.steve.siani.djissitchi@ibm.com>
Diffstat (limited to 'components/scripts')
-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 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