Edit the Configuration Using NETCONF
In a NETCONF session with a Junos device, you can use NETCONF operations to modify the device
configuration. The NETCONF operations <copy-config>
,
<edit-config>
, and <discard-changes>
offer functionality that is analogous to configuration mode commands in the Junos OS
CLI. The <copy-config>
and <edit-config>
operations support loading configuration data formatted as Junos XML elements or CLI
configuration statements.
To change the configuration, a client application emits the <copy-config>
,
the <edit-config>
, or the
<discard-changes>
tag element and the corresponding tag
subelements within the <rpc>
tag element.
The following examples show the various available tag elements:
<rpc> <copy-config> <target><candidate/></target> <error-operation> (ignore-error | stop-on-error) </error-operation> <source> (<running/> | <url>location</url>) </source> </copy-config> </rpc> ]]>]]>
<rpc> <edit-config> <target><candidate/></target> <default-operation>operation</default-operation> <error-operation>error</error-operation> <(config | config-text | url)> <!-- configuration change file or data --> </(config | config-text | url)> </edit-config> </rpc> ]]>]]>
<rpc> <discard-changes/> </rpc> ]]>]]>
The only acceptable value for the <target>
element is
<candidate/>
, which can refer to either the candidate
configuration or the open configuration database. If a client application issues the
Junos XML protocol <open-configuration>
operation to open a
specific configuration database before executing a
<copy-config>
or <edit-config>
operation, the device performs the operation on the open configuration database.
Otherwise, the device performs the operation on the candidate configuration.
The three tags—<copy-config>
, <edit-config>
, and <discard-changes>
—correspond to the three basic configuration tasks available
to you, which are described here:
Overwrite the target configuration with a new configuration—Use the
<copy-config>
operation to replace the target configuration with a new configuration.Edit configuration elements—Use the
<edit-config>
operation to add, change, or delete specific configuration elements within the target configuration. To specify how the device should handle configuration changes, see Set the Edit Configuration Mode in a NETCONF Session.Roll back changes to the current configuration—Use the
<discard-changes>
operation to roll back the candidate configuration to match the contents of the current running (active) configuration. This operation is analogous to therollback 0
configuration mode command in the CLI.Note:The
<discard-changes/>
tag element cannot be used to discard uncommitted changes that have been loaded into the ephemeral configuration database.