8/19/2019 Tivoli Scripting
1/38
Sam Sriramadhesikan14 August 2012
Scripting
8/19/2019 Tivoli Scripting
2/38
Agenda
Architecture Automation Scripts application
Launch Points
Variables Deep Dive into Launch Points
Logging
Resources
8/19/2019 Tivoli Scripting
3/38
ser !eed
Abilit" to rapidl" e#tend packaged applications $"pical user challenges
% Limited to no &ava skills' avoid &ava(based development
% Reduce s"stem do)ntime across the product environments
Primar" customi*ation areas
% +usiness ob,ect e#tensions
% -ield validations
%.ork/lo) scalation actions
Driven b" customer and e#ploiter reuirements
% 3a#imo Advisor" ouncil
% 5+3 Service 3anagement product /amil"
8/19/2019 Tivoli Scripting
4/38
.hat is a script6
Short pieces o/ code
Simpli/ied programming model
suall" used to glue or e#tend applications
suall" interpreted 7vs compiled &ava or 889 #ample % add all asset spare part quantities together and
set total into ASSET.SPAREQTY : spPartSet = mbo.getMboSet('sparepart')
partCount = spPartSet.count() totalQty = 0.0
for i in range(partCount):
partMbo = spPartSet.getMbo(i)
totalQty += partMbo.getouble('!uantity')
mbo.set"alue('spare!ty'#totalQty)
8/19/2019 Tivoli Scripting
5/38
.h" scripting6
&ava skills and implementation increase 5$ costs
% &ava& developers
% AP5 kno)ledgecompatibilit"
% Per/ormance/unctionalit" issues
% +uild process /or .AR; AR; &AR /iles
% Server shutdo)n re(starts
Scripting promotes simpli/ied programming model
Scripting is completel" d"namic 7no server re(starts9
8/19/2019 Tivoli Scripting
6/38
Scripting Strateg" /or
$pae e#ploits scripting AP5 that is part o/ &D? @
% &SR 22 % standardi*ed scripting AP5 /or &ava
Supports t)o script engines out o/ the bo#
% Rhino &avaScript 7embedded )ith &D? @; compliant )ith &SR 229
% &"thon 2=>=2 7ne)er version compliant )ith &SR 229
Bther &SR(22 compliant script engines can be seamlessl"plugged in
% Provides programming /le#ibilit" to clients and practitioners
% #ample: &acl; &Rub"; Croov"; &a)k
% Place &ARs in application server classpath and re(start server
8/19/2019 Tivoli Scripting
7/38
Scripting Strateg" /or
$pae scripting can be enabled /or man" di//erentcon/igurations
% !o longer limited to ,ust actions
% Script creation and management remains the same
$pae scripting supports simple coding approach
% Launch points o//er closer alignment )ith $pae applications andcon/igurations
% Script variables and bindings to pass in data and return results % Detailed kno)ledge and e#perience o/ 3a#imo AP5s not a pre(reuisite
8/19/2019 Tivoli Scripting
8/38
Runtime
Script Driver
Script ngineScript ngine
Design $ime
Scripting architecture in
$pae Database
Script
Script Driver
Script ngine
Script
Launch Point ActionLaunchPoint
Bb,ectLaunchPoint
AttributeLaunchPoint
onditionLaunchPoints
-ieldValidationsBb,ect vents Action
5 constructs
.ork/lo)
scalation
onditional5
.ork/lo)
ondition!ode
8/19/2019 Tivoli Scripting
9/38
Scripting constructs in
Script
Variables
Bb,ects Attributes
Actions
$pae nativecon/iguration or
application
on/iguration or applicationconte#t /or script
5nput and output variablesto script
Script e#ecuted passinginputs and returning
outputs
+indings
Launch Point+inding
applicationcon/igurationdata to variables
onditions
8/19/2019 Tivoli Scripting
10/38
Automation Scripts application
reation and maintenance o/ launch points; scripts andvariables
.i*ards to create launch points
% Bb,ect Launch Point
#ecute scripts on 3+B events such as init; add; update; or delete
#ecute scripts conditionall" 7based on criteria9
% Attribute Launch Point
#ecute scripts during /ield validations
% Action Launch Point
#ecute scripts in the conte#t o/ )ork/lo)escalation actions
% ustom Launch Point
.ork/lo) conditions and conditional e#pressions can be enabled
8/19/2019 Tivoli Scripting
11/38
Automation Scripts application
Declare input and output variables +ind variables to 3+B attributes; s"stem properties;
3AEVARs or literals
Share script among multiple launch points
5mport e#isting script /iles created e#ternall" into application
Promote scripts and launch points /rom development toproduction )ith 3igration 3anager
Speci/" logging level and place log statements )ithin script
8/19/2019 Tivoli Scripting
12/38
Automation Scripts application
Co $o(FS"stem on/iguration(FPlat/orm on/iguration(FAutomationScripts
Securit" Croup 3AEAD35! grantedaccess to the application out o/ thebo#
Standard po)er application )ith /ourtabs
%List
% Automation Script
% Variables
% Launch Points
8/19/2019 Tivoli Scripting
13/38
Automation Scripts application ( creation
reate ra) script % Script can be subseuentl" associated )ith launch point
reate launch point associated )ith variables and scripts
% .i*ards to guide users through creation seuence
8/19/2019 Tivoli Scripting
14/38
Automation Scripts application ( maintenance
3aintain e#isting launch points; variables and scripts /rommain tabs
% 3odi/" script code
% Add or modi/" variables
% Recon/igure launch point
% Deactivate or activate launch point
% Delete e#isting launch points; variables and scripts
8/19/2019 Tivoli Scripting
15/38
Launch Points
Launch Point is a complete script con/iguration Launch point con/iguration consists o/ three parts
% $arget application or conte#t the script should e#ecute on
% +od" o/ the script
% Variables to be passed bet)een application and script
Variables Script
Launch Point
Bb,ects Attributes Actions.ork/lo)
onditionsSecurit"
onditionsBb,ects Attributes ActionsBb,ects Attributes.ork/lo)
onditions ActionsBb,ects AttributesSecurit"
onditions.ork/lo)
onditions ActionsBb,ects Attributes
8/19/2019 Tivoli Scripting
16/38
Variables
Variables enable data to be passed to and returned /romscript
#ploiting variables simpli/ies script code
Variables have these characteristics:
% Variable $"pe: 5! 7passed to9 or B$ 7returned /rom9 or 5!B$ 7both9
% Variables o/ t"pe B$ are set back into a business ob,ect
% .hen setting back to business ob,ect the /ollo)ing can be controlled:
Allo)ing or suppressing validation
Allo)ing or suppressing access control
Allo)ing or suppressing action
8/19/2019 Tivoli Scripting
17/38
Variables
Variables have these characteristics: % Variable +inding: Variables can be bound to one o/:
+usiness ob,ect attribute 73AEA$$R5+$9
S"stem propert" 7SGSPRBP9
3AEVAR
Literal value
% Variable +inding: Variables can receive a global binding value that canbe overridden per launch point
Clobal binding value is common to all launch points associated )ith the script
Clobal binding value overridden /or a particular launch point; i/ needed
8/19/2019 Tivoli Scripting
18/38
Variables
Variables are al)a"s bound to the source or target o/ data
Variable binding is declared at the script level
% an be overridden per launch point
Variables
Script
Launch Point
Launch point associated )ith ASS$ business
ob,ect; runs upon update o/ ASS$ record
5! variables receive S5$5D; ASS$$GP
B$ variable sets DSR5P$5B!
siteidassett"pe desc
8/19/2019 Tivoli Scripting
19/38
5mplicit Variables Script code made simpler b" providing implicit variables
5mplicit variables are automaticall" available to a script
!o need to declare these separatel" in Automation Script application
5mplicit variable Description
user 5! variable onl"' provides currentl" logged in userHs 5D
app 5! variable onl"' provides application name that script ise#ecuting against
evalresult B$ variable onl"' )ork/lo) condition and securit" conditionscripts return true /alse values al)a"s
errorgroup B$ variable onl"' script code sets $pae error group con/igured
in Database on/iguration applicationerrorke" B$ variable onl"' script code sets $pae error ke" con/igured in
Database on/iguration application
params B$ variable onl"' script code sets an arra" o/ parameters thatpopulate the error message speci/ied b" errorgroup; errorke"
8/19/2019 Tivoli Scripting
20/38
Additional implicit variables $hese implicit variables are associated )ith a primar" variable
-or e#ample; i/ an B$ variable called siteid is speci/ied /or a script; thensiteidIreadonl" )ill cause the associated S5$5D attribute to become read(onl"
5mplicit variable Description
Ireadonl" Retrieve or set the read(onl" /lag /or a business ob,ect attribute
Ireuired Retrieve or set the reuired /lag /or a business ob,ect attribute
Ihidden Retrieve or set the hidden /lag /or a business ob,ect attribute
Iinternal 5! variable onl"' provides the $pae internal value /or aSG!B!G3DB3A5! entr"
Iinitial 5! variable onl"' provides the initial value /or an attribute asretrieved /rom the 3+B
Iprevious 5! variable onl"' provides the previous value /or an attribute asretrieved /rom the 3+B
Imodi/ied 5! variable onl"' provides a /lag indicating i/ the value /or anattribute has been modi/ied
8/19/2019 Tivoli Scripting
21/38
Variables bound to attributes
Variables that are bound to business ob,ect attributes can be con/igured in a
number o/ )a"s
Variable +inding Description
Attribute Variable receives its value /rom the business
ob,ectHs attribute
Relationship=Attribute Variable receives its value /rom a relatedbusiness ob,ectHs attribute 7multiple relationshipscan be traversed using $pae standard JdotHnotation9
Arra"s Variable receives an arra" o/ values /rom abusiness ob,ectHs attribute 7multiple relationshipscan be traversed9
8/19/2019 Tivoli Scripting
22/38
Arra" !otations
Arra" notations onl" allo)ed on 5! variables )ith3AEA$$R5+$ bindings
#isting
8/19/2019 Tivoli Scripting
23/38
Arra" !otations
Support in :
#isting
8/19/2019 Tivoli Scripting
24/38
Arra" !otations
+usiness ob,ects can be traversed in the /ollo)ing )a"s:
% +" inde# 7e#ample; PBBS$K,9
% +" SML /ilter 7e#ample; PBL5!BS$KlinecostF100
% +" condition e#pression 7e#ample; PBBS$Kcond: BS$B!D!9
Results o/ traversal al)a"s end )ith a single attribute value or arra" o/attribute values
% PBL5!Ki=PBBS$K,=costlinenum
% PO#$%E+linecost,-/.PO(OST+percentage0-/.loadedcost1
Variables )ith binding to business ob,ect attributes can beinitiali*ed using the scripting /rame)ork arra" notations rather
than coding )ith $pae AP5 )ithin the bod" o/ the script=
8/19/2019 Tivoli Scripting
25/38
Bb,ect Launch Point
De/ines a script con/iguration e#ecuted during businessob,ect events
% 5nitiali*e
% 5nsert
% pdate
% Delete
Supports both persistent and non(persistent ob,ects
+usiness ob,ect events can be /iltered to meet speci/iccriteria
$hree(step )i*ard to create con/iguration
8/19/2019 Tivoli Scripting
26/38
Bb,ect Launch Point Demo
Scripting ingredients to implement this reuirement:
1= De/ine an Bb,ect launch point that e#ecutes )henever a ne)l" inserted asset record is saved
2= De/ine the script that associated pre/i# )ith and associate )ith the Bb,ect launch point
= $est the Bb,ect launch point and script immediatel" and activate or de(activate as desired
Reuirement:
.hen a ne) asset record is created )ith the Assets application;the asset number should adhere to the /ollo)ing naming
convention: asset number should be pre/i#ed )ith the t"pe o/asset being created=
Asset Type Prefix-A5L5$5S -$
-L$ -L
5$ 5$
PRBD$5B! PR
8/19/2019 Tivoli Scripting
27/38
Attribute Launch Point
De/ines a script con/iguration e#ecuted during /ieldvalidations
% Script e#ecutes against the validate79 method o/ 3boValueAdapter
Supports both persistent and non(persistent attributes
Script can trigger displa" o/ in/ormational; )arning or errormessages based on validation logic
$hree(step )i*ard to create con/iguration
8/19/2019 Tivoli Scripting
28/38
Attribute Launch Point Demo
Scripting ingredients to implement this reuirement:
1= De/ine an Attribute launch point that e#ecutes )henever Purchase Price /ield is
tabbed out o/ 2= De/ine the script that con/igures the /ields and associate )ith the Attribute launch
point
= $est the Bb,ect launch point and script immediatel" and activate or de(activate asdesired
Reuirement:
5/ Purchase Price on an asset is more than N100; Vendor /ieldmust be populated= 5/ Purchase Price on an asset is less than
N100; Vendor /ield is not reuired= -or an" Purchase Price;
Replacement ost should be hal/ the Purchase Price=
8/19/2019 Tivoli Scripting
29/38
Action Launch Point
De/ines a script con/iguration e#ecuted as part o/ )ork/lo) process or
escalation point
% Action record is generated during launch point creation
% Action record is o/ t"pe JS$B3H
% $pae scripting provides out o/ the bo# &ava class callable /rom action toe#ecute script
% But o/ the bo# &ava class accepts three parameters:
Param 1 Script name
Param 2 Launch Point name
Param Action name
% Parameters are auto(populated during launch point creation
8/19/2019 Tivoli Scripting
30/38
Action Launch Point Demo
Scripting ingredients to implement this reuirement:
1= De/ine an Action launch point that computes target contact and start dates and
generates )ork log entr"2= De/ine the )ork/lo) process that incorporates the Action launch point
= $est the )ork/lo) process; action launch point and script immediatel" and activateor de(activate as desired
Reuirement:
As part o/ a )ork/lo) process operating on a Service Reuestrecord; s"stem initiated processing computes target contact andtarget start dates and also creates a )ork log entr" against the
Service Reuest=
8/19/2019 Tivoli Scripting
31/38
ustom ondition Launch Point
onditions are commonl" con/igured in $pae
$)o t"pes o/ conditions are enabled /or scripting in $pae
% .or/lo) onditions 7as de/ined in ondition !ode9
% Securit" onditional 5 7as de/ined in ondition #pression 3anager
$)o steps to /ull" enable scripted conditions:
% De/ine the ustom ondition Launch Point
% Associate the Launch Point )ith )ork/lo) ondition !ode or ondition #pression 3anager
ondition !ode and ondition #pression 3anager con/iguration must be per/ormed innative applications
% .ork/lo) Designer 7de/ine S$B3 condition in )ork/lo) canvas9
% ondition #pression 3anager 7de/ine S$B3 e#pression9
$"peOLASS; lassOcom=ibm=tivoli=ma#imo=script=Scriptustomondition
#pression should hold launch point in/ormation: script nameF:launchpoint nameF
$pae scripting provides out o/ the bo# &ava class callable /rom either t"pe o/ condition
Script must al)a"s return true or /alse 7evalresult B$ variable9
8/19/2019 Tivoli Scripting
32/38
ustom ondition Launch Point Demo
Scripting ingredients to implement this reuirement:
1= De/ine an ustom ondition launch point evaluates the status o/ an asset record
2= De/ine the condition e#pression that )ill invoke this script
= De/ine the signature option that )ill controls access to the Spare Parts tab
4= Associate the condition e#pression and signature option )ith 3AEAD35! securit"group
>= $est the complete con/iguration immediatel" and activate or de(activate as desired
Reuirement:
-or all users in the 3AEAD35! securit" group; /or assets thathave status o/ DB335SS5B!D; Assets application must not
displa" the Spare Parts tab=
8/19/2019 Tivoli Scripting
33/38
Skills
Scripting is targeted at e#ploiters and implementers
#ploiters ma" deliver out o/ the bo# script content /or theirproduct capabilities
% $SR3 Service atalog shopping cart scripts
% 3D+ R+A script to trigger provisioning )ork/lo)s in $P3
5mplementers create scripts to accelerate production roll out
#perience )ith $pae con/igurations is a pre(reuisite
% Data model and relationship kno)ledge e#tremel" valuable
?no)ledge o/ scripting language s"nta# and operations is apre(reuisite
?no)ledge o/ $pae business ob,ect AP5 is an advantage;though not reuired
8/19/2019 Tivoli Scripting
34/38
Deplo"ment approach
Scripts should be created and tested in developmentenvironments
Application behavior )ith and )ithout scripts can bemeasured % simpl" activate or de(activate the script
Scripts can be packaged using 3igration 3anager anddistributed to pre(production and production environments
% 3igration group SR5P$-C
% D3SR5P$ ob,ect structure % D3LA!QPB5!$ ob,ect structure
% Launch points that )ere active in source )ill be migrated and set activein target
8/19/2019 Tivoli Scripting
35/38
Script Logging
autoscript logger set to RRBR level out o/ the bo#
All log statements /rom scripting /rame)ork and individualscripts processed b" autoscript logger
Logging /or individual scripts
% Place print statements inside the script
% Print output redirected to autoscript logger
% ach script can con/igure the log level o/ its print statements
% All print statements inside bod" o/ script redirected to same log: nosupport to generate mi#ed logs 7e#ample; RRBR and D+C9
Recommendation is to redirect scripting logs to dedicated log/ile
8/19/2019 Tivoli Scripting
36/38
Script Logging
Log statement indicates e#ecution time
% 5rrespective o/ log level
% S"stem propert" m6e.logging.(orrelationEnabled must be enabled
$% Mar &0$$ &&:%:0: *,- M/Serer C*1M/SC2*P31$0& Correlation starte4.
$% Mar &0$$ &&:%:0:& *,- M/Serer C*1M/SC2*P31$0& 35e total time ta6en to e7ecute
t5e C-C83S2 script for t5e C-C83 launc5 point is $9 ms.
$% Mar &0$$ &&:%:0:& *,- M/Serer C*1M/SC2*P31$0& Correlate4 4ata: ; app:S2 Script:C-C83S2 Mbo*4:& Mboame:S2 ?aunc5Point:C-C83
eal*Params3ime:$ @serame:S2 eal-@3Params3ime:0 ;lapse43ime:>0 ms ;
Speci/" D+C level in autoscript logger to obtain additional e#ecution details ona script
% Prior to e#ecuting; print the binding values /or script variables
% A/ter e#ecuting; print the updated values
% 5/ errorke" and errorgroup being set; indicate i/ the message success/ull" retrieved
8/19/2019 Tivoli Scripting
37/38
Script ompilation and #ecution
pon save; script is compiled and cached
% A pre(compiled script can be e#ecuted multiple times )ithout the needto reparse or recompile
% Pre(compilation can be done onl" )ith those scripting engines thatsupport compilation
% Pre(compilation and cacheing make script e#ecution more e//icient
An" s"nta# errors /ound reported in application as popupmessage
&"thon &avaScript standard interpreter e#ecutes script
5/ additional imports are used; then the correspondinglibraries must be present in application server LASSPA$Q
8/19/2019 Tivoli Scripting
38/38
Resources
3a#imo 5n/ormation enter /or Automation Scriptsapplication help
&"thon scripting % http:)))=,"thon=org
&avascript 7Rhino9 scripting
% http:)))=mo*illa=orgrhino
&SR(22 scripting /or &ava speci/ication % http:,cp=orgabout&avacommunit"processpr,sr22
$pae Scripting ookbook % http:ibm=copPl2
Service 3anagement onnect blogs % https:)))=ibm=comdeveloper)orksservicemanagementaminde#=html
http://www.jython.org/http://www.mozilla.org/rhino/http://jcp.org/aboutJava/communityprocess/pr/jsr223/http://ibm.co/pPl32Ehttps://www.ibm.com/developerworks/servicemanagement/am/index.htmlhttps://www.ibm.com/developerworks/servicemanagement/am/index.htmlhttp://ibm.co/pPl32Ehttp://jcp.org/aboutJava/communityprocess/pr/jsr223/http://www.mozilla.org/rhino/http://www.jython.org/