Supported Platforms
Related Documentation
- ACX, EX, M, MX, PTX, SRX, T Series
- Summary of Extension Functions in the jcs and slax Namespaces
- close() Function (jcs Namespace)
- execute() Function (jcs Namespace)
- ACX, EX, M, MX, SRX, T Series
- Junos Script Automation: Understanding Extension Functions in the jcs and slax Namespaces
- get-hello() Function (jcs Namespace)
- get-protocol() Function (jcs Namespace)
- ACX, EX, M, MX, QFX, SRX, T Series
- Specifying the Session Protocol for Connections Using Junos Automation Scripts
open() Function (jcs Namespace)
Namespaces
SLAX Syntax
XSLT Syntax
Release Information
Function introduced in Junos OS Release 9.3.
Support for NETCONF sessions added in Junos OS Release 11.4R1.
Support for routing instances added in Junos OS Release 12.2R1.
Description
Return a connection handle that can be used to execute remote procedure calls (RPCs) using the jcs:execute() extension function. To execute an RPC on a remote device, an SSH session must be established. In order for the script to establish the connection, you must either configure the SSH host key information for the remote device on the local device where the script will be executed, or the SSH host key information for the remote device must exist in the known hosts file of the user executing the script.
To redirect the SSH connection to originate from within a specific routing instance, include the routing instance name in the connection parameters. The routing instance must be configured at the [edit routing-instances] hierarchy level, and the remote device must be reachable either using the routing table for that routing instance or from one of the interfaces configured under that routing instance.
Starting with Junos OS Release 11.4, the new parameter, session-options, supports the option to create a session either with the Junos XML protocol server on devices running Junos OS or with the NETCONF server on devices where NETCONF service over SSH is enabled. Previously, the function supported only sessions with the Junos XML protocol server on devices running Junos OS.
The connection handle is closed with the jcs:close() function.
Parameters
passphrase | — | (Optional) User’s login passphrase. If you do not specify a passphrase and it is required for authentication, you should be prompted for one during script execution by the device to which you are connecting. |
remote-hostname | — | Domain name or IP address of the remote router, switch, or security device. If you are opening a local connection, do not pass this value. If you specify a session type, this parameter is required. |
routing-instance-name | — | (Optional) Routing instance from within which the SSH connection originates. |
session-options | — | (Optional) XML node set that specifies the session protocol and connection parameters. The structure of the node set is: var $session-options := { <instance> "routing-instance-name"; <method> ("junoscript" | "netconf" | "junos-netconf"); <passphrase> "passphrase"; <password> "password"; <port> "port-number"; <routing-instance> "routing-instance-name"; <username> "username"; }
|
username | — | (Optional) User’s login name. If you do not specify a username and it is required for the connection, the script uses the local name of the user executing the script. |
Return Value
connection | — | Connection handle to the remote host. |
Usage Examples
The following example shows how to connect to a local device:
var $connection = jcs:open();
The following example shows how to connect to a remote device:
var $connection = jcs:open(remote-hostname);
The following example shows how the user, bsmith, with the passphrase “test123” obtains a connection handle to the remote device, fivestar:
var $connection = jcs:open("fivestar", "bsmith", "test123");
The following example shows how the user, bsmith, with the passphrase “test123” creates a junos-netconf session with a device running Junos OS:
var $options := { <method> "junos-netconf"; <username> "bsmith"; <passphrase> "test123"; } var $connection = jcs:open("fivestar", $options);
Related Documentation
- ACX, EX, M, MX, PTX, SRX, T Series
- Summary of Extension Functions in the jcs and slax Namespaces
- close() Function (jcs Namespace)
- execute() Function (jcs Namespace)
- ACX, EX, M, MX, SRX, T Series
- Junos Script Automation: Understanding Extension Functions in the jcs and slax Namespaces
- get-hello() Function (jcs Namespace)
- get-protocol() Function (jcs Namespace)
- ACX, EX, M, MX, QFX, SRX, T Series
- Specifying the Session Protocol for Connections Using Junos Automation Scripts
Published: 2013-07-26
Supported Platforms
Related Documentation
- ACX, EX, M, MX, PTX, SRX, T Series
- Summary of Extension Functions in the jcs and slax Namespaces
- close() Function (jcs Namespace)
- execute() Function (jcs Namespace)
- ACX, EX, M, MX, SRX, T Series
- Junos Script Automation: Understanding Extension Functions in the jcs and slax Namespaces
- get-hello() Function (jcs Namespace)
- get-protocol() Function (jcs Namespace)
- ACX, EX, M, MX, QFX, SRX, T Series
- Specifying the Session Protocol for Connections Using Junos Automation Scripts