execute() Function (SLAX and XSLT)
Namespaces
http://xml.juniper.net/junos/commit-scripts/1.0
SLAX Syntax
var $result = jcs:execute(connection, rpc);
XSLT Syntax
<xsl:variable name="result" select="jcs:execute(connection, rpc)"/>
Description
Execute a remote procedure call (RPC) within the context of a specific management session in SLAX
and XSLT automation scripts. Any number of RPCs may be executed within
the same session until the session is closed with the jcs:close()
function. This is in contrast to the jcs:invoke()
function, which also performs RPC calls,
but uses a unique session per command.
Python automation scripts can use Junos PyEZ APIs to execute RPCs on a local or remote device.
Parameters
connection |
Connection handle generated by a call
to the |
rpc |
Remote procedure call (RPC) to execute. |
Return Value
result |
Results of the executed RPC, which include the contents
of the |
Usage Examples
In the following example, the $rpc
variable is declared and initialized with the Junos XML <get-interface-information>
element. A call to the jcs:open()
function generates a connection handle to
the remote device at IP address 198.51.100.1. The user’s login
and password are provided as arguments to jcs:open()
to provide access to the remote device. The code calls jcs:execute()
and passes in the connection handle and
RPC as arguments. Junos OS on the remote device processes the RPC
and returns the results, which are stored in the $results
variable.
var $rpc = <get-interface-information>; var $connection = jcs:open('198.51.100.1', 'bsmith', 'test123'); var $results = jcs:execute($connection, $rpc); expr $results; expr jcs:close($connection);
The equivalent XSLT code is:
<xsl:variable name="connection" select="jcs:open('198.51.100.1', 'bsmith', 'test123')"/> <xsl:variable name="rpc"> <get-interface-information/> </xsl:variable> <xsl:variable name="results" select="jcs:execute($connection, $rpc)"/> <xsl:value-of select="$results"/> <xsl:value-of select="jcs:close($connection)"/>
Release Information
Function introduced in Junos OS Release 9.3.