WebSphere Extended Deployment, Version 6.0.x
             Operating Systems: AIX, HP-UX, Linux, Solaris, Windows, z/OS


Managing work classes with scripts

The workclassoperations.py script can be used to manage work classes.

Usage

The workclassoperations.py script creates, updates work classes for enterprise applications and generic server clusters. It also lists rules in a work class, list members in a work class, fetch default action, set default action, add rule, delete rule, delete members, and delete work classes for the various policies and communication protocols.

From a command line:

For general help: >> ./wsadmin.sh -lang jython -f workclassoperations.py

For operation specific help, >> ./wsadmin.sh -lang jython -f workclassoperations.py --help

The following is the usage of the script:

Usage: wsadmin                            
	[-lang jython]                         
	[-f workclassoperations.py]                            
	[-odrname odrName]                           
	[-odrnode odrNode]                            
	[-wcname workClassName]                            
	[-appname appName]                            
	[-webmodule webModule]                            
	[-adduri ["uri1?uri2?..."]]   -addmember                          
	[-type HTTP|SOAP|IIOP|JMS]                            
	[-vhost virtualHost]                            
	[-wctype APP|GSC|ARP|ASP|GRP|GSP]                            
	[-addrule ["priority?expr?actiontype?action"]]                            
	[-deleterule [priority]]                            
	[-deleteuri ["uri1?uri2?..."]]  [-deletemember]                         
	[-deletewc]                            
	[-listrule]                            
	[-listuri]  [-listmember]                        
	[-setdefaultaction ["actiontype?action"]]                 
      	[-modifydefaultaction ["actiontype?action"]]                  
      	[-getdefaultaction]                                                [-systemapp]

      	[-both]                                                      

For operation-specific help type:

wsadmin -lang jython -f workclassoperations.py <operation> -help

where:

<operation> specifies a supported operation:
  1. listWorkClasses [options]
  2. createWorkClass [options]
  3. removeWorkClass [options]
  4. addMembers [options]
  5. removeMembers [options]
  6. listMembers [options]
  7. addRules [options]
  8. removeRules [options]
  9. listRules [options]
  10. modifyDefaultAction [options]
  11. getDefaultAction [options]
  12. modifyVirtualHost [options]
  13. getVirtualHost [options]

Common options:

  • --type
    • type of work class to create
    • ASP = application service policy
    • ARP = application routing policy
    • GSP = generic server service policy
    • GRP = generic server routing policy
  • --appname
    • optional name of application
    • optional [required-if] the --type parameter is specified as ASP or ARP
  • --odrname
    • optional name of odr
    • [required-if] the --type parameter is specified as GSP or GRP
  • --nodename
    • optional name of node
    • [required-if] the --type parameter is specified as GSP or GRP

Depending on where you are issuing the command, you might have to specify the path to workclassoperation.py. For example, if you have created a profile named Dmgr01 located here:c:\<WAS_INSTALL_ROOT>\profiles\Dmgr01\bin . From within that directory, type:

wsadmin -lang jython -f ..\..\..\bin\workclassoperations.py

Note that if the deployment manager is not started, you must include the additional parameter -conntype NONE. For example,

wsadmin -lang jython -conntype NONE workclassoperations.py

Example

Lists all work classes by the type specified. The format of listing is:

workclassname type appname/odrname deploymentname

Options:

  • --type [see common options] [optional]
  • --appname [see common options] [optional]
  • --odrname [see common options] [optional]

list all work classes:

>> ./wsadmin.sh -lang jython -f workclassoperations.py listWorkClasses

List all work classes for application Trade:

>> ./wsadmin.sh -lang jython -f workclassoperations.py listWorkClasses --appname Trade

List all routing policy work classes for application Trade:

>> ./wsadmin.sh -lang jython -f workclassoperations.py listWorkClasses --type ARP --appname Trade

List all generic server work classes for ODR myODR:

>> ./wsadmin.sh -lang jython -f workclassoperations.py listWorkClasses --odrname myODR

List all generic server routing policy work classes for ODR myODR:

>> ./wsadmin.sh -lang jython -f workclassoperations.py listWorkClasses --type GRP --odrname myODR

Command line options

