+

Search Tips   |   Advanced Search

workclassoperations.py script

Use the workclassoperations.py script to create, update, and manage work classes.

We can complete the following actions with the workclassoperations.py script:

The workclassoperations.py script is in the app_server_root/bin directory.

The script usage for general help follows:

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

The script usage for operation-specific help follows:

./wsadmin.sh -lang jython -f workclassoperations.py operation --help

Depending on where we are issuing the command, we might have to specify the path to the workclassoperation.py script. For example, we create a profile named Dmgr01 located in the c:\app_server_root\profiles\Dmgr01\bin directory.

./wsadmin.sh -lang jython -f ../../../bin/workclassoperations.py
Note that if the deployment manager is not started, we must include the additional parameter -conntype NONE:
./wsadmin.sh -lang jython -conntype NONE workclassoperations.py 


Operations

listWorkClasses

List work classes by type. The format of listing is workclassname type appname/odrname deploymentname

  • --type: Type of work class to list:

  • --appname: Name of the application. Required if we specify the --type parameter as ASP or ARP.
  • --odrname: Name of the on demand router. Required if we specify the --type parameter as GSP or GRP.

createWorkClass

Creates a work class. The new service policy does not contain any application modules or classification rules. We must create and associate application modules and classification rules separately.

  • :

    • --type: Type of work class to list:

    • --appname: Name of the application. Required if we specify the --type parameter as ASP or ARP.
    • --odrname: Name of the on demand router. Required if we specify the --type parameter as GSP or GRP.
    • --nodename: Name of the node. Required if we specify the --type parameter as GSP or GRP.
    • --wcname: Unique name for the work class within the specified type.
    • --protocol: Communications protocol that transmits the request. Currently supported protocols are HTTP, IIOP, SOAP, and JMS.
    • --wcaction: Default action to take when a request is matched to a member for the specified work class.
    • --module: Application module to associate members. Required if we specify the --appname and --members parameters.
    • --members: Protocol-specific pattern:

      • HTTP: /test1?/test2/*
      • IIOP: ejbName:ejbMethod?ejbName:ejbMethod
      • SOAP: webService:operationName?webService:operationName
      • JMS: bus:destination?bus:destination

    • --rule: Classification rule in the format of "priority?rule?action"
    • --virtualhost: Virtual host. Required if we specify the --type parameter as GSP or GRP.

  • removeWorkClass: Removes a work class.

    • --type: Type of work class to remove:

    • --appname: Name of the application. Required if we specify the --type parameter as ASP or ARP.
    • --odrname: Name of the on demand router. Required if we specify the --type parameter as GSP or GRP.
    • --wcname: Unique name for the work class within the specified type.

  • addMembers: Adds members to a work class. The ODR uses the new member to match incoming requests.

    • --type: Type of work class to remove:

    • --appname: Name of the application. Required if we specify the --type parameter as ASP or ARP.
    • --odrname: Name of the on demand router. Required if we specify the --type parameter as GSP or GRP.
    • --wcname: Unique name for the work class within the specified type.
    • --protocol: Communications protocol that transmits the request. Currently supported protocols are HTTP, IIOP, SOAP, and JMS.
    • --module: Application module to associate members. Required if we specify the --appname and --members parameters.
    • --members: Protocol-specific pattern:

      • HTTP: /test1?/test2/*
      • IIOP: ejbName:ejbMethod?ejbName:ejbMethod
      • SOAP: webService:operationName?webService:operationName
      • JMS: bus:destination?bus:destination

    • --ejbname: Name of the EJB. Required only when we specify the --protocol parameter as JMS and the --module parameter as IIOP.

  • removeMembers: Removes members from a work class. The member is no longer used by the ODR.

    • --type: Type of work class to modify:

    • --appname: Name of the application. Required if we specify the --type parameter as ASP or ARP.
    • --odrname: Name of the on demand router. Required if we specify the --type parameter as GSP or GRP.
    • --wcname: Unique name for the work class within the specified type.
    • --protocol: Communications protocol that transmits the request. Currently supported protocols are HTTP, IIOP, SOAP, and JMS.
    • --module: Application module from which to disassociate members. Required if we specify the --appname and --members parameters.
    • --members: Protocol-specific pattern:

      • HTTP: /test1?/test2/*
      • IIOP: ejbName:ejbMethod?ejbName:ejbMethod
      • SOAP: webService:operationName?webService:operationName
      • JMS: bus:destination?bus:destination

  • listMembers: Lists members of a work class.

    • --type: Type of work class to list:

    • --appname: Name of the application. Required if we specify the --type parameter as ASP or ARP.
    • --odrname: Name of the on demand router. Required if we specify the --type parameter as GSP or GRP.
    • --nodename: Name of the node. Required if we specify the --type parameter as GSP or GRP.
    • --wcname: Unique name for the work class within the specified type.
    • --protocol: Communications protocol that transmits the request. Currently supported protocols are HTTP, IIOP, SOAP, and JMS.

  • addRules: Adds a classification rule used by the ODR to a work class. If we issue the command with the like wildcard '%' on UNIX operating systems, replace the escape sequence (\%%) with (\%).

    • --type: Type of work class to modify:

    • --appname: Name of the application. Required if we specify the --type parameter as ASP or ARP.
    • --odrname: Name of the on demand router. Required if we specify the --type parameter as GSP or GRP.
    • --nodename: Name of the node. Required if we specify the --type parameter as GSP or GRP.
    • --wcname: Unique name for the work class within the specified type.
    • --rule: Classification rule in the format of "priority?rule?action"

  • removeRule: Removes a classification rule from a work class. The rule is no longer used by the ODR.

    • --type: Type of work class to modify:

    • --appname: Name of the application. Required if we specify the --type parameter as ASP or ARP.
    • --odrname: Name of the on demand router. Required if we specify the --type parameter as GSP or GRP.
    • --wcname: Unique name for the work class within the specified type.
    • --expression: Rule expression.
    • --priority: Priority of the rule to match. The rule with the lowest priority is matched first.

  • listRules: Lists classification rules.

    • --type: Type of work class to modify:

    • --appname: Name of the application. Required if we specify the --type parameter as ASP or ARP.
    • --odrname: Name of the on demand router. Required if we specify the --type parameter as GSP or GRP.
    • --wcname: Unique name for the work class within the specified type.

  • modifyDefaultAction: Edits the default action for a work class.

    • --type: Type of work class to modify:

    • --appname: Name of the application. Required if we specify the --type parameter as ASP or ARP.
    • --odrname: Name of the on demand router. Required if we specify the --type parameter as GSP or GRP.
    • --wcname: Unique name for the work class within the specified type.
    • --wcaction: Default action to take when a request is matched to a member for the specified work class.

  • getDefaultAction: Default action for a work class.

    • --type: Type of work class to list:

    • --appname: Name of the application. Required if we specify the --type parameter as ASP or ARP.
    • --odrname: Name of the on demand router. Required if we specify the --type parameter as GSP or GRP.
    • --wcname: Unique name for the work class within the specified type.

  • modifyVirtualHost: Edits the virtual host for a work class.

    • --type: Type of work class to modify. The valid types are GSP and GRP.
    • --odrname: Name of the on demand router. Required if we specify the --type parameter as GSP or GRP.
    • --wcname: Unique name for the work class within the specified type.
    • --virtualhost: Virtual host. Required if we specify the --type parameter as GSP or GRP.

  • getVirtualHost: Lists the virtual host for a work class.

    • --type: Type of work class to list. The valid types are GSP and GRP.
    • --odrname: Name of the on demand router. Required if we specify the --type parameter as GSP or GRP.
    • --wcname: Unique name for the work class within the specified type.


Example

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

Create a HTTP application routing policy work class for application Trade with a default action of reject and reject code of 404:

./wsadmin.sh -lang jython -f workclassoperations.py createWorkClass 
--type ARP --wcname CustomWorkClass --protocol HTTP --wcaction "reject?404" --appname Trade 
--module myModule.war --members "/test1?/test2"

List all routing policy work classes for application Trade:

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

View the default action of a HTTP application routing policy work class for application Trade:

./wsadmin.sh -lang jython -f workclassoperations.py getDefaultAction 
--type ARP --wcname CustomWorkClass --appname Trade

Modify the default action to Default_TC in a HTTP application service policy work class for application Trade-edition1.0:

./wsadmin.sh -lang jython -f workclassoperations.py modifyDefaultAction --type ASP --wcname Default_HTTP_WC 
--wcaction Default_TC --appname Trade-edition1.0

Map the default HTTP work class of edition 1.2 of the DayTrader application to the default transaction class for the service policy GOLD:

import java.lang.System as System

wasinstallroot=System.getProperty("was.install.root")
execfile(wasinstallroot+"/bin/IMPPYModules.py")
import java.lang.System as System

wasinstallroot=System.getProperty("was.install.root")
execfile(wasinstallroot+"/bin/IMPPYModules.py")

#application with name DayTrader installed with edition 1.2
appName="DayTrader-edition1.2"
#Default_TC_GOLD is the default transaction class mapped to service policy GOLD
modifyAppSLADefaultAction("Default_HTTP_WC", appName, tcName, 0)

AdminConfig.save()

For transitioning users: The WebSphere Virtual Enterprise command that equates to IMPPYModules.py is XDPYModules.py. If we are making the transition from WebSphere Virtual Enterprise, we can continue to use the XDPYModules.py command, which operates the same as the IMPPYModules.py command.trns

Add a classification rule to the application service policy work class for application Trade:

./wsadmin.sh -lang jython -f workclassoperations.py addRules --wcname CustomWorkClass 
--appname Trade --type ARP --rule "1?clienthost=\'localhost\' and serverhost like \'\%%.ibm.com\'?permit?Trade"

Remove a classification rule by priority from the application service policy work class for application Trade:

./wsadmin.sh -lang jython -f workclassoperations.py removeRule --wcname 
CustomWorkClass --appname Trade --type ARP --priority 1

Remove a HTTP application routing policy work class for application Trade:

./wsadmin.sh -lang jython -f workclassoperations.py removeWorkClass --type ARP 
--wcname CustomWorkClass --appname Trade


Related:

  • Overview of work classes
  • Intelligent Management: routing and service policies