WAS v8.5 > Script the application serving environment (wsadmin) > Set up intermediary services using scripting

Create new virtual hosts using templates with scripting

Use scripting to create a new virtual host from a new or preexisting template.

Before starting this task, wsadmin must be running. See the topic about starting the wsadmin scripting client using wsadmin.sh for more information. Some configuration object types have templates that we can use when we create a virtual host. We can create a new virtual host using a preexisting template or by creating a new custom template. Create a new virtual host using a template:

  1. To create a new custom template, perform the following steps:

    1. Copy and paste the following file into a new file, myvirtualhostname.xml:

    2. Edit and customize the new myvirtualhostname.xml file.
    3. Place the new file in the following directory:

    If we want the new custom template to appear with the list of templates, use the AdminConfig object reset command. For example:

    • Jacl:

        $AdminConfig reset
    • Jython:

        AdminConfig.reset()

    The dmgr console does not support the use of custom templates. The new template that you create will not be visible in the dmgr console panels.

  2. 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)

  3. 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)

  4. Save the configuration changes. See the topic about saving configuration changes with wsadmin for more information.


Related


Use the wsadmin scripting AdminConfig object for scripted administration
Start the wsadmin scripting client using wsadmin.sh
Save configuration changes with wsadmin


Related information:

Commands for the AdminConfig object using wsadmin.sh


+

Search Tips   |   Advanced Search