The administrative scripting (wsadmin) allows for the creation of scripts which have the ability to interact with WebSphere® Application Server objects, and are able to manipulate Service Policy Manager (SPM) user interfaces. The SPM runtime component provides a corresponding MBean interface for each of its Web services.
The wsadmin tools supports Jacl and Jython scripting languages. Jacl is the default language. If you want to use the Jython scripting language, use the -lang option when you run the script or specify it in the wsadmin.properties file.
For more information, refer to the topic WebSphere application server administration server configuration model in the WebSphere Application Server information center.
For more information, refer to the topic Installing Telecom Web Services Server base components in this information center.
For more information, refer to the topic Getting started with scripting in the WebSphere Application Server information center, and click the links for Jython and Jacl in the Sub-topics list.
The following is a sample MBean program using the Jython scripting language. This script attempts to create requesters and remove requesters.
Script name: IMS_SPM_RequestersAdmin_MBean_sample.py ######################################################################### # How to run this script: # Copy this to IMS WAS bin directory and enter: # ./wsadmin.sh -f IMS_SPM_RequestersAdmin_MBean_sample.py -lang jython ######################################################################### import javax.management.ObjectName import java.lang.System as sys import pytwss.mbean.mbean_utils import com.ibm.twss.spm.admin.policy import com.ibm.twss.spm.admin.common.ServicePolicyException as SPE # Get MBean type RequesterAdministration spmReqAdmin=AdminControl.queryNames('WebSphere:type=RequesterAdministration,*') if (spmReqAdmin == ""): print "can not get MBean type RequesterAdministration from WebSphere runtime. Make sure" print " 1) You have installed Service Policy Manager Runtime (SPM) application" print " 2) server and the SPM runtime application are started" sys.exit(0) # Uncomment below line to see help on MBean if needed #print Help.all(spmReqAdmin) #List of Requester Definitions to be attempted Requesters_list =[['Grp1', 'ALL', 1 , 'Grp1 Desc', 'RequesterGroup'], ['Grp2', 'ALL', 1 , 'Grp2 Desc', 'RequesterGroup'], ['Grp3', 'Grp2', 1 , 'Grp3 Desc', 'RequesterGroup'], ['Req1-1', 'Grp1', 1 , 'Req1-1 Desc', 'Requester'], ['Req1-2', 'Grp1', 1 , 'Req1-2 Desc', 'Requester'], ['Req3-1', 'Grp3', 1 , 'Req3-1 Desc', 'Requester'], ['Req1-1', 'Grp1', 1 , 'Req1-1 Desc', 'Requester'], ['Req1-1', 'Grp1', 1 , 'Req1-1 Desc', 'Requester'], ['Req1-1', 'DummyGroup', 1 , 'Req1-1 Desc', 'Requester']] print "================= Attempting CreateRequesters =================" i=0 for i in range(0, len(Requesters_list)): print " ======== Attempting record: ", Requesters_list[i], "=========" #Instanciate RequestDefinition and set values ReqDef=com.ibm.twss.spm.admin.common.RequesterDefinition() ReqDef.setRequester(Requesters_list[i][0]) ReqDef.setParentGroup(Requesters_list[i][1]) ReqDef.setEnabled(Requesters_list[i][2]) ReqDef.setDescription(Requesters_list[i][3]) ReqType=com.ibm.twss.spm.admin.common.RequesterType.fromString(Requesters_list[i][4]) ReqDef.setDefinitionType(ReqType) #Instanciate RequestDefinitionList ReqDefList = com.ibm.twss.spm.admin.common.RequesterDefinitionList() ReqDefList.setDefinition([ReqDef]) #Instanciate CreateRequestersRequest and set RequestersDefinitionList CreReqReq=com.ibm.twss.spm.admin.req.CreateRequestersRequest() CreReqReq.setDefinitions(ReqDefList) #Instanciate CreateRequestersResponse CreReqRes=com.ibm.twss.spm.admin.req.CreateRequestersResponse() #Invoke the createRequesters operation CreReqRes = AdminControl.invoke_jmx(javax.management.ObjectName(spmReqAdmin), 'createRequesters', [CreReqReq], ['com.ibm.twss.spm.admin.req.CreateRequestersRequest']) #Get any ServicePolicyExceptions SPE = ((CreReqRes.getFaultStatus()).getFaultStatus(0)).getFault() if SPE is not None: #Print ServicePolicyException ID and text print " ", SPE.getText(), "\n" if SPE is None: print " Successful" i=i+1 print "====================== Attempting RemoveRequesters =================" Remove_list =[['Grp1'], ['Gr1'], ['Req1-1']] i=0 for i in range(0, len(Remove_list)): print " ======== Attempting record: ", Remove_list[i], "=========" RemReqList=com.ibm.twss.spm.admin.common.RequesterList() RemReqList.setRequester(Remove_list[i]) RemReqReq=com.ibm.twss.spm.admin.req.RemoveRequestersRequest() RemReqReq.setRequesters(RemReqList) RemReqRes=AdminControl.invoke_jmx(javax.management.ObjectName(spmReqAdmin), 'removeRequesters', [RemReqReq], ['com.ibm.twss.spm.admin.req.RemoveRequestersRequest']) #Get any ServicePolicyExceptions SPE = ((RemReqRes.getFaultStatus()).getFaultStatus(0)).getFault() if SPE is not None: #Print ServicePolicyException ID and text print " ", SPE.getText(), "\n" if SPE is None: print " Successful" i=i+1