Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 

emit-change Template (SLAX and XSLT) and emit_change (Python)

 

Syntax

Python Syntax

SLAX Syntax

XSLT Syntax

Description

Generate a persistent or transient change to the configuration.

Parameters

contentContent of the persistent or transient change. In SLAX and XSLT scripts, this is relative to dot. Python scripts must include the full configuration path representing all levels of the configuration hierarchy formatted as an XML string.
dotXPath expression specifying the hierarchy level at which the change will be made. The default location is the position in the XML hierarchy that the script is currently evaluating. You can alter the default when you call the template by including a valid XPath expression either for the dot parameter in SLAX scripts or for the select attribute of the dot parameter in XSLT scripts.
formatFormat of the configuration data loaded through a Python commit script. The only supported format is xml.
messageWarning message displayed in the CLI notifying the user that the configuration has been changed. The message parameter automatically includes the edit path, which defaults to the current location in the XML hierarchy. To change the default edit path, specify a valid XPath expression either for the dot parameter in SLAX scripts or for the select attribute of the dot parameter in XSLT scripts.
nameAllows you to refer to the current element or attribute. The name() XPath function returns the name of an element or attribute. The name parameter defaults to the value name($dot), which is the name of the element in dot (which in turn defaults to “ . ”, which is the current element).
tagType of change to generate. Specify 'change' to generate a persistent change, or specify 'transient-change' to generate a transient change. If you omit this parameter in SLAX and XSLT scripts, the jcs:emit-change template defaults to generating a persistent change.

Usage Examples

The following example demonstrates how to call the jcs:emit-change template in an XSLT commit script:

When you commit a configuration that includes one or more interfaces that have IS-IS enabled but do not have the family mpls statement included at the [edit interfaces interface-name unit logical-unit-number] hierarchy level, the jcs:emit-change template adds the family mpls statement to the configuration and generates the following CLI output:

user@host# commit

The content parameter of the jcs:emit-change template provides a simpler method for specifying a change to the configuration. For example, consider the following code:

In SLAX and XSLT scripts, the jcs:emit-change template converts the content parameter into a <change> request. The <change> request inserts the provided partial configuration content into the complete hierarchy of the current context node. Thus, the jcs:emit-change template changes the hierarchy information in the content parameter into the following code:

If a transient change is required, the tag parameter can be passed in as 'transient-change', as shown here:

The extra quotation marks are required to allow XSLT to distinguish between the string "transient-change" and the contents of a node named "transient-change". If the change is relative to a node other than the context node, the parameter dotcan be set to that node, as shown in the following example, where context is set to the [edit chassis] hierarchy level:

The following Python commit script generates a persistent change to the configuration: