Supported Platforms
Related Documentation
- EX, M, MX, QFX, SRX, T Series
- Using Device Object Methods to Execute RPCs and Operational Commands
- Creating and Executing a NETCONF Java Toolkit Program File
- Troubleshooting Exception Errors in a NETCONF Java Toolkit Program
- NETCONF Java Toolkit Class: NetconfSession
- NETCONF Java Toolkit Class: XML
- NETCONF Java Toolkit Class: XMLBuilder
- NETCONF Java Toolkit Overview
NETCONF Java Toolkit Class: Device
A net.juniper.netconf.Device object represents an SSHv2 connection and a default NETCONF session between the configuration management server and the device on which the NETCONF server resides.
When creating a Device object, you must provide the IP address or DNS name and the authentication details to create the SSHv2 connection. Authentication can be user-password based or RSA/DSA key-based. You also have the option of specifying the port number for the SSHv2 connection and the client capabilities to be sent to the NETCONF server.
The constructor syntax is:
Device (String hostname, String login, String password, String pemKeyFile)
Device (String hostname, String login, String password, String pemKeyFile, int port)
Device (String hostname, String login, String password, String pemKeyFile,
ArrayList capabilities)
Device (String hostname, String login, String password, String pemKeyFile, int port,
ArrayList capabilities)
The constructor parameters are:
- hostname—(Required) IP address or DNS name of the device on which the NETCONF server is running and to which to connect via SSHv2.
- login—(Required) Username for the login account on the device on which the NETCONF server is running.
- password—(Required) Password for either user password-based authentication or key-based authentication. If no password is required for key-based authentication, pass this argument as null.
- pemKeyFile—(Required) Path of the file containing the DSA/RSA private key in PEM format for key-based authentication. For user password-based authentication, pass this argument as null.
- port—(Optional) Port number on which to establish the SSHv2 connection. The default port is 830. If you are connecting to a device that is configured for NETCONF over SSH on a port other than the default port, you must specify that port number in the arguments.
- capabilities—(Optional)
Client capabilities to be communicated to the NETCONF server, if the
capabilities are other than the default capabilities.
The default capabilities sent to the NETCONF server are:
urn:ietf:params:xml:ns:netconf:base:1.0 urn:ietf:params:xml:ns:netconf:base:1.0#candidate urn:ietf:params:xml:ns:netconf:base:1.0#confirmed-commit urn:ietf:params:xml:ns:netconf:base:1.0#validate urn:ietf:params:xml:ns:netconf:base:1.0#url?protocol=http,ftp,file
The general syntax for creating a Device object is:
Device device_name = new Device (String hostname, String login, String password, String pemKeyFile, <int port>, <ArrayList capabilities>)
By default, a NetconfSession object is created when you create a new instance of Device and connect to a NETCONF server. Once you have created a Device object, you can perform NETCONF operations.
Examples
The following example creates a Device object with an authenticated SSHv2 connection to IP address 10.10.1.1. The connection uses user password-based authentication with the login name “admin” and the password “PaSsWoRd”. When the connect() method is called, it connects to the device and automatically establishes a default NETCONF session.
Device my_device = new Device("10.10.1.1", "admin", "PaSsWoRd", null); my_device.connect();
To create a Device object with a NETCONF-over-SSH connection on port 49000 instead of the default port 830, add the port number to the constructor arguments.
Device my_device = new Device("10.10.1.1", "admin", "PaSsWoRd", null, 49000);
The default timeout value for connecting to the device is 5000 milliseconds. To set the timeout value to a different interval, call the setTimeOut() method on the device object.
Related Documentation
- EX, M, MX, QFX, SRX, T Series
- Using Device Object Methods to Execute RPCs and Operational Commands
- Creating and Executing a NETCONF Java Toolkit Program File
- Troubleshooting Exception Errors in a NETCONF Java Toolkit Program
- NETCONF Java Toolkit Class: NetconfSession
- NETCONF Java Toolkit Class: XML
- NETCONF Java Toolkit Class: XMLBuilder
- NETCONF Java Toolkit Overview
Published: 2012-11-05
Supported Platforms
Related Documentation
- EX, M, MX, QFX, SRX, T Series
- Using Device Object Methods to Execute RPCs and Operational Commands
- Creating and Executing a NETCONF Java Toolkit Program File
- Troubleshooting Exception Errors in a NETCONF Java Toolkit Program
- NETCONF Java Toolkit Class: NetconfSession
- NETCONF Java Toolkit Class: XML
- NETCONF Java Toolkit Class: XMLBuilder
- NETCONF Java Toolkit Overview