Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Delete Elements in Configuration Data Using the Junos XML Protocol

Junos XML protocol client applications can delete configuration elements from the selected configuration database on Junos devices.

Junos XML protocol client applications can delete configuration elements (hierarchy levels or configuration objects) from the candidate configuration or open configuration database on devices running Junos OS or devices running Junos OS Evolved. To delete elements, a client application first emits the basic tag elements described in Create, Modify, or Delete Configuration Elements Using the Junos XML Protocol. A client application then includes the appropriate attribute or operator for the chosen format.

Table 1 summarizes how a client application deletes configuration objects using the different data formats. The placement of the attribute or operator depends on the type of element to delete.

Table 1: Delete Configuration Objects
Format Method to Delete Object

Junos XML

Include the delete="delete" attribute in the opening tag for each element to delete.

Formatted ASCII text

Include the delete: operator on the line that just precedes the statement to delete.

Configuration mode commands

Use the delete command and specify the path to the element.

JSON

Include the "operation" : "delete" attribute in the attribute list for each object to delete.

To provide the configuration data as a data stream, enclose formatted ASCII text, configuration mode commands, or JSON data in a <configuration-text>, <configuration-set>, or <configuration-json> element, respectively. To load the data from a file, you do not need to include any additional elements.

Delete a Hierarchy Level or Container Object

A client application can delete a hierarchy level and all of its children (or a container object that has children but no identifier). To delete a hierarchy level, a client application first includes the basic tag elements or configuration statements for its parent levels, as described in Create, Modify, or Delete Configuration Elements Using the Junos XML Protocol.

To use Junos XML elements to delete a hierarchy level, an application includes the delete="delete" attribute in the empty tag that represents the hierarchy level or container object.

To use formatted ASCII text, an application places the delete: statement on the line that precedes the hierarchy level to remove. The application also places a semicolon after the level to remove (even though the existing configuration uses curly braces that enclose its child statements).

To use configuration mode commands, an application specifies the delete command and the statement path to the hierarchy level or object to remove.

To use JSON configuration data, an application includes the "operation" : "delete" attribute in the attribute list for the hierarchy or container object to remove.

The following example removes the [edit protocols ospf] hierarchy level from the candidate configuration using Junos XML tag elements:

The following example removes the [edit protocols ospf] hierarchy level from the candidate configuration using JSON configuration data. The request provides the configuration data as a data stream, so the application encloses the data in a <configuration-json> element.

Delete a Configuration Object That Has an Identifier

To delete a configuration object that has an identifier, a client application first includes the basic tag elements or configuration statements for its parent levels, as described in Create, Modify, or Delete Configuration Elements Using the Junos XML Protocol.

To Junos XML elements to delete the object, an application includes the delete="delete" attribute in the opening tag for the object to remove. In the object's container element, the application encloses only the identifier element, not the elements that represent any other characteristics of the object. In the following example, the <name> element is the object's identifier:

Note:

The delete attribute appears in the opening container tag, not in the identifier tag. The presence of the identifier tag element results in the removal of the specified object, not in the removal of the entire hierarchy level represented by the container tag element.

To use formatted ASCII text to delete the object, an application places the delete: statement on the line that precedes the object and its identifier.

To use configuration mode commands, an application specifies the delete command, the statement path to the object, and the object and its identifier.

To use JSON configuration data, an application includes the "operation" : "delete" attribute in the attribute list for the object. In the container object, it encloses only the name/value pair representing the identifier. In the following example, the "name" field identifies the object to remove:

The following example uses Junos XML tag elements to remove the user object barbara from the [edit system login user] hierarchy level in the candidate configuration.

The following example uses JSON configuration data to remove the user object barbara from the [edit system login user] hierarchy level in the candidate configuration. The request provides the configuration data as a data stream, so the application encloses the data in a <configuration-json> element.

Delete a Single-Value or Fixed-Form Option from a Configuration Object

A client application can delete either a fixed-form option or an option that takes just one value from a configuration object. The client application first includes the basic tag elements or configuration statements for its parent levels, as described in Create, Modify, or Delete Configuration Elements Using the Junos XML Protocol. For information about deleting an option that can take multiple values, see Delete Values from a Multivalue Option of a Configuration Object.

To use Junos XML tag elements to delete the option, an application includes the delete="delete" attribute in the empty tag for that option. The application does not include tag elements for children that should remain in the configuration. In the following example, the <name> element is the object's identifier:

When using formatted ASCII text, the application places the delete: statement above each option:

When using configuration mode commands, the application specifies the delete command, the statement path to the option, and the option to be removed. The commands can specify the full path to the option statement. Alternatively, the commands can navigate to the hierarchy level of the object and delete the option statement from that location. Use a separate command to delete each option.

When using JSON configuration data to delete an option, the application includes the "operation" : "delete" attribute in the option's attribute list. To delete options for a hierarchy level or container object, specify the options to delete at that level.

To delete options for an object that has an identifier, include the identifier first, and then specify the options to delete. In the following example, the element’s identifier has the field name "name":

The following example removes the fixed-form option disable at the [edit forwarding-options sampling] hierarchy level using Junos XML tag elements.

Delete Values from a Multivalue Option of a Configuration Object

Some Junos OS configuration objects are leaf statements that have multiple values. In the formatted ASCII CLI representation, the values are enclosed in square brackets following the name of the object:

The Junos XML representation does not use a parent tag for the object, but instead uses a separate instance of the object element for each value. In the following example, the <name> element is the identifier:

For example, consider the permissions of a login class, which are displayed as a list in brackets.

Junos XML format lists each permission in a separate <permissions> element.

To remove one or more values for such an object, a client application first includes the basic tag elements or configuration statements for its parent levels, as described in Create, Modify, or Delete Configuration Elements Using the Junos XML Protocol.

When using Junos XML elements to remove a value, the application includes the delete="delete" attribute in the opening tag for each value. It does not include elements that represent values to be retained. In the following example, the parent object's identifier is <name>:

When using formatted ASCII text, the application repeats the parent statement for each value and places the delete: statement above each paired statement and value:

When using configuration mode commands, the application specifies the delete command, the statement path to each value, and the value to be removed. The commands can specify the full path to the value. Alternatively, the commands can navigate to the hierarchy level of the object and delete the value from that location. Use a separate command to delete each value.

In JSON, a multivalue option is a name/value pair where the field name is the object name, and its value, which represents the options, is an array of strings. Junos OS does not support using JSON to delete single values from an object with a multivalue option. To update the option list, you must delete the existing object and then configure a new object with the required set of values.

The following example uses Junos XML elements to remove two of the permissions granted to the user-accounts login class.