Rename Objects In Configuration Data Using the Junos XML Protocol
A Junos XML protocol client application can rename configuration objects on Junos devices.
A Junos XML protocol client application can change the name of one or more of a configuration object’s identifiers. To rename the object, a client application first includes the tag elements described in Create, Modify, or Delete Configuration Elements Using the Junos XML Protocol.
To use Junos XML elements to rename an object, the client application includes the object and its identifier element with the current name. In the object's opening tag, the application includes:
-
The
rename="rename"attribute. -
An attribute with the same name as the identifier tag name. For most objects, this is
name. The value for this attribute is the new identifier for the object.
<configuration>
<!-- opening tag for each parent of the object -->
<object rename="rename" name="new-name">
<name>current-name</name>
</object>
<!-- closing tag for each parent of the object -->
</configuration>If the object has multiple identifiers, the application includes both an identifier element and an attribute in the opening tag for each one. If one or more of the identifiers is not changing, set its attribute value to its current name. For example:
<configuration>
<!-- opening tag for each parent of the object -->
<object rename="rename" changing-identifier="new-name" \
unchanging-identifier="current-name">
<changing-identifier>current-name</changing-identifier>
<unchanging-identifier>current-name</unchanging-identifier>
</object>
<!-- closing tag for each parent of the object -->
</configuration>To use configuration mode
commands to rename an object, the application specifies the rename
command equivalent to the CLI configuration mode command. If the object has multiple
identifiers, the application includes a separate rename command for
each identifier.
<configuration-set>
rename statement-path-to-object object current-name to object new-name
</configuration-set>You cannot use the rename operation when you use formatted ASCII text or JSON to represent the configuration data.
The
following example changes the name of a firewall filter from
access-control to new-access-control using
Junos XML elements.
<rpc>
<load-configuration>
<configuration>
<firewall>
<family>
<inet>
<filter rename="rename" name="new-access-control">
<name>access-control</name>
</filter>
</inet>
</family>
</firewall>
</configuration>
</load-configuration>
</rpc>[edit firewall family inet] user@host# rename filter access-control to filter new-access-control
The following example changes the name of a firewall filter from
access-control to new-access-control using
configuration mode commands:
<rpc>
<load-configuration action="set" format="text">
<configuration-set>
rename firewall family inet filter access-control to filter new-access-control
</configuration-set>
</load-configuration>
</rpc>The following example shows how to change the identifiers
for an OSPF virtual link (defined at the
[edit protocols ospf area area]
hierarchy level) from neighbor-id 192.168.0.3 and
transit-area 10.10.10.1 to
neighbor-id 192.168.0.7 and
transit-area 10.10.10.5.
[edit protocols ospf area area] user@host# rename virtual-link neighbor-id 192.168.0.3 transit-area 10.10.10.1 to virtual-link neighbor-id 192.168.0.7 transit-area 10.10.10.5
<rpc>
<load-configuration>
<configuration>
<protocols>
<ospf>
<area>
<name>area</name>
<virtual-link rename="rename" neighbor-id="192.168.0.7" transit-area="10.10.10.5">
<neighbor-id>192.168.0.3</neighbor-id>
<transit-area>10.10.10.1</transit-area>
</virtual-link>
</area>
</ospf>
</protocols>
</configuration>
</load-configuration>
</rpc>