Action scripts allow you to hook into the process of control. You can run a script before, instead of, and after any given action that VMTurbo generates.
To enable action scripts, check your license for the following key:
If you don't have that key in your license file then drop an email to email@example.com to have them regenerate your license keys and then apply the new set.
Action scripts can be enabled/disabled on a per-group basis, but where do you set the script name to execute?
The answer.. you don't! VMTurbo will automatically call a script based on the following naming convention for a script placed in the /srv/tomcat/script/control directory:
Where ACTION is one of:
And EntityType is one of
PRE_MOVE_VirtualMachine.sh will be called prior to the move action on a Virtual Machine.
POST_SUSPEND_PhysicalMachine.sh will be called after a suspend action on a Physical Machine
The scripts receive information about the action through the following environment variables:
VMT_TARGET_UUID - The action target UUID (added in 6.2.2). Use this to get a list of actions by VM instead of VMT_TARGET_INTERNAL or VMT_TARGET_NAME. See Using VM internal ID (vm-####) in rest API to list VM actions by VM is no longer supported for further details.
VMT_TARGET_INTERNAL - The action target internal name.
VMT_TARGET_NAME - The action target display name.
VMT_CURRENT_INTERNAL - The current configuration or placement internal name.
VMT_CURRENT_NAME - The current configuration or placement display name.
VMT_NEW_INTERNAL - The new configuration or placement internal name.
VMT_NEW_NAME - The new configuration or placement display name.
VMT_ACTION_INTERNAL - The action UUID.
VMT_ACTION_NAME - The action name.
You can refer to these variables inside the script using the "$" sign. For example, to get the action target display name, use $VMT_TARGET_NAME.
In new versions to setup this script to run for a particular groups of VMs via new UI, as an example for PRE_RESIZE script you need to go to Settings >> policy >> Automation Policy >> Select Virtual Machine >> Give the policy name and select the group you have previously created >> Action Orchestration >> Resize >>Select PRE as shown in screenshot >> Save and Apply. Additionally, to make sure that the .sh script has proper permissions to run, do the following steps as well :
The following is an example of the content of a MOVE_VirtualMachine.sh script. This script will be executed instead of a virtual machine move action.
It checks if the if the virtual machine to move is hosted on a specific physical machine. If it does then it rejects the action, otherwise it accepts it:
OUT=$(curl -s -X GET http://<admin-user>:<admin-password>@localhost/vmturbo/api/markets/Market/virtualmachines/$VMT_TARGET_INTERNAL/resources?resource=CPU.* | grep -E 'provider="<physical-machine-name>"')
if [ "X$OUT" = "X" ]; then
curl -X POST http://<admin-user>:<admin-password>@localhost/vmturbo/api/actionlogs/Market_ActionLog/actionitems/$VMT_ACTION_INTERNAL --data "action=accept" > /dev/null
curl -X POST http://<admin-user>:<admin-password>@localhost/vmturbo/api/actionlogs/Market_ActionLog/actionitems/$VMT_ACTION_INTERNAL --data "action=reject" > /dev/null