Using a value of merge-object
with the on-exist
attribute allows users to merge data from two different elements without having to
recreate the element. When on-exist=merge-object
is applied to the
second element, the first element is modified with the data of the second element.
In the following example, an ACL named merge-example is declared twice:
Element 1:
<acl name="merge-example">
<acl-value value="133.188.167.0/26"/>
</acl>
Element 2:
<acl name="merge-example" on-exist="merge-object">
<acl-value value="51.82.246.0/26"/>
<acl-value value="97.12.0.0/25"/>
</acl>
<acl name="merge-example">
<acl-value value="133.188.167.0/26"/>
<acl-value value="51.82.246.0/26"/>
<acl-value value="97.12.0.0/25"/>
</acl>
The merging of elements via on-exist=merge-object
is intended to only
apply to the corresponding element at the same level and not it's children (unless those
children are metadata fields). The merge operation will modify the first element with
new metadata and also combine the children, but the metadata for child elements will not
change unless on-exist=merge-object
is explicitly declared on the child
element. If the elements have children that are pointing to the same element, the engine
will not combine the children to avoid creating duplicates of an element.
In the following example, an IPv4 network named Network 1 is declared twice:
Element 1:
<ip4-network range="1.1.0.0/16" name="Network 1">
<dhcp-role server="Server 1" type="master" secondary="Server 2"/>
</ip4-network>
Element 2:
<ip4-network range="1.1.0.0/16" name="Network 1" on-exist="merge-object">
<dhcp-role server="Server 1" type="none" secondary="Server 2"/>
</ip4-network>
Result:
<ip4-network range="1.1.0.0/16" name="Network 1">
<dhcp-role server="Server 1" type="master" secondary="Server 2"/>
</ip4-network>
In this example, it can be observed that:
-
The DHCP role did not change from
master
tonone
because the merge applies at the IPv4 network entity level. -
The DHCP roles are not duplicated after the merge. They are assumed to be the same entity because their identifier is the name
Server 1
To modify the DHCP role, on-exist=merge-object
must be declared at the
DHCP role level.