Creating action scripts
An action script can be any executable that a user can invoke from a command line. You can save these executable files anywhere on the server – The Manifest indicates the path to the file (see Deploying the Action Script Manifest). The Action Script user that you have configured for the script server must have access to your script files, with read and execution privileges.
To execute a script, Turbonomic for
Government Standard builds the appropriate SSH command from the
manifest information it has discovered. It grants a timeout limit of 30 minutes by default, or
the manifest entry can declare a different limit. If the execution exceeds the limit,
Turbonomic for
Government Standard sends a SIGTERM to terminate the process.
Passing information to the action script
Turbonomic for Government Standard uses two techniques to pass information about an action to the associated action script:
Pass general information via environment variables
Pass full action data via
stdin
To pass general information into the script, Turbonomic for
Government Standard sets
environment variables on the Action Script Server. You can reference these environment
variables in your scripts. For example, assume you want to send an email that includes the name of
the VM that is an action target. You can get that name via the VMT_TARGET_NAME
environment variable.
The following list shows the environment variables that Turbonomic for
Government Standard
can set when
it executes a script. Note that not all of these variables apply for every action.
For example, an action to scale VMEM does not include providers, so the action does not
include values for the VMT_CURRENT_INTERNAL, VMT_CURRENT_NAME,
VMT_NEW_INTERNAL, or VMT_NEW_NAME variables. If a given
variable does not apply, Turbonomic for
Government Standard sets it to an empty string.
VMT_ACTION_INTERNALThe UUID for the proposed action. You can use this to access the action via the REST API. For example, your script could accept or cancel the action according to its own criteria.
VMT_ACTION_NAMEThe name of the action.
VMT_CURRENT_INTERNALThe internal name for the current provider.
VMT_CURRENT_NAMEThe display name for the current provider.
VMT_NEW_INTERNALThe internal name for the new provider.
VMT_NEW_NAMEThe display name for the new provider.
VMT_TARGET_INTERNALThe internal name of the entity this action will affect. You can use this to access the target entity via the REST API. For example, you can get historical statistics or you can change settings for the entity.
VMT_TARGET_NAMEThe display name of the entity this action will affect.
VMT_TARGET_UUIDThe UUID of the entity this action will affect.
For some scripts, you might need a complete description of the associated action. For example, assume you want to analyze the utilization metrics for a given resource. The environment variables for passing general information do not include this information.
When it invokes an action script, Turbonomic for
Government Standard passes the
complete data for the associated action via stdin. Your script can
load this into a variable to access the specific data it needs. For example,
the following loads stdin into myActionData:
myActionData=$(cat -)
stdin contains a JSON string that represents of the full data
associated with this action. For example, the myActionData variable
could contain a string similar to:
{"actionType":"RIGHT_SIZE","actionItem":[{"actionType":"RIGHT_SIZE","uuid":"143688943343760","targetS
E":{"entityType":"VIRTUAL_MACHINE","id":"4200fcdb-eafe-2a4a-abf5-a7ad2b00555c"...