Config API

 

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.

 

 

ConfigAPI

 

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.

 

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.

 

ConfigObject

 

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);

 

LoginLevel

 

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.

 

Task

 

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:

Task task = new Task();

task.setTaskType(Task.COMMAND);

task.setTaskName("task2");

task.setCommand("pwd");

task.setDataRequired(false);

 

TaskData

 

The 'TaskData' is used for sending data for a task. It models the data required by a command or script.

 

Interfaces

 

ExecutionInterface

 

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.

 

DataInterface

 

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.

 

LoginInterface

 

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.

 



Copyright © 2009 ZOHO Corp. All Rights Reserved.