Create new virtual hosts using templates with scripting
Use scripting to create a new virtual host from a new or preexisting template.
Some configuration object types have templates that we can use when we create a virtual host. Create a new virtual host using a preexisting template or by creating a new custom template. Perform the following steps to create a new virtual host using a template:
Tasks
- To create a new custom template...
- Copy and paste the following file into a new file, myvirtualhostname.xml:
app_server_root\config\templates\default\virtualhosts.xml(iSeries)
app_server_root/config/templates/default/virtualhosts.xml- Edit and customize the new myvirtualhostname.xml file.
- Place the new file in the following directory:
app_server_root\config\templates\custom\(iSeries)
app_server_root/config/templates/custom/
If we want the new custom template to appear with the list of templates, restart the deployment manager.
The administrative console does not support the use of custom templates. The new template that we create will not be visible in the administrative console panels.
- Use the AdminConfig object listTemplates command to list available templates, for example:
- Jacl:
$AdminConfig listTemplates VirtualHost- Jython:
print AdminConfig.listTemplates('VirtualHost')Example output:
default_host(templates/default:virtualhosts.xml#VirtualHost_1) my_host(templates/custom:virtualhostname.xml#VirtualHost_1)- Create a new virtual host. For example:
- Jacl:
set cell [$AdminConfig getid /Cell:NetworkDeploymentCell/] set vtempl [$AdminConfig listTemplates VirtualHost my_host] $AdminConfig createUsingTemplate VirtualHost $cell {{name newVirHost}} $vtempl- Jython:
cell = AdminConfig.getid('/Cell:NetworkDeploymentCell/') vtempl = AdminConfig.listTemplates('VirtualHost', 'my_host') AdminConfig.createUsingTemplate('VirtualHost', cell, [['name', 'newVirHost']], vtempl)
- Save the configuration changes.
- In a network deployment environment only, synchronize the node.
wsadmin AdminConfig Start the wsadmin scripting client Save wsadmin configuration changes Commands for the AdminConfig object