Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Announcement: Try the Ask AI chatbot for answers to your technical questions about Juniper products and solutions.

close
external-header-nav
keyboard_arrow_up
close
keyboard_arrow_left
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

Create New Elements in Configuration Data Using the Junos XML Protocol

date_range 14-Jul-21

In a Junos XML protocol session with a device running Junos OS, to create new configuration elements (hierarchy levels or configuration objects), a client application includes the basic tag elements, formatted ASCII statements, configuration mode commands, or JSON objects described in Creating, Modifying, or Deleting Configuration Elements Using the Junos XML Protocol.

For Junos XML tag elements and formatted ASCII text, new elements can be created in either merge mode or replace mode, which are described in Merging Elements in Configuration Data Using the Junos XML Protocol and Replacing Elements in Configuration Data Using the Junos XML Protocol. In replace mode, the application includes the action="replace" attribute in the <load-configuration/> tag or opening <load-configuration> tag.

To use Junos XML tag elements to represent the element, the application includes each of the element’s identifier tag elements (if it has them) and all child tag elements being defined for the element. In the following, the identifier tag element is called <name>. The application does not need to include any attributes in the opening container tag for the new element:

content_copy zoom_out_map
<configuration>
    <!-- opening tag for each parent of the element -->
        <container-tag> 
            <name>identifier</name> 
                <!-- tag elements for other children, if any -->
         </container-tag> 
    <!-- closing tag for each parent of the element -->
</configuration>

To use formatted ASCII text to represent the element, the application includes each of the element’s identifiers (if it has them) and all child statements (with values if appropriate) that it is defining for the element. It does not need to include an operator before the new element:

content_copy zoom_out_map
<configuration-text>
    /* statements for parent levels of the element */
        element identifier {
            /* child statements if any */
        } 
    /* closing braces for parent levels of the element */
</configuration-text>

To use configuration mode commands to create new elements, the application includes the action="set" and format="text" attributes in the <load-configuration> tag. The application includes the set command as it would be executed in the CLI. The command includes the statement path to the element, the element’s identifier if it has one, and all child statements (with values if appropriate) that it is defining for the element.

content_copy zoom_out_map
<configuration-set>
    set statement-path-to-element element identifier child-elements 
</configuration-set>

Starting in Junos OS Release 16.1, you can load configuration data formatted using JavaScript Object Notation (JSON) on the device. When loading configuration data in JSON format, you can create new elements in merge mode only. To represent the element in JSON, the application includes each element’s identifier (if it has one) and all data and child objects being defined for the element. The application does not need to include any specific operation attributes in order to create the new element. In the following example, the JSON member that specifies the element’s identifier has the field name "name":

content_copy zoom_out_map
<configuration-json>
{
    "configuration" : {
        /* JSON objects for parent levels of the element */
            "container-tag" : {
                "object" : [
                {
                    "name" : "identifier",
                    /* data and child objects */  # if any
                }
                ],
                /* data and child objects */  # if any
            }
        /* closing braces for parent levels of the element */
    }
}
</configuration-json>
external-footer-nav