60 likes | 229 Views
Script Invocation Conventions. TOSCA Interop SC 2012-12-07. Introduction / Background. Current interop use case SugarCRM provides simple scripts as Implementation Artifacts for lifecycle operations of Node Types
E N D
Script Invocation Conventions TOSCA Interop SC2012-12-07
Introduction / Background • Current interop use case SugarCRM provides simple scripts as Implementation Artifacts for lifecycle operations of Node Types • Conventions have to be defined to allow for interoperable invocation of those scripts in different TOSCA implementations • References to actual scripts in CSAR • Parameter passing from model to script • … • Note: bindings to several script languages have to be defined. For now, only bash scripts are used, so we concentrate on a bash binding.
Script Artifact Definitions • Non-normative Artifact Type “ScriptArtifact” defined in interop use case Has to be documented; candidate for normative definition in TOSCA vNext • ScriptLanguage: specifies the used script language impact on invocation convention, parameters passing, etc. • PrimaryScript: specifies the “entry script” to be invoked in cases where multiple files are referenced by an ArtifactTemplate (e.g. is main script brings with it additional helper or library files) • ArtifactReferences element uses Ant fileset like notation • reference attribute can specify a file or directory • If reference points to a directory, files in the directory to be referenced by the ArtifactTemplate are specified thru include and exclude patterns • Relative reference URIs in ArtifactTemplate elements are interpreted relative to the CSAR root directory <ArtifactTemplate id="at-c1ab1a58-91f1-49ec-a3e0-57f46e3d72e1“ type="ns1:ScriptArtifact"> <Properties> <ns1:ScriptArtifactProperties xmlns:ns1="http://docs.oasis-open.org/tosca/ns/2011/12/ToscaBaseTypes" xmlns="http://docs.oasis-open.org/tosca/ns/2011/12/ToscaBaseTypes"> <ScriptLanguage>sh</ScriptLanguage> <PrimaryScript>scripts/MySQL/configure.sh</PrimaryScript> </ns1:ScriptArtifactProperties> </Properties> <ArtifactReferences> <ArtifactReference reference="scripts/MySQL"> <Include pattern="configure.sh"/> </ArtifactReference> </ArtifactReferences> </ArtifactTemplate>
Invocation Conventions for bash scripts • Parameters are passed to script as environment variables • Script can access parameters by name using $<parameter name> notation • Scripts in current interop example are supposed to be executed on the target environment (i.e. VMs created during service instantiation) • Invocation mechanism • Make script (incl. potential helper files) available on target environment • Create a new bash • Set all parameters to be passed to script as environment parameters • Invoke script • Process return code; read out potential return parameters the script may have written to environment variables
Parameter conventions for scripts of Node Type Operations • Pass all properties of the Node instance (instantiated Node Template) to script as environment variables • Pass special parameter like “PublicIP” as environment variables • Denotes the public IP address of the VM on which the Node is deployed (i.e. avoids having to define a PublicIP property for each Node Type) • Example: configure.sh of SugarCRMApplication • NodeTypeSugarCRMApplication defines parameters AdminUser, AdminPassword, etc. • Script can access parameters like$AdminUser$AdminPassword…
Parameter passing for scripts of Relationship Type Operations • Pass all properties of the Relationship instance (instantiated Relationship Template) as environment variables • Accessible by script as $<relationship property name> • Pass all properties (and special properties like PublicIP) of the source Node instance of the relationship as environment variables with prefix “Source_” • Accessible by script as$Source_<source node property name> • Pass all properties (and special properties like PublicIP) of the target Node instance of the relationship as environment variables with prefix “Target_” • Accessible by script as$Target_<target node property name> • Example: connectToDatabase.sh of MySQLDatabaseConnection…sed -i -e 's/YOURDBHOST/'${Target_PublicIP}:${Target_mySqlPort}'/' $ResponseFilesed -i -e 's/YOURDBNAME/'${Target_DBName}'/' $ResponseFilesed -i -e 's/YOURDBUSER/'${Target_DBUser}'/' $ResponseFile…