WAS v8.5 > Script the application serving environment (wsadmin) > Use the wsadmin scripting AdminConfig object for scripted administration

Specify configuration objects using wsadmin.sh

Specify configuration objects with scripting and wsadmin.

Start wsadmin.sh

To manage an existing configuration object, identify the configuration object and obtain a configuration ID of the object to use for subsequent manipulation.

  1. Obtain the configuration ID:

    • Obtain the ID of the configuration object with the getid command, for example:

      • Jacl:

          set var [$AdminConfig getid /type:name/]
      • Jython:

          var = AdminConfig.getid('/type:name/')

      We can specify multiple /type:name/ value pairs in the string, for example, /type:name/type:name/type:name/. If we specify the type in the containment path without the name, include the colon, for example, /type:/. The containment path must be a path containing the correct hierarchical order. For example, if we specify /Server:server1/Node:node/ as the containment path, we do not receive a valid configuration ID because Node is a parent of Server and comes before Server in the hierarchy.

      This command returns all the configuration IDs that match the representation of the containment and assigns them to a variable.

      To get server configuration IDs residing in the mynode node:

      • Jacl:

          set nodeServers [$AdminConfig getid /Node:mynode/Server:/]
      • Jython:

          nodeServers = AdminConfig.getid('/Node:mynode/Server:/')

      To get server1 configuration ID that resides in mynode:

      • Jacl:

          set server1 [$AdminConfig getid /Node:mynode/Server:server1/]
      • Jython:

          server1 = AdminConfig.getid('/Node:mynode/Server:server1/')

      To get server configuration IDs:

      • Jacl:

          set servers [$AdminConfig getid /Server:/]
      • Jython:

          servers = AdminConfig.getid('/Server:/')

    • Obtain the ID of the configuration object with the list command, for example:

      • Jacl:

          set var [$AdminConfig list type]
        or

          set var [$AdminConfig list type scopeId]
      • Jython:

          var = AdminConfig.list('type')
        or

          var = AdminConfig.list('type', 'scopeId')

      This command returns a list of configuration object IDs of a given type. If we specify the scopeId value, the list of objects is returned within the specified scope. The returned list is assigned to a variable.

      To get server configuration IDs:

      • Jacl:

          set servers [$AdminConfig list Server]
      • Jython:

          servers = AdminConfig.list('Server')

      To get server configuration IDs in the mynode node:

      • Jacl:

        set scopeid [$AdminConfig getid /Node:mynode/]
        set nodeServers [$AdminConfig list Server $scopeid]
      • Jython:

        scopeid = AdminConfig.getid('/Node:mynode/')
        nodeServers = AdminConfig.list('Server', scopeid)

  2. If more than one configuration ID is returned from the getid or the list command, the IDs are returned in a list syntax.

    One way to retrieve a single element from the list is to use the lindex command. The following example retrieves the first configuration ID from the server object list:

    • Jacl:

      set allServers [$AdminConfig getid /Server:/]
      set aServer [lindex $allServers 0]
    • Jython:

      allServers = AdminConfig.getid('/Server:/')
      
       # get line separator 
       import  java  lineSeparator = java.lang.System.getProperty('line.separator')
      
       arrayAllServers = allServers.split(lineSeparator)
       aServer = arrayAllServers[0]


Results

We can now use the configuration ID in any subsequent AdminConfig commands that require a configuration ID as a parameter.


Related concepts:
Use wsadmin scripting with Jacl
Start the wsadmin scripting client using wsadmin.sh
Use the wsadmin scripting AdminConfig object for scripted administration
Commands for the AdminConfig object using wsadmin.sh


+

Search Tips   |   Advanced Search