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_CISPEC_CS_CPUSPEED.
memgb IN ATTRIBUTE SCI_CISPEC_CS_MEMORY.NUMVALUE
numcpus IN ATTRIBUTE SCI_CISPEC_CS_NUMCPUS.NUMVALUE
virtual IN ATTRIBUTE SCI_CISPEC_CS_VIRTUAL.ALNVALUE
srclass IN ATTRIBUTE CLASSSTRUCTURE.
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.getString('SCI_CISPEC_CS_
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 ( manuf.startswith('VMware') )) :
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.