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
header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
Automation Scripting User Guide
Table of Contents Expand all
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

invoke() Function (SLAX and XSLT)

date_range 01-Feb-21

Namespaces

content_copy zoom_out_map
http://xml.juniper.net/junos/commit-scripts/1.0

SLAX Syntax

content_copy zoom_out_map
var $result = jcs:invoke(rpc, "no-login-logout");

XSLT Syntax

content_copy zoom_out_map
<xsl:variable name="result" select="jcs:invoke(rpc)"/>

Description

Invoke a remote procedure call (RPC) on the local device. The function requires one argument, either a string containing a Junos XML API RPC, or a tree containing an RPC. The result contains the contents of the <rpc-reply> element, not including the <rpc-reply> tag. An RPC allows you to perform functions equivalent to Junos OS operational mode commands.

Note:

Python automation scripts can use Junos PyEZ APIs to execute RPCs on a local or remote device.

Parameters

rpc

String containing a Junos XML API RPC or a tree containing an RPC.

no-login-logout

(Optional) In SLAX commit and event scripts, suppress UI_LOGIN_EVENT and UI_LOGOUT_EVENT messages in system log files when the script logs in as root to execute the RPC.

Return Value

result

Results of the executed RPC, which include the contents of the <rpc-reply> element, but not the <rpc-reply> tag itself. By default, the results are in XML format equivalent to the output produced with the | display xml option in the CLI.

Usage Examples

The following example tests to see if the interface argument is included on the command line when the script is executed. If the argument is provided, the output of the show interfaces terse operational mode command is narrowed to include only information about the specified interface.

content_copy zoom_out_map
<xsl:param name="interface"/>
<xsl:variable name="rpc">
    <get-interface-information>
        <terse/>
        <xsl:if test="$interface">
            <interface-name>
                <xsl:value-of select="$interface"/>
            </interface-name>
        </xsl:if>
    </get-interface-information>
</xsl:variable>
<xsl:variable name="out" select="jcs:invoke($rpc)"/>

In this example, the jcs:invoke() function calls the Junos XML API RPC get-software-information, and stores the unmodified output in the variable sw:

content_copy zoom_out_map
<xsl:variable name="sw" select="jcs:invoke('get-software-information')"/>

Release Information

Function introduced in Junos OS Release 7.6.

no-login-logout parameter added in Junos OS Release 21.1R1 for commit and event scripts.

footer-navigation