Add or define a rule for the created work class
Use the -addrule command line option. Do not use this option with the -deleterule, -listrule, or -getdefaultaction options on the same command invocation. If you add more than one rule at a time, list them in the order of their priority starting from a low number to the higher number in sequence.
  • 'priority' is the priority assigned to the rule being created. Priority is an integer value, for example, 0, 1, 2, 3, and so on, with 0 being the highest priority.
  • The question mark is a separator and it is required in this sequence.
  • 'expr' is the rule expression. See Routing and service policies work classes for more information.
  • 'actiontype' is the type of action to take and has an enumerated values of permit, permitsticky, reject, or redirect for the routing policy. If you create a service policy work class, the actiontype is the transaction class name.
  • 'action' its value depends on the actiontype. For example, if actiontype is 'redirect' then the action is the redirect URL. For example, redirect?http://www.ibm.com. For the reject actiontype, the action is a reject code. For example, reject?404. For generic server cluster work classes, the action is the name of the generic server cluster.
Specify the name of the enterprise application or application edition
Use the -appname appName command line option to specify the name of the enterprise application or application edition without the .ear extension.
Provide a collection of URI patterns to associate with the work class web module for the enterprise application.
Use the -adduri -addmember command line option to provide a collection of URI patterns to associate with the work class web module for the enterprise application. URI patterns are separated by the question mark (?) sign and each URI pattern must start with a forward slash (/).
Indicate the operation to apply for routing and service policies
Use the -both command line option to indicate that the -listrule, or the -getdefaultaction operation should be applied for both routing and service policies on the given work class name.
Delete a specific rule
Use the -deleterule command line option to delete a specific rule from the work class specified using the -wcname option. It cannot be used with the -addrule, -listrule, or -getdefaultaction options on the same command invocation.
Delete a collection of URI patterns from the web module work class
Use the -deleteuri -deletemember command line option to provide a collection of URI patterns to be deleted from the web module work class. This option is applicable to enterprise application work classes only.
Display the URI from the web module element of the work class
Use the -listuri -listmembercommand line option to display URI from the web module element of the work class. This option is applicable only to enterprise application work classes.
Delete a work class
Use the -deletewc command line option to delete a work class. With this option, you must also specify the -wctype command line option with a value of either ARP (application routing policy), ASP (application service policy), GRP (generic routing policy), or GSP (generic server policy).
Get the default action type and action in a defined workclass
Use the -getdefaultaction command line option to get the default actiontype and action that are defined in the work class that is specified using the -wcname option. Do not use this command line option with the -addrule, -delete, or -listrule options on the same command invocation.
Display the rules defined in the work class
Use the -listrule command line option to display the rules defined in the work class. Do not use this option with -addrule, -deleterule, or -getdefaultaction options on the same command invocation.
Modify the default action for the work class
Use the -modifydefaultaction to modify the default action for the existing work class specified using the -wcname option and specifying the actiontype and action.
Specify the name of the on demand router (ODR) proxy server
Use the -odrname odrName command line option to specify the name of your on demand router (ODR) proxy server.
Specify the name of the ODR node
Use the -odrnode odrNode command line option to specify the name of your ODR node.
Specify a default action
Use the -setdefaultaction option with the actiontype and action specified to create a rule with the expression denoted by the asterisk (*) sign and set the action type and action to the values provided with the option.
Specify the request type
Use the -type option to specify the protocol for which this work class applies. Acceptable values are HTTP and SOAP. If the -type option is not specified, the default of HTTP is assumed.
Specify the name of the virtual host for the generic server cluster
Use the -vhost virtualHost option to specify the name of the virtual host for the generic server cluster.
Specify the name of the web module
Use the -webmodule webModule option to specify the web module name without the .jar or .war extension.
Tip: Although the parameter is named -webmodule, it is valid to specify EJB and Web modules while managing JMS work classes only.
Specify the name of the work class
Use the -wcname workClassName option to specify the name of the work class. No spaces are allowed in the work class name. This option is always required.
Specify the work class type
The -wctype option takes a constant value of either APP for enterprise application or GSC for generic server cluster when creating work classes because the default action type, actiontype, is used to distinguish between routing and service policy work classes. In operations where the distinction is not obvious, the ARP, ASP, GRP, and GSP are used. If the -deletewc option is specified, acceptable values are ARP for delete application routing work class, ASP for delete application service policy work class, GRP for delete generic server cluster routing policy work class, and GSP for delete generic server service policy work class. There is no default, so a value must be specified.
Specify the EJB name for JMS work class [Version 6.0.1 and later]
Use the -ejbName <myEJBname> option to specify the Enterprise JavaBeans bean name in the EJB jar module.

Example

