Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    Replacing the Candidate Configuration Using NETCONF

    In a NETCONF session with a device running Junos OS, you can replace the candidate configuration with a new configuration file using either the <copy-config> tag or the <edit-config> tag with the <default-operation> subtag value set to replace.

    Using <copy-config> to Replace the Candidate Configuration

    One method for replacing the entire candidate configuration is to include the <copy-config> tag element in the <rpc> element. The <target> tag encloses the <candidate/> tag to indicate that the new configuration data replaces the candidate configuration. The <source> tag element encloses the <url> tag element, which specifies the filename that contains the new configuration data. When the configuration data is formatted as Junos XML tag elements, set the <url> format attribute to xml or omit the attribute. When the configuration data is formatted as CLI configuration statements, set the <url> format attribute to text.

    <rpc>
        <copy-config>
            <target>
                <candidate/>
            </target>
            <source>
                <url format="(xml | text)">
                    <!-- location specifier for file containing the new configuration -->
                </url>
            </source>
        </copy-config>
    </rpc>
    ]]>]]>

    Using <edit-config> to Replace the Candidate Configuration

    The other method for replacing the entire candidate configuration is to set the edit configuration mode to replace as a global variable. The candidate configuration includes the <default-operation> tag element with the value replace in the <edit-config> tag element, as described in Setting the Edit Configuration Mode in a NETCONF Session. To specify the new configuration data, the application includes a <config> or <config-text> tag element that contains the data or a <url> tag element that names the file containing the data, as discussed in Uploading and Formatting Configuration Data in a NETCONF Session.

    <rpc>
        <edit-config>
            <target>
                    <candidate/>
            </target>
            <default-operation>replace</default-operation>

        <!-- EITHER -->
            <config>
                <configuration>
                    <!-- tag elements representing the configuration elements to change -->
                </configuration>
            </config>
        <!-- OR -->
            <config-text>
                <configuration-text>
                    <!-- tag elements representing the configuration elements to change -->
                </configuration-text>
            </config-text>
        <!-- OR -->
            <url>
                <!-- location specifier for file containing changes -->
            </url>

        </edit-config>
    </rpc>
    ]]>]]>

    Published: 2013-07-26