Pattern scripts

Use the command-line interface to work with pattern_script and pattern_scripts objects.

Pscripts object

A pattern_scripts object represents the collection of scripts defined within a particular classic virtual system pattern part on the IBM® PureApplication® Software. Objects of this type are used to create, delete, iterate over, list and search for scripts within a pattern part on the IBM PureApplication Software.

When creating classic virtual system pattern scripts, the ID (of the script to be added to the pattern part) is required. The pattern_scripts object has all the normal methods of a resourcecollection object. The create() method, however, has behavior that is unique to the Pscripts object.

Help is available for the pattern_scripts object on the command-line interface. To get help, pass it as an argument to the help() function, as shown in the following example:
>>> help(deployer.pattern_scripts)
The Pscripts object has the following method:
create
Creates a pattern script or scripts within a pattern part. The scripts to be added can be specified in the following ways:
  • As a script object for the part that is to be added to this pattern part, as shown in the following example:
    >>> mypart.scripts.create(thescript)
  • As a dictionary (dict) object with the required keys, as shown in the following example:
    >>> mypart.scripts.create({'id': thescript.id })
  • As a long or int value that specifies the ID of the script object to be used to create a classic virtual system pattern script. This value is shown in the following example:
    >>> mypart.scripts.create(thescript.id)
  • As the name of a file containing a Jython expression that evaluates to one of the values in this list.
  • As the value deployer.wizard or a wizard instance created by calling deployer.wizard(). If either of these values is supplied, the command-line interface prompts, interactively, for the values to create the resource. For more information about using the wizard to create a pattern_scripts object, see the Related reference section.
  • As a list of any of the previous parts specified, in which case multiple scripts are created within the classic virtual system pattern part. This list of parts is shown in the following example:
    >>> mypart.scripts.create([script1, script2])
This method returns a classic virtual system pattern script object for the new classic virtual system pattern script, or a list of these objects if multiple classic virtual system pattern scripts were created.

For more information about working with resource objects, see the Related concepts section.

For more information about the script package object, see the Related reference section.

Pscript object

A classic virtual system pattern script object represents a script that has been added to a part in a classic virtual system pattern on the IBM PureApplication Software. Use the classic virtual system pattern script object to query and manipulate the script definition on the system. Attributes of the script and relationships between the script and other resources in PureApplication Software are represented as Jython attributes on the classic virtual system pattern script object. Manipulate these Jython attributes using standard Jython mechanisms to change the corresponding data in PureApplication Software.

To get help for the pattern_script object, on the command-line interface, pass it as an argument to the help() function, as shown in the following example:
>>> help(deployer.pattern_script)
For more information about working with resource objects, see the Related reference section.

Pscript attributes

The pattern_script object has the following attributes:

description
The description of the script.
executionOrder
Indicates the order in which this script is to run, relative to other scripts in the same part. Classic virtual system pattern scripts with larger values for the executionOrder attribute are run before scripts with smaller values. This value is an integer.
id
The ID of the script. This attribute is read-only.
isdeletable
Indicates if this script can be deleted by a user. This attribute is read-only.
label
The label used for the script. This attribute is read-only.
parameters
A list of parameters defined for this script. This attribute is read-only. Each parameter is a dict object with the following properties:
defaultvalue
The default value assigned to the parameter.
key
The key of the parameter.
locked
Indicates whether the value for the userConfigurable parameter can be changed.
Note: This property is read-only.
userConfigurable
Indicates whether the value of the parameter can be changed at deployment time.
Changes to the dict object have no effect on the script. To change a parameter of the script, use the setParameter() method.
ppart
The part that contains this script. This attribute is read-only. For more information about the properties and methods supported by pattern_part objects, enter the following command:
>>> help(deployer.pattern_part)
startsafter
The set of scripts in the classic virtual system pattern that must start before this script. For additional information on manipulating script startup order, enter the following command:
     >>> help(deployer.pattern_script.StartsAfter)
For more information, see StartsAfter object.
type
The type of this script. This attribute is read-only.

Pscript methods

The pattern_script part has the following methods:

getParameter
Returns information about a particular parameter of a script. This method accepts the following parameters:
key
The key of the parameter to be retrieved. This parameter is required.
wantMetadata
An optional boolean value indicating if the method returns metadata about the parameter (True) or just the value of the parameter (False), as shown in the following example:
>>> mypattern.parts[0].scripts[0].getParameter('key1', True)
setParameter
Sets the value and (optionally) metadata for a script parameter. This method accepts the following parameters:
key
The key of the parameter to be set. This parameter is required.
defaultvalue
An optional value to be set for the parameter. If not specified, the current value of the parameter is unchanged.
metadata
An optional dict object that can contain the following key:
userConfigurable
A boolean value that indicates if users can change the value of this parameter at deployment time, as shown in the following example:
>>> mypattern.parts[0].scripts[0].setParameter('key1', \
   ...   'new value', **{ 'userConfigurable': False })

StartsAfter object

A list-like object that represents the parts in the pattern that must start before this part.

StartsAfter methods

