Automation Scripts in SmartCloud Control Desk 7.5.1
Clark Carradine 1000009CMC Visits (1542)
The ability to easily create Action Scripts in SmartCloud Control Desk 7.5 is a great new feature for Power Users and developers.
The benefits of action scripting vs Java customization are:
– Scripts can be migrated from development to production with Migration Manager.
– No need to rebuild EAR file
– No need to restart the system
– Action scripts are less likely to get trampled in an upgrade
I have built a simple example of an action script in SmartCloud Control Desk 7.5.1 that builds a custom CI description for a Computer System.
The customer requirement was to create a custom description that updates when the CI is moved from the default "NOT READY" state. The script would update the description with various ci spec's to create a new description like "Virtual - 2 CPU's @ 2.3Ghz - 4.0 GB Mem".
A little analysis shows we need the following CISpec values:
Which we can get with the following relationships from the CI object
Using the Automation Script wizard create a new script using a Object Launch point.
Launch Point "CustomCIDesc"
Events "Add" and "Update"
Since the CI Specs do not exist when a CI is initialized we can't set that as an event.
This is a new script.
Give the script a name and choose a scripting language. I chose jython.
We now need to define the variables that the script will use. There are three type of variables that can be defined:
IN Passes a value into the script
OUT Passes a value out of the script
IN/OUT Which does both.
By defining the following variable as explicit variables the wizard takes care of all the under the covers plumbing.
Variable Variable Type Binding Type Bound to
cpughz IN ATTRIBUTE SCI_
memgb IN ATTRIBUTE SCI_
numcpus IN ATTRIBUTE SCI_
virtual IN ATTRIBUTE SCI_
srclass IN ATTRIBUTE CL
customdesc OUT ATTRIBUTE DESCRIPTION
Notice in the script below I came back and added additional logic for when the virtual attribute was null. This is an an example of retrieving a value using the implicit variable mbo.
# * GBSP Confidential
# * Written by Clark Carradine
# This script sets the custom description for a CI
manuf = mbo.
if memgb is not None:
memgb = round(memgb / 1073741824,2)
if cpughz is not None:
cpughz = round(cpughz / 1000000000,2)
if ( virtual == 'true' ) or ((virtual is None) and ( manu
type = 'Physical'
customdesc = "%s - %d CPU's @ %sGhz - %s GB Mem" % (type, numcpus, cpughz, memgb )
customdesc = ''
This certainly just scratches the surface with what can be done with Action Scripts.