Create a server using scripting
Use the commands in the ServerManagement command group for the AdminTask object or the AdminServerManagement script library to create a new application server, web server, proxy server, or generic server.
There are three ways to complete this task. This topic uses the AdminConfig object and the commands for the AdminTask object to create a new server configuration. Alternatively, we can use the scripts in the AdminServerManagement script library to create an application server, web server, proxy server, or generic server.
Tasks
- Start the wsadmin scripting tool.
- Obtain the configuration ID of the node object.
The following examples obtain the configuration ID of the node object and assign it to the node variable. In these examples, node is the name of the node to which we are adding the new server, server is the name of the server we are creating, template_name is the name of the template we want used to create the server. The AdminTask.createApplicationServer() command requires us to specify a node name. The node name must be enclosed within single quotation marks. The AdminConfig.create() command requires us to specify the configuration ID of the node object. If we do not know the configuration ID, run the AdminConfig.getid('/Node:node') command to obtain that information.
- Use Jacl:
set node [$AdminConfig getid /Node:node/]
- Use Jython:
node = AdminConfig.getid('/Node:node/')
To display the configuration ID of the node object,:
print node
- Determine whether to use the AdminConfig or AdminTask object to create the server.
- Create the server.
A server name can not contain a blank character..
- The following example uses the commands for the AdminTask object to create a server:
Use the AdminTask object:
- Jacl:
$AdminTask createApplicationServer node {-name server -templateName template_name}
- Jython:
AdminTask.createApplicationServer('node', ['-name', 'server', '-templateName', 'template_name'])
- The following example uses the AdminConfig object to create a server. In these examples, node is the node variable to which the configuration ID of the node object is assigned.
Use the AdminConfig object:
- Jacl:
$AdminConfig create Server $node {{name server}}
- Jython:
AdminConfig.create('Server', node, ['name', 'server'])
- Save the configuration changes.
AdminConfig.save()
- In a network deployment environment only, 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")
Example
Create file createServer.jython with...
AdminTask.createApplicationServer('myNode', ['-name', 'myNewServer'])
AdminConfig.save()
AdminNodeManagement.syncNode("myNode")Run...
wsadmin -lang jython -f createServer.jython -username wasadmin -password wasadmin
Synchronize nodes Create application servers Create generic servers Create WebSphere proxy servers wsadmin AdminConfig Server configuration scripts Server settings configuration scripts Commands for the AdminConfig object