Creating new virtual hosts using templates with scripting

 

Creating new virtual hosts using templates with scripting

Before starting this task, the wsadmin tool must be running. See the Starting the wsadmin scripting client article for more information.

Some configuration object types have templates that you can use when you create a virtual host. You 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:

  1. If you want to create a new custom template...

    1. Copy and paste the following file into a new file, myvirtualhostname.xml:
      install_root/config/templates/default/virtualhosts.xml

      where install_root is /QIBM/ProdData/WebSphere/AppServer/V6/Base for WebSphere Application Server and WebSphere Application Server Express, and /QIBM/ProdData/WebSphere/AppServer/V6/ND for WebSphere Application Server Network Deployment.

    2. Edit and customize the new myvirtualhostname.xml file.

    3. Place the new file in the following directory:
      install_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:

    • Using Jacl:
      $AdminConfig reset

    • Using Jython:
      AdminConfig.reset()

    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.

  2. Use the AdminConfig object listTemplates command to list available templates, for example:

    • Using Jacl:
      $AdminConfig listTemplates VirtualHost

    • Using 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:

    • Using Jacl:
      set cell [$AdminConfig getid /Cell|NetworkDeploymentCell/]
      set vtempl [$AdminConfig listTemplates VirtualHost my_host]
      $AdminConfig createUsingTemplate VirtualHost $cell {{name newVirHost}} $vtempl

    • Using 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 Saving configuration changes with the wsadmin tool article for more information.

  5. In a network deployment environment only, synchronize the node. See the Synchronizing nodes with the wsadmin tool article for more information.



Related concepts
AdminConfig object for scripted administration

Related reference
Commands for the AdminConfig object