The StartsAfter object has the following methods:
__contains__
This method is invoked implicitly by Jython when you use the in operator on a StartsAfter object. Its single parameter must be a classic virtual system pattern script from the same classic virtual system pattern. The method returns True or False to indicate if the specified classic virtual system pattern script is in the set of classic virtual system pattern scripts that must start before the classic virtual system pattern script to which the StartsAfter object belongs. Invocation of this method is shown in the following example:
 >>> firstScript = mypattern.parts[0].scripts[0]
    >>> secondScript = mypattern.parts[1].scripts[0]
    >>> if firstScript in secondScript.startsafter:
    >>>    # firstScript starts before secondScript
__delitem__
This method is invoked implicitly by Jython when you use the del operator on a StartsAfter object. Its single parameter must be the index of the classic virtual system pattern script to be removed from the set of classic virtual system pattern scripts that must start before the classic virtual system pattern script to which the StartsAfter object belongs. Invocation of this method is shown in the following example:
     >>> del mypattern.parts[0].scripts[0].startsafter[0]
__getitem__
This method is invoked implicitly by Jython when you use the [] operator on a StartsAfter object. Its single parameter must be the non-negative index of the classic virtual system pattern script to be returned from the set of classic virtual system pattern scripts that must start before the classic virtual system pattern script to which the StartsAfter object belongs. Invocation of this method is shown in the following example:
     >>> mypattern.parts[0].scripts[0].startsafter[0]
__iadd__
This method is invoked implicitly by Jython when you use the += operator on the StartsAfter attribute of a classic virtual system pattern script. It accepts a single parameter that can be either a classic virtual system pattern script or list of classic virtual system pattern scripts. All classic virtual system pattern scripts must belong to the same classic virtual system pattern. All scripts passed as arguments are added to the set ofclassic virtual system pattern scripts that must start before the classic virtual system pattern script to which the StartsAfter object belongs. Invocation of this method is shown in the following example:
    >>> firstScript = mypattern.parts[0].scripts[0]
    >>> secondScript = mypattern.parts[1].scripts[0]
    >>> secondScript.startsafter += firstScript
This method returns StartsAfter to allow chained operations.
__isub__
This method is invoked implicitly by Jython when you use the -= operator on the StartsAfter attribute of a classic virtual system pattern script. It accepts a single parameter that can be either a classic virtual system pattern script or list of classic virtual system pattern scripts. All classic virtual system pattern scripts must belong to the same classic virtual system pattern. All scripts passed as arguments are removed from the set of classic virtual system pattern scripts that must start before the classic virtual system pattern script to which the StartsAfter attribute belongs. Invocation of this method is shown in the following example:
    >>> firstScript = mypattern.parts[0].scripts[0]
    >>> secondScript = mypattern.parts[1].scripts[0]
    >>> secondScript.startsafter -= firstScript
This method returns the StartsAfter attribute to allow chained operations.
__iter__
This method is invoked implicitly by Jython when a StartsAfter object is used in a context that requires iterating over its elements. It returns an iterator over the classic virtual system pattern scripts that are required to start before the original classic virtual system pattern script.
__len__
Returns the number of classic virtual system pattern scripts that are explicitly required to start before the classic virtual system pattern script to which the StartsAfter object belongs. This method is invoked implicitly by Jython when you use the len() function, as shown in the following example:
    >>> len(mypattern.parts[0].scripts[0].startsafter)
__lshift__
This method is invoked implicitly by Jython when you use the left shift operator ('<<') on a StartsAfter object. Its single parameter can be either a classic virtual system pattern script or a list of classic virtual system pattern scripts. All classic virtual system pattern scripts must belong to the same classic virtual system pattern. All scripts passed as arguments are added to the set of classic virtual system pattern scripts that must start before the classic virtual system pattern script to which the StartsAfter object belongs. Invocation of this method is shown in the following example:
    >>> firstScript = mypattern.parts[0].scripts[0]
    >>> secondScript = mypattern.parts[1].scripts[0]
    >>> secondScript.startsafter << firstScript
This method returns StartsAfter to allow chained operations.
__repr__
Returns a string representation of the classic virtual system pattern scripts that must start before a particular classic virtual system pattern script.
__rshift__
This method is invoked implicitly by Jython when you use the right shift operator ('>>') on a StartsAfter object. Its single parameter can be either a classic virtual system pattern script or a list of classic virtual system pattern scripts. All classic virtual system pattern scripts must belong to the same classic virtual system pattern. All scripts passed as arguments are removed from the set of classic virtual system pattern scripts that must start before the classic virtual system pattern script to which the StartsAfter belongs. Invocation of this method is shown in the following example:
    >>> firstScript = mypattern.parts[0].scripts[0]
    >>> secondScript = mypattern.parts[1].scripts[0]
    >>> secondScript.startsafter >> firstScript
This method returns the StartsAfter object to allow chained operations.
__str__
Returns a string representation of the classic virtual system pattern scripts that must start before a particular classic virtual system pattern script.
__unicode__
Returns a string representation of the classic virtual system pattern scripts that must start before a particular classic virtual system pattern script.
For more information about working with resource objects, see the Related reference section.