Set tag
This tag assigns a value to an attribute on a topology
element, usually on a capability or requirement.
Attributes
Attribute | Type | Required or optional | Description |
---|---|---|---|
isEncrypted | Boolean | Optional | Whether the attribute is encrypted, such as a password. The default is false. |
isExtended | Boolean | Optional | If this attribute is set to false (the default), the tag refers to a standard attribute on the topology element. If this attribute is set to true, the tag refers to a custom attribute as described in Adding custom attributes to capabilities. |
name | String | Required | The name of the attribute. The attribute name is not always the name that is shown in the topology editor; you must specify the internal name of the attribute as specified in the domain. For attribute names, see Domains supported by the topology editor. |
owner | XPath | Optional | The XPath location of the topology element that contains the attribute to set. If this attribute is not specified, the set tag must be within a tag that represents the containing topology element. |
searchOwnedCaps | Boolean | Optional | Specifies whether to search the capabilities of the current unit for an attribute value. The default value is false. This attribute is meaningful only when the set tag is a child of a unit tag. See the example of the searchOwnedCaps attribute after this table. |
type | String | Optional | The type of the custom attribute. This attribute
is meaningful only if the isExtended attribute
is set to true. Valid values are:
|
value | XPath | Required | The value to set the attribute to. You can specify a variable, an XPath reference to the CSV file, or a literal value in two sets of quotes. |
Examples
You can use a value from the CSV
file in the value attribute, as in the following
example:
<deploy:capability type="os.WindowsOperatingSystem"
name="Windows">
<%-- set hostname --%>
<deploy:set name="hostname" value="/csv/row[2]/cell[8]"/>
</deploy:capability>
You can also define a variable
with context.setVariable and use that variable in
the value attribute, as in the following example:<deploy:capability type="os.WindowsOperatingSystem"
name="Windows">
<%-- set hostname --%>
<c:setVariable select="'com.mycompany.server1'" var="hostnameVar"/>
<deploy:set name="hostname" value="$hostnameVar"/>
</deploy:capability>
You can also specify a literal
value for the in the value attribute with two
sets of quotes, as in the following example:
<deploy:capability type="os.WindowsOperatingSystem"
name="Windows">
<%-- set hostname --%>
<deploy:set name="hostname" value="'com.mycompany.server1'"/>
</deploy:capability>
The following code shows
a complete example of how to set attributes on capabilities when you
add a template to a topology.
<%-- add a concrete Windows Server 2008 unit to the topology --%>
<deploy:template id="os.OperatingSystemUnit.WServer2008.infra">
<%-- access the operating system unit in the template --%>
<deploy:unit name="My OS unit" type="os.WindowsOperatingSystemUnit">
<%-- access the operating system capability on the unit --%>
<deploy:capability
type="os.WindowsOperatingSystem"
name="Windows Server 2008" preferNameMatch="false">
<%-- set hostname to "com.mycompany.server1" --%>
<c:setVariable select="'com.mycompany.server1'" var="hostnameVar"/>
<deploy:set name="hostname" value="$hostnameVar"/>
</deploy:capability>
</deploy:unit>
</deploy:template>
As a shortcut, you can use
the searchOwnedCaps attribute to set values on
capabilities. If you set searchOwnedCaps to true,
and the set tag is the child of a unit tag, the set tag applies first
to the attributes of the unit. If the unit has no matching attribute,
the set tag then applies to the capabilities of that unit. For example,
the following code sets attributes on a capability without accessing
the capability directly:
<deploy:unit name="New server unit" type="server.X86ServerUnit">
<deploy:set name="cpuCount" value="'4'" searchOwnedCaps="true"/>
<deploy:set name="cpuArchitectureWidth" value="'32-bit'" searchOwnedCaps="true"/>
<deploy:set name="virtual" value="'false'" searchOwnedCaps="true"/>
</deploy:unit>
The previous code is equivalent
to the following example:
<deploy:unit name="New server unit" type="server.X86ServerUnit">
<deploy:capability type="server.X86Server" name="x86 Server">
<deploy:set name="cpuCount" value="'4'"/>
<deploy:set name="cpuArchitectureWidth" value="'32-bit'"/>
<deploy:set name="virtual" value="'false'"/>
</deploy:capability>
</deploy:unit>