CLI Transport Provider

 

WebNMS CLI API is protocol neutral, and it is designed in such a way that the protocol details are hidden from the core API. In the higher layer, CLI messages can be transported over any protocol to communicate with the device. WebNMS CLI API provides Telnet over TCP/IP and Serial (RS232) as default protocol implementations.

 

Transport Provider acts as a bridge between the core API and the transport protocol implementation. The CLI API interacts with the framework unaware of the details of the protocol and uses the implementation of the protocol that is registered with the Transport Provider. Hence, it is possible to plug in other protocol implementations such as IPX, UDP, and others.

 

CLI Transport provider consists of the following interfaces:

CLITransportProvider

 

The CLITransportProvider interface provides the methods for performing the basic Input-Output (I/O) operations, which are necessary for any transport protocol. It contains the following API methods.

 

Method Purpose

void open(CLIProtocolOptions cliProtocolOptions)

 

This method can be used to open a transport interface based on the type of protocol option.

CLIMessage read()

This method can be used to receive CLI response from the device over the transport interface.

void write(CLIMessage cliMsg)

This method can be used to send data to the device over the transport interface.

void close()

This method can be used to close the transport interface after communication is over.

 

CLIProtocolOptions

 

The CLIProtocolOptions interface defines protocol specific options that have to be implemented depending on the protocol being used to communicate with the CLI device. A reference implementations for Telnet, SSH and Serial port are provided. The implementation of the interface can be passed as an argument to the CLISession constructor as follows.

 

CLISession session =

new CLISession(CLIProtocolOptionsImpl,enablePooling);

 

Here session is an instance of CLISession and CLIProtcolOptionsImpl is an instance of the class that implements this interface. The enablePooling is a boolean to indicate whether the session is dedicated or non-dedicated.

 

The CLIProtocolOptions can also be set on the session before calling the open method in the CLISession.
 

session.setCLIProtocolOptions(CLIProtocolOptionsImpl);

 

For example, the Telnet implementation for the CLIProtocolOptions has the target host, port, and login parameters as the option. Similarly, the custom protocol implementation requires the necessary parameters or options present in the implementation.

 

How to plug in a protocol implementation

  1. Provide implementation of CLITransportProvider for the protocol (for example, TelnetTransportImpl) - This class should provide the implementation for open(), close(), read(), and write() methods. These methods will be used by the CLISession to establish communication and transfer data between the CLI application and device.

  2. Provide implementation of CLIProtocolOptions - This class should provide the necessary parameters needed for the protocol communication. Example: host, port, login parameters, etc, in case of Telnet. This is used by the CLI API to uniquely identify each connection between the CLI application and device.

  3. The configuration file, cliTransport.conf, that is available in <CLI Home>/conf directory should contain the name of the implemented CLITransportProvider class file.

 

Note: In the application, the following should be taken care of while using the CLI Transport Provider.

  • After creating the session object, use session.setTransportProviderClassName(String className). Here className is used to specify the protocol for communication. Telnet is provided as a default protocol.

  • Create a ProtocolOptions object with necessary parameters. Set this on the session object using session.setCLIProtocolOptions(ProtocolOptions param) method. For Telnet, this will be the TelnetProtocolOptionsImpl.

  • It is mandatory for the CLIProtocolOptions to be first set on the CLISession object before opening the session (session.open()).

 

Please refer to Java documentation for complete details.

Related Topics

 

 



Copyright © 2009 ZOHO Corp. All Rights Reserved.