|
WebNMS CLI API provides ConfigAPI package for developing applications to configure network devices such as routers, switches, hubs, and others. The ConfigAPI is a utility package that uses the core CLI APIs for communication with devices. The following architecture diagram explains the relationship between various classes in Config API.

The device configuration consists of sending set of tasks, i.e., commands. The tasks are grouped in the TaskList, which is an XML file loaded into the application. The tasks are grouped according to a specific type of configuration, i.e., interface configuration, general configuration, and others.
ConfigAPI provides the methods to perform following configuration tasks.
Add/Delete/Modify tasks
Executing the tasks either in the form of commands or scripts
Add/Delete configuration
Open/Close connection with device
Set the login level
The runConfiguration
method executes the configuration. It takes data from
the DataInterface or the arguments passed to the configuration. It proceeds
further to run the configuration only if the data is available for the
whole configuration. The data availability is decided based on the mandatory
and data required properties of the task.
| Mandatory | Data Required | Action |
|---|---|---|
|
F |
F |
Executes the task with cmd/script. |
|
F |
T |
If no data, skips the task. Otherwise executes the task. |
|
T |
F |
Executes the task with the cmd/script. |
|
T |
T |
If no data, throws exception. Otherwise executes the task. |
Each configuration task can be executed at a particular login level. If the login level for a task conflicts, this method switches to the particular login level of the task before executing the task. It exits from the login level after executing a particular task.
This class is used to set/get config ID, login level, task list, and data interface.
|
ConfigObject confOb = new ConfigObject(); confOb.setConfigID("<config name>"); confOb.setLoginLevel("level1"); confOb.setTaskList(taskList); |
This class represents the login mode in which the commands can be executed, as some devices require authentication to switch over to configuration mode. The login level for executing a task can be set according to the device specifications.
The WebNMSConfiguration Application developed using ConfigAPI can be used to configure CISCO devices running on CISCO-IOS. These devices can be configured only in privilege mode, whereas in user mode commands can be sent to view only a few device settings. Following login options are available in LoginLevel class.
Set the login level
Login prompt
Login name
Login command
Password prompt
Login password
Command prompt
Sublevels
Exit command
Task can be either a command or a script that can be sent to configure a device. The default type of task is command. Task includes the following:
Name of the task: The command name.
Command for the task: The actual command that has to be sent to configure the device.
Login level to execute the task: There will be different login levels to execute a particular task.
Mandatory: A value of true can be assigned, if the task is to be compulsorily executed. If it is false, the task will be skipped when no values for the parameters are given during its execution.
Data required: It should be true, if the command in the task has parameters, for which values are to be given during execution otherwise it is false.
Description of the task
|
Task task = new Task(); task.setTaskType(Task.COMMAND); task.setTaskName("task2"); task.setCommand("pwd"); task.setDataRequired(false); |
The 'TaskData' is used for sending data for a task. It models the data required by a command or script.
Interfaces
This interface is implemented to execute configuration that has a set of tasks. You can specify the configuration in the TaskList.xml file available in <CLI Home>/conf directory. Following methods are used to perform operations with a particular configuration.
executeCommand: To execute the tasks that are in the form of commands.
executeScript: To execute the tasks that are in the form of scripts. To run the scripts, you have to specify the scripting language, which is implemented using the Script Handler APIs.
setloginLevel: To set the login level that is used to log into a remote device. This is also used for switching over from a login level to one of its sublevels and vice versa. The login parameters and login command are used for changing the login level.
login: To log in into a remote host with the CLIProtocolOptions.
This interface is implemented to send data to the device during execution of configuration. Use getConfigData method when data is not given to it. The data for all the tasks in the given configuration will be returned from this method. getConfigCmdData method can be used to get the data for a command in a configuration. getConfigScriptData can be used to get data for running a script in a configuration.
This interface is implemented to get the login name and password for a particular login level. In case the login name and password is not to be exhibited in the TaskList, for a particular mode of configuration, use getLoginName and getLoginPassword methods to return the login name and password.
Please refer to Java documentation for complete details.
|