Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Deleting Elements in Configuration Data Using the Junos XML Protocol

In a Junos XML protocol session with a device running Junos OS, to delete configuration elements (hierarchy levels or configuration objects) from the candidate configuration or open configuration database, a client application emits the basic tag elements described in Creating, Modifying, or Deleting Configuration Elements Using the Junos XML Protocol. When using Junos XML tag elements to represent the elements to delete, the client application includes the delete="delete" attribute in the opening tag for each element. When using formatted ASCII text, the client application precedes each element to delete with the delete: operator. When using configuration mode commands to delete elements, the client application uses the delete command and specifies the path to the element. When using JSON data to delete an element, the client application includes the "operation" : "delete" attribute in the attribute list for that element. The placement of the attribute or operator depends on the type of element being deleted, as described in the following sections:

Note:

You can load configuration data formatted using JavaScript Object Notation (JSON) starting in Junos OS Release 16.1.

Deleting a Hierarchy Level or Container Object

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

When using Junos XML tag elements, the application includes the delete="delete" attribute in the empty tag that represents the level or container object:

When using formatted ASCII text, the application places the delete: statement above the level to be removed, which is followed by a semicolon (even though in the existing configuration it is followed by curly braces that enclose its child statements):

When using configuration mode commands, the application specifies the delete command and the statement path to the hierarchy level or object to be removed.

When using JSON configuration data to delete a hierarchy level or container object, the application includes the "operation" : "delete" attribute in the attribute list for the hierarchy or container object:

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

The following example shows how to remove the [edit protocols ospf] hierarchy level from the candidate configuration using configuration data formatted in JSON:

Deleting a Configuration Object That Has an Identifier

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

When using Junos XML tag elements, the application includes the delete="delete" attribute in the opening tag for the object. In the container tag element for the object, it encloses only the identifier tag element, not tag elements that represent any other characteristics of the object. In the following, the identifier tag element is called <name>:

Note:

The delete attribute appears in the opening container tag, not in the identifier tag element. 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.

When using formatted ASCII text, the application places the delete: statement above the object and its identifier:

When using configuration mode commands, the application specifies the delete command, the statement path to the object, and the object and its identifier.

When using JSON configuration data, the 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 JSON member that specifies the element’s identifier has the field name "name":

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-formatted configuration data to remove the user object barbara from the [edit system login user] hierarchy level in the candidate configuration.

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

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

When using Junos XML tag elements, the application includes the delete="delete" attribute in the empty tag for each option. It does not include tag elements for children that are to remain in the configuration. In the following, the identifier tag element for the object is called <name>:

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. You can specify the full path to the option statement or 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 attribute list for that option. 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 JSON member that specifies the element’s identifier has the field name "name":

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

Deleting Values from a Multivalue Option of a Configuration Object

As described in Mapping Configuration Statements to Junos XML Tag Elements, 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 tag element for each value. In the following, the identifier tag element is called <name>:

To remove one or more values for such an object, a client application includes the basic tag elements or configuration statements for its parent levels, as described in Creating, Modifying, or Deleting Configuration Elements Using the Junos XML Protocol. When using Junos XML tag elements, the application includes the delete="delete" attribute in the opening tag for each value. It does not include tag elements that represent values to be retained. In the following, the identifier tag element for the parent object is called <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. You can specify the full path to the value or navigate to the hierarchy level of the object and delete the value from that location. Use a separate command to delete each value.

The JSON representation for an object with 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 desired set of values.

The following example shows how to remove two of the permissions granted to the user-accounts login class using Junos XML tag elements.