Template tag

This tag adds the contents of a template to the target topology.

Attributes

Table 1. Attributes of the template tag
Attribute Type Required or optional Description
addMissingUnits Boolean Optional This attribute is meaningful only when you set the useExistingUnits attribute to true. Set the addMissingUnits attribute to true (the default) if you want to add the units that are not in the topology. Set this attribute to false to skip units that are in the template but not in the topology.
id String Required The ID of the template to be added to the topology. For a list of templates in the topology editor domains, see Domains supported by the topology editor.
prefix String Optional A prefix to add to the internal name of the new units. This name is not visible in the topology editor. You can use this prefix later to access and update the units.

If you add more than one instance of a template to a topology, specify a different prefix for each instance. Otherwise, more than one unit may have the same internal name, which can cause the topology editor to show warnings. Resolutions can resolve these warnings by giving unique internal names to units.

topology XPath Optional The XPath location of the topology to which to add the contents of the template. The default value is $TargetObject, which refers to the topology that you select when you import information from the CSV file.
useExistingUnits Boolean Optional Set this attribute to true if you want to reuse and update existing units in the topology rather than creating new units from the template. The default value is false.
var String Optional The name of a variable to create that refers to the elements in the template. If you assign a variable name here, you can use that variable in other places in the JET code to refer to the new topology elements.

Examples

The following example shows JET code that creates an instance of the template server.intel_x86.conceptual, which includes a conceptual x86 server unit.
<deploy:template id="server.intel_x86.conceptual" topology="$TargetObject"/>
For greater control, you can refer to the topology elements in the template. For example, the following code sets the caption of the conceptual x86 server unit in the template.
<deploy:template id="server.intel_x86.conceptual" topology="$TargetObject">
  <deploy:unit name="New server unit" type="server.X86ServerUnit"/>
</deploy:template>
By default, the template tag creates new units in the topology. However, you can reuse units from the topology by setting the useExistingUnits attribute to true. In this case, instead of creating new units, the template tag accesses and updates the matching units. The template tag matches units first by the unit name; if no units match by name, it matches units by the caption (applicable for templates that instantiates single unit only). Then you can nest tags within the template tag and make changes to the units. Specifying a prefix for the units makes it easier to access them later. For example, you can first add units from a template and apply a prefix, as in the following code:
<deploy:template id="was.WasNodeUnit.7.infra" 
  prefix="BaseAppSrvCell_BaseAppSrvNode_" 
  useExistingUnits="false"/>
Then you can access and update the units from that template by using the template tag again, as in the following code:
<deploy:template id="was.WasNodeUnit.7.infra" 
  prefix="BaseAppSrvCell_BaseAppSrvNode_" 
  useExistingUnits="true">
  <deploy:unit name="BaseAppSrvCell_BaseAppSrvNode_was_WasNodeUnit_0" 
  type="was.WasNodeUnit" displayName="BaseAppSrvNode" 
  var="nodeUnit">
    <deploy:capability name="WebSphere Node" 
      type="was.WasNode" preferNameMatch="false">
        <deploy:set name="profileName" value="'testProfile'" />
    </deploy:capability>
  </deploy:unit>
</deploy:template>
When you specify a prefix with the prefix attribute, the internal name of the new units (not the captions) follows this pattern:
prefixunitType_counter
prefix
The prefix you specified in the prefix attribute.
unitType
The unit type, with the period replaced with an underscore character. For example, the previous code example creates a unit of the type was.WasNodeUnit, so the internal name uses was_WasNodeUnit.
counter
A number that increments with each unit of the same type. For the first unit of a certain type, this number is 0.
For example, the previous code example creates a unit of the type was.WasNodeUnit. The template tag adds the prefix BaseAppSrvCell_BaseAppSrvNode_. The complete internal name of the unit is BaseAppSrvCell_BaseAppSrvNode_was_WasNodeUnit_0. Later, the code example accesses this unit by this name and makes updates to it without creating a new unit.

Feedback