Passing parameter/variable values to containers
What options are available to pass a value assiged as a prompted variable/parameter in a plan to a container to resolve a value for a variable/parameter defined in a container which is called by the plan?
Supposed the plan is defined as:
<?xml version="1.0" encoding="UTF-8"?>
<!-- generated by N1 SPS -->
<executionPlan xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' name='setdb' version='5.1' xsi:schemaLocation='http://www.sun.com/schema/SPS plan.xsd' xmlns='http://www.sun.com/schema/SPS' path='/utilities'>
<paramList>
<param name='dbName'></param>
<param displayMode='BOOLEAN' prompt='install container xyz?' default='TRUE' name='do_container_param'></param>
</paramList>
<simpleSteps>
<execNative userToRunAs='root'>
<inputText><![CDATA[
:[dbName];
]]></inputText>
<exec cmd='sh'></exec>
</execNative>
</simpleSteps>
<inlineSubplan planName='install_container_xyz'>
<simpleSteps>
<if>
<condition>
<istrue value=':[do_container_param]'></istrue>
</condition>
<then>
<install blockName='default'>
<component name='xyz.cont' path='/someN1FolderPath'></component>
</install>
</then>
</if>
</simpleSteps>
</inlineSubplan>
</executionPlan>
How can I pass the value assigned to dbName to the container xyz.cont to be used to resolve a value for a variable/parameter in the xyz.cont?
# 1
The new, soon-to-be-released 6.0 version of SPS handles this problem with Component Variables. With this feature, you can specify in the plan what variables to pass to the component blocks.
However, that doesn't help you in the meantime. The sample XML you list isn't quite accurate, but I think I understand what you're after. I cleaned it up a little to make it valid and took out the execNative step (not sure what the intent of that was).
Anyway, here's what I get for the plan:
<?xml version="1.0" encoding="UTF-8"?>
<!-- generated by N1 SPS -->
<executionPlan xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' name='setdb' version='5.1' xsi:schemaLocation='http://www.sun.com/schema/SPS plan.xsd' xmlns='http://www.sun.com/schema/SPS' path='/utilities'>
<paramList>
<param name='dbName' prompt="database name"></param>
<param displayMode='BOOLEAN' prompt='install container xyz?' default='TRUE' name='do_container_param'></param>
</paramList>
<simpleSteps>
<if>
<condition>
<istrue value=':[do_container_param]'></istrue>
</condition>
<then>
<install blockName='newBlock'>
<argList dbName=":[dbName]"/>
<component name='xyz.cont' path='/someN1FolderPath'/>
</install>
</then>
</if>
</simpleSteps>
</executionPlan>
The component would look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!-- generated by N1 SPS -->
<component xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' name='xyz.cont' version='5.1' xsi:schemaLocation='http://www.sun.com/schema/SPS component.xsd' xmlns='http://www.sun.com/schema/SPS'>
<extends>
<type name='system#container'></type>
</extends>
<installList>
<installSteps returns='false' name='newBlock' requireLocking='true'>
<paramList>
<param name='dbName'></param>
</paramList>
<!-- some steps here -->
</installSteps>
</installList>
</component>
Note that you have to rename the block. You can't change the signature of an inherited component block (container component defines block "default". Either create a new block or use an untyped component). I think this is what you're trying to do. Please let me know if I missed.
# 2
The xml schema reads:
<install> Step
The <install> step installs a component onto the target host. This causes the
steps of the named <installSteps> element of the associated component to
be executed. This step can only appear as the child of the <simpleSteps>
element.
The <install> step has the following child elements:
<argList> An optional element that is a list of arguments to pass to the
<installSteps> block.
If specified, this element can only appear one time. See
<argList> Element on page 26.
Then, reading from page 26:
The arguments of the <argList> element are expressed as attributes.
The order in which the attributes appear is not significant. The following <argList> declares two arguments, password and path:
<argList password=":[password]" path="/tmp"/>
Worth a quick test.
-Mike