Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To design an artifact as a component executor, we should define a Class that inherit AbstractScriptComponentFunction and override function to run actions.

  • Python sampleDefine Artifacts:
Code Block
languagepy
titleDefine a Python Artifact
linenumberstrue
from org.onap.ccsdk.cds.blueprintsprocessor.services.execution import AbstractScriptComponentFunction 

class someArtifact(AbstractScriptComponentFunction):

...


Code Block
languagejava
titleDefine a Kotlin Artifact
linenumberstrue
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction

open class SampleScriptArtifact : AbstractScriptComponentFunction() {

}


  • Implement your Artifact:

An artifact need to implement at least 2 functions in order to be valid:

Code Block
languagepy
titleImplement component process
linenumberstrue
def process(self, resource_assignment):        
        try:
            ######################### Component action here ########################
            #Do action here
            ########################### End ##########################
			
        except JavaException, err:
          log.error("Java Exception in the script {}", err)
        except Exception, err:
          log.error("Python Exception in the script {}", err)
        return None


Code Block
languagepy
titleImplement component recover
linenumberstrue
    def recover(self, runtime_exception, resource_assignment):
        log.error("Exception in the script {}", runtime_exception)
        print self.addError(runtime_exception.cause.message)
        return None


  • Functions available in Artifact script

The main library available while running a Component in CDS is the BlueprintRuntimeService. This provides to the user the Blueprint running context and run-time execution functions.The following shows functions available for all the different Components execution from a python script:

...