Create configuration objects using the wsadmin scripting tool
Use scripting and the wsadmin tool to create configuration objects.
Perform this task to create an object. To create new objects from the default template, use the create command. Alternatively, we can create objects using an existing object as a template with the createUsingTemplate command. We can only use the createUsingTemplate command for creation of a server with APPLICATION_SERVER type. To create a server with a type other than APPLICATION_SERVER, use the createGenericServer or the createWebServer command.
Tasks
- Start the wsadmin scripting tool.
- Use the AdminConfig object listTemplates command to list available templates:
Use Jacl:
$AdminConfig listTemplates JDBCProvider
Use Jython:
AdminConfig.listTemplates('JDBCProvider')
Attribute Definition $ is a Jacl operator for substituting a variable name with its value AdminConfig that represents the WebSphere Application Server configuration listTemplates AdminConfig command JDBCProvider Object type - Assign the ID string that identifies the existing object to which the new object is added. We can add the new object under any valid object type. The following example uses a node as the valid object type:
Use Jacl:
set n1 [$AdminConfig getid /Node:mynode/]
Use Jython:
n1 = AdminConfig.getid('/Node:mynode/')
AdminConfig getid command description.
Attribute Definition set Jacl command $ Jacl operator for substituting a variable name with its value n1 Variable name AdminConfig Object representing the WAS configuration getid AdminConfig command Node Object type mynode Name of the node where the new object is added - Template to use:
Use Jacl:
set t1 [$AdminConfig listTemplates JDBCProvider "DB2 JDBC Provider (XA)"]
Use Jython:
t1 = AdminConfig.listTemplates('JDBCProvider', 'DB2 JDBC Provider (XA)')
Attribute Definition set Jacl command $ Jacl operator for substituting a variable name with its value t1 Variable name AdminConfig Object representing the WAS configuration listTemplates AdminConfig command JDBCProvider Object type DB2 JDBC Provider (XA) Name of the template to use for the new object If we supply a string after the name of a type, we get back a list of templates with display names that contain the string you supplied. In this example, the AdminConfig listTemplates command returns the JDBCProvider template whose name matches DB2 JDBC Provider (XA). This example assumes that the variable specified here only holds one template configuration ID. If the environment contains multiple templates with the same string, for example, DB2 JDBC Provider (XA), the variable will hold the configuration IDs of all of the templates. Be sure to identify the specific template to use before performing the next step, creating an object using a template.
- Create the object with the following command:
Use Jacl:
$AdminConfig createUsingTemplate JDBCProvider $n1 {{name newdriver}} $tl
Use Jython:
AdminConfig.createUsingTemplate('JDBCProvider', n1, [['name', 'newdriver']], t1)
Attribute Definition $ Jacl operator for substituting a variable name with its value AdminConfig Object representing the WAS configuration createUsingTemplate AdminConfig command JDBCProvider Object type n1 Evaluate the ID of the host node specified in step number 3 name Attribute of JDBCProvider objects newdriver Value of the name attribute t1 Evaluate the ID of the template specified in step number 4 All create commands use a template unless there are no templates to use. If a default template exists, the command creates the object.
- Save the configuration changes.
AdminConfig.save()
- In a multiple-server environment, synchronize the node.
Use the syncActiveNode or syncNode scripts in the AdminNodeManagement script library to propagate the configuration changes to node or nodes.
- Use the syncActiveNodes script to propagate the changes to each node in the cell:
AdminNodeManagement.syncActiveNodes()
- Use the syncNode script to propagate the changes to a specific node:
AdminNodeManagement.syncNode("myNode")
Start the wsadmin scripting client Use the script library to automate the application serving environment wsadmin AdminConfig Commands for the AdminConfig object