Creating configuration objects using the wsadmin scripting tool
You can use scripting and the wsadmin tool to create configuration objects.
About this task
Perform this task if you want to create an object. To create new objects from the default template, use the create command. Alternatively, you can create objects using an existing object as a template with the createUsingTemplate command. You can only use the createUsingTemplate command for creation of a server with APPLICATION_SERVER type. If you want to create a server with a type other than APPLICATION_SERVER, use the createGenericServer or the createWebServer command.
Procedure
- 啟動 wsadmin Scripting 工具。
- Use the AdminConfig object listTemplates command
to list available templates:
Using Jacl:
$AdminConfig listTemplates JDBCProvider
Using Jython:
AdminConfig.listTemplates('JDBCProvider')
Table 1. AdminConfig listTemplates command description. Run a command from a wsadmin command line. Attribute Definition $ is a Jacl operator for substituting a variable name with its value AdminConfig is an object that represents the WebSphere® Application Server configuration listTemplates is an AdminConfig command JDBCProvider is an object type - Assign the ID string that identifies the existing object
to which the new object is added. You can add the new object under
any valid object type. The following example uses a node as the valid
object type:
Using Jacl:
set n1 [$AdminConfig getid /Node:mynode/]
Using Jython:
n1 = AdminConfig.getid('/Node:mynode/')
Table 2. AdminConfig getid command description. Run a command from a wsadmin command line. Attribute Definition set is a Jacl command $ is a Jacl operator for substituting a variable name with its value n1 is a variable name AdminConfig is an object that represents the WebSphere Application Server configuration getid is an AdminConfig command Node is an object type mynode is the name of the node where the new object is added - Specify the template that you want to use:
Using Jacl:
set t1 [$AdminConfig listTemplates JDBCProvider "DB2 JDBC Provider (XA)"]
set t1 [$AdminConfig listTemplates JDBCProvider "DB2 Universal JDBC Driver Provider (XA)"]
Using Jython:
t1 = AdminConfig.listTemplates('JDBCProvider', 'DB2 JDBC Provider (XA)')
t1 = AdminConfig.listTemplates('JDBCProvider', 'DB2 Universal JDBC Driver Provider (XA)')
If you supply a string after the name of a type, you 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 that you specify 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 that you want to use before you perform the next step, creating an object using a template.Table 3. AdminConfig listTemplates command description. Run a command from a wsadmin command line. Attribute Definition set is a Jacl command $ is a Jacl operator for substituting a variable name with its value t1 is a variable name AdminConfig is an object that represents the WebSphere Application Server configuration listTemplates is an AdminConfig command JDBCProvider is an object type DB2® JDBC Provider (XA) is the name of the template to use for the new object - Create the object with the following command:
Using Jacl:
$AdminConfig createUsingTemplate JDBCProvider $n1 {{name newdriver}} $tl
Using Jython:
AdminConfig.createUsingTemplate('JDBCProvider', n1, [['name', 'newdriver']], t1)
Table 4. AdminConfig createUsingTemplate command description. Run a command from a wsadmin command line. Attribute Definition $ is a Jacl operator for substituting a variable name with its value AdminConfig is an object that represents the WebSphere Application Server configuration createUsingTemplate is an AdminConfig command JDBCProvider is an object type n1 evaluates the ID of the host node that is specified in step number 3 name is an attribute of JDBCProvider objects newdriver is the value of the name attribute t1 evaluates the ID of the template that is 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. 請利用 AdminNodeManagement Script 程式庫中的 syncActiveNode 或 syncNode Script,將配置變更傳播給節點。
- 利用 syncActiveNodes Script,依照下列範例所示,將變更傳播給 Cell 中的每個節點:
AdminNodeManagement.syncActiveNodes()
- 利用 syncNode Script,依照下列範例所示,將變更傳播給特定的節點:
AdminNodeManagement.syncNode("myNode")
- 利用 syncActiveNodes Script,依照下列範例所示,將變更傳播給 Cell 中的每個節點:


http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=txml_template
檔名:txml_template.html