Create new virtual hosts using templates with scripting
Overview
Some configuration object types have templates that use when you create a virtual host. We can 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:
Procedure
- Start wsadmin
- If you want to create a new custom template, perform the following steps:
- Copy and paste the following file into a new file, myvirtualhostname.xml:
<WAS-ROOT>\config\templates\default\virtualhosts.xml- Edit and customize the new myvirtualhostname.xml file.
- Place the new file in the following directory:
<WAS-ROOT>\config\templates\custom\If you want the new custom template to appear with the list of templates, restart the deployment manager on a network deployment edition, or use the AdminConfig object reset command. For example:
The administrative console does not support the use of custom templates. The new template that you 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 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 $AdminConfig save cell = AdminConfig.getid('/Cell:NetworkDeploymentCell/') vtempl = AdminConfig.listTemplates('VirtualHost', 'my_host') AdminConfig.createUsingTemplate('VirtualHost', cell, [['name', 'newVirHost']], vtempl)
- In a network deployment environment only, synchronize the node.
See Also
AdminConfig object for scripted administration
See Also
Commands for the AdminConfig object