|
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:
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. |
|
This method can be used to receive CLI response from the device over the transport interface. | |
|
This method can be used to send data to the device over the transport interface. | |
|
This method can be used to close the transport interface after communication is over. |
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
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.
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.
The configuration file, cliTransport.conf, that is available in <CLI Home>/conf directory should contain the name of the implemented CLITransportProvider class file.
For Telnet - Specify
the class name as:
com.adventnet.cli.transport.TelnetTransportImpl
For Serial Port - Specify the class name as: com.adventnet.cli.serial.SerialCommProviderImpl
|
|
Note: In the application, the following should be taken care of while using the CLI Transport Provider.
|
Please refer to Java documentation for complete details.
|