Some examples follow:
Create a routing policy work class for the my_App application named my_Work_Class. The work class applies to all URIs with pattern /test1 and /test2/* from the my_Web_Module web module, and contains a single rule that permits requests from the ibm.com domain. The default action causes all other requests to be rejected with an error code of 404.
wsadmin -lang jython -f workclassoperations.py -appname my_App -wcname my_Work_Class  
-type HTTP -wctype APP -webmodule my_Web_Module -adduri -addmember "/test1?/test2/*" -addrule  "1?clienthost LIKE \'\%%.ibm.com\'?permit?my_App" -setdefaultaction "reject?404"
Create an enterprise application work class for a routing policy. It has the default action of reject with a reject code of 404. If issuing this command on UNIX base operating system, the escape sequence (\%%) should be replaced by (\%).
wsadmin -lang jython -f workclassoperations.py -appname A -wcname CustomWorkClass
-type HTTP -wctype APP -webmodule myWebModule -adduri -addmember "/test1?/test2/*" -addrule
"1?clienthost=\'localhost\' and serverhost like \'\%%.ibm.com\'?permit" -setdefaultaction
"reject?404"    
Create an enterprise application work class for a service policy. If issuing this command on UNIX base operating system, replace the escape sequence (\%%) with (\%).
wsadmin -lang jython -f workclassoperations.py -appname A -wcname Custom2WorkClass
-type HTTP -wctype APP -webmodule myWebModule -setdefaultaction "Default_TC"
-adduri -addmember "/test1?/test2/*" -addrule "1?clienthost=\'localhost\' and serverhost
like \'\%%.ibm.com\'?Default_TC" 
Create a work class for a routing policy with a default type of HTTP. Its default action type is permit, and the action is the generic server cluster name where requests are routed to.
wsadmin -lang jython -f workclassoperations.py -odrname ODR -odrnode myNode01
-wcname GSCWorkClass  -vhost default_host -wctype GSC -setdefaultaction "permit?myGSC" -adduri -addmember "/test1/*"
Create a work class for the service policy with a default type of HTTP. If you are issuing this command on UNIX base operating system, the escape sequence (\%%) should be replaced by (\%).
wsadmin -lang jython -f workclassoperations.py -odrname ODR -odrnode myNode01
-wcname GSCWorkClass -vhost default_host -wctype GSC -addrule "1?serverhost=\'localhost\'
and serverhost like \'\%%.ibm.com\'?TransactionClassA" -setdefaultaction "TransactionClassB"
Delete a rule with priority 1 in the CustomWorkClass work class for a routing policy.
wsadmin -lang jython -f workclassoperations.py -deleterule 1 -wcname CustomWorkClass
 -appname A -wctype ARP"    
List rules in the CustomWorkClass work class for both (-both option) routing and service policies for the enterprise application A.
wsadmin -lang jython -f workclassoperations.py -listrule -wcname CustomWorkClass
-both -appname A -wctype APP"    
List rules in the CustomWorkClass work class for both (-both option) routing and service policies for the generic server cluster.
wsadmin -lang jython -f workclassoperations.py -listrule -wcname CustomWorkClass
-both -odrname ODR -odrnode theTestNode01 -wctype GSC"    
Get default actions in work class named CustomWorkClass for both (-both option) routing and service policies.
wsadmin -lang jython -f workclassoperations.py -getdefaultaction -wcname CustomWorkClass
-both -appname A -wctype APP"     
Delete a routing policy work class named CustomWorkClass under the enterprise application A.
wsadmin -lang jython -f workclassoperations.py -deletewc -wcname CustomWorkClass
-appname A -wctype ARP"    
Delete a service policy work class named CustomWorkClass under the enterprise application A edition.
 wsadmin -lang jython -f workclassoperations.py -deletewc -wcname CustomWorkClass
-appname A -wctype ASP" 
Delete a service policy work class named CustomWorkClass under the ODR named myODR.
wsadmin -lang jython -f workclassoperations.py -deletewc -wcname CustomWorkClass
-odrname myODR -wctype GSP"   
Delete a routing policy work class named CustomWorkClass under the ODR named myODR.
wsadmin -lang jython -f workclassoperations.py -deletewc -wcname CustomWorkClass
-odrname myODR -wctype GRP"    
List URIs in work class named CustomWorkClass for application A and web module microwebapp.
wsadmin -lang jython -f workclassoperations.py -listuri -listmember -wcname CustomWorkClass
-appname A -webmodule microwebapp"    
Delete URIs in work class named CustomWorkClass for application A and web module microwebapp. Use the -wctype ARP or ASP to distinguish between routing and service policies work class. If -wctype is not used, the routing policy work class is used.
wsadmin -lang jython -f workclassoperations.py -deleteuri  -deletemember "/myURI/help.jsp"
-wcname CustomWorkClass -appname A -webmodule microwebapp"    
Create an enterprise application work class for a routing policy with two additional rules and the default. If you are issuing this command on UNIX base operating system, the escape sequence (\%%) should be replaced by (\%).
wsadmin -lang jython -f workclassoperations.py -appname A -webmodule microwebapp
-wcname Custom2WorkClass -wctype APP -type HTTP -adduri -addmember "/test1?/test2/*"
-setdefaultaction "redirect?http://www.ibm.com" -addrule "1?clienthost=\'localhost\'
and serverhost like \'\%%.ibm.com\'?permit?A"  -addrule "2?protocol IN (\'HTTP\',\'HTTPS\')?permitsticky?A" 
Adds URIs to an existing work class named CustomWorkClass for application A and web module microwebapp.
wsadmin -lang jython -f workclassoperations.py -adduri -addmember "/myURI/help.jsp" -wcname
CustomWorkClass -appname A -webmodule microwebapp -wctype ARP"  
Create an enterprise application SOAP work class for a routing policy. It has the default action of reject with a reject code of 404. If you are issuing this command on UNIX base operating system, the escape sequence (\%%) should be replaced by (\%).
wsadmin -lang jython -f workclassoperations.py -appname A -wcname CustomWorkClass -type 
SOAP -wctype APP -webmodule myWebModule -adduri -addmember "RemoteTest:addJob?RemoteTest:removeJob" 
-addrule "1?clienthost=\'localhost\' and serverhost like \'\%%.ibm.com\'?permit" 
-setdefaultaction "reject?404"
Create an IIOP work class named IIOPWorkClass_001 for a service policy mapping to the default transaction class for all EJBs and all methods in EJB module named IIOPTestEjb_Server.jar contained in application named MyEjbApplication. [Version 6.0.1 and later]
Important: Routing policy work classes are not supported for IIOP. Only service policy work classes are supported. Additionally, to specify more than one EJB or method, use the following format: <ejbName>:<ejbMethod>?<ejbName>:<ejbMethod>.

For example: -addmember Demo_001:method_001?Demo_002:method_002

wsadmin -lang jython -f  workclassoperations.py -appname  
MyEjbApplication -wcname IIOPWorkClass_001  -type IIOP  -wctype 
ASP  -webmodule  IIOPTestEjb_Server  -setdefaultaction "Default_TC"
-addmember *:*
Create an IIOP work class named IIOPWorkClass_002 for a service policy mapping to the transaction class named TC_A_IIOP_002 for EJB named Demo and all methods in the Demo EJB module named IIOPTestEjb_Server.jar contained in application named MyEjbApplication.
wsadmin -lang jython -f workclassoperations.py -appname 
MyEjbApplication -wcname IIOPWorkClass_002 type IIOP -wctype 
ASP -webmodule IIOPTestEjb_Server -setdefaultaction "TC_A_IIOP_002" 
-addmember Demo:*
Create an IIOP work class named IIOPWorkClass_003 for a service policy mapping to the default transaction class for an EJB named Demo and all methods in the Demo EJB module named IIOPTestEjb_Server.jar contained in application named MyEjbApplication. If the method name is mySpecialMethod and the client host name is localhost, map the service policy to the transaction class TC_A_IIOP_003.
wsadmin -lang jython -f workclassoperations.py -appname 
MyEjbApplication -wcname IIOPWorkClass_003 -type IIOP -wctype 
ASP -webmodule IIOPTestEjb_Server -setdefaultaction "Default_TC" 
-addmember Demo:mySpecialMethod -addrule "1?clienthost=\'localhost\'?TC_A_IIOP_003"
Create a JMS work class. For JMS work classes, the format must be <bus>:<destination>?<bust>:<destination>This example is for two entries. [Version 6.0.1 and later]
wsadmin.sh -lang jython -f workclassoperations.py -appname A 
-wcname JMSWorkClass1 -type JMS -wctype ASP -webmodule 
microwebmodule -setdefaultaction "Default_TC" -addmember 
bus1:destination1
wsadmin.sh -lang jython -f workclassoperations.py -appname MdbAA 
-wcname JMSWorkClass2 -type JMS -wctype ASP -webmodule MDBAA 
-ejbNameMDBAA  -setdefaultaction "Default_TC"  -addmember 
bus1:destination2



Related reference
Routing and service policies work classes
Reference topic    

Terms of Use | Feedback

Last updated: Nov 30, 2007 4:05:14 PM EST
http://publib.boulder.ibm.com/infocenter/wxdinfo/v6r0/index.jsp?topic=/com.ibm.websphere.xd.doc/info/reference/rodwcscript.html