|
WebNMS 5 API Specification | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.adventnet.management.Property
|
+--com.adventnet.management.cli.CLIProperty
This is the implementation of com.adventnet.management.Property for CLI protocol. It encapsulates the Information about the device like, name of the device, port no to contact the device etc., and the command(s) to be executed after making the connection to the device. The CLIProperty can be used for two purposes. One of these is for opening a new CLI Session and the other purpose is to send a CLI command/request. In both cases certain parameters have to be set on the CLIProperty instance.
For example to establish a CLI Session the following parameters are required:
// Create a new CLIProperty
CLIProperty prop = new CLIProperty();
prop.setTargetHost("testhost"); // sets the target host name
prop.setLoginName("guest"); // sets the login name
prop.setPassword("guest"); // sets the password
The other parameters (like login Prompt, password prompt and shell prompt)
if not explicitly set take their default values.
For example to send a CLI request/command the following parameters are required in addition to the TargetHost and TargetPort:
// Create a new CLIProperty
CLIProperty prop = new CLIProperty();
// Create a Command List
prop.setTargetHost("testhost"); // set the target host
prop.setTargetPort("23"); //set the target port
String[] commandList = { "date" , "who" }; // eg commands
prop.setCommandList(commandList); // sets the list of commands
// Create a prompt list
String[] promptList = { "$","#" }; // eg prompts
prop.setPromptList(promptList); // sets the Prompt List
The above property can then be used to send the list of CLI commands
specified in the command list
| Fields inherited from class com.adventnet.management.Property |
OP_READ, OP_WRITE, RESULT_INT, RESULT_LONG, RESULT_OBJECT, RESULT_STRING |
| Constructor Summary | |
CLIProperty()
Creates an instance of CLIProperty setting the Protocol type field to 'CLI'. |
|
| Method Summary | |
void |
copy(Property property)
Copy the property value to this instance. |
java.lang.String |
getCombinedPropKey()
This method is not being used in CLI protocol. |
java.lang.String |
getCommand()
Getter for Command. |
java.lang.String[] |
getCommandList()
Gets the list of commands to be executed on the Device. |
java.lang.String |
getEventKey()
This method will return the sessionId as the key for the event generated. |
java.lang.String |
getLoginName()
Getter for LoginName. |
java.lang.String |
getLoginPrompt()
Getter for Login Prompt. |
java.lang.String |
getPassword()
Getter for Password. |
java.lang.String |
getPasswordPrompt()
Getter for Password Prompt. |
java.util.Properties |
getPromptAction()
Gets the prompt and its corresponding action. |
java.lang.String[] |
getPromptList()
Gets the Prompt list. |
java.util.Hashtable |
getProperties()
This method will return a Hashtable which will have the property values with the corresponding keys. |
java.lang.String |
getSessionId()
Gets the sessionId that has been set by the user. |
java.lang.String |
getSessionKey()
Returns the session key associated with a particular cli property. |
java.lang.String |
getShellPrompt()
Getter for Shell Prompt. |
java.lang.String |
getTargetHost()
Gets the target host. |
java.lang.String |
getTargetPort()
Getter for the Target port. |
boolean |
isPerformPing()
Gets the perform ping flag. |
void |
setCommand(java.lang.String command)
Setter for Command. |
void |
setCommandList(java.lang.String[] list)
Sets the list of commands to be executed in the Target Host. |
void |
setLoginName(java.lang.String loginName)
Setter for LoginName. |
void |
setLoginPrompt(java.lang.String loginPrompt)
Setter for LoginPrompt. |
void |
setPassword(java.lang.String passwd)
Setter for Password. |
void |
setPasswordPrompt(java.lang.String passwordPrompt)
Setter for PasswordPrompt. |
void |
setPerformPing(boolean flag)
Sets the perform ping flag. |
void |
setPromptAction(java.util.Properties prop)
This method is used for setting the possible prompts and action/command to be executed when the prompt is encountered. |
void |
setPromptList(java.lang.String[] list)
Sets the list of prompt(s) to be expected after the end of each and every command corresponding to the command provided in the setCommandList method. |
void |
setProperties(java.util.Hashtable prop)
This method will set a list of properties on this CLIProperty instance. |
void |
setSessionId(java.lang.String sessId)
Sets the Session Id. |
void |
setShellPrompt(java.lang.String shellPrompt)
Setter for ShellPrompt. |
void |
setTargetHost(java.lang.String host)
Sets the target host. |
void |
setTargetPort(java.lang.String p)
Setter for the Target port. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public CLIProperty()
| Method Detail |
public void setTargetHost(java.lang.String host)
host - host name of the target CLI device which can be a either the * dns name or ip address in string format like 100.100.100.100.public java.lang.String getTargetHost()
public void setCommandList(java.lang.String[] list)
syncSend() or send() on the device. Each
command will be executed in succession in the same order as in the list.list - of commands to be executed after making the connection
to the device.public java.lang.String[] getCommandList()
public void setPromptList(java.lang.String[] list)
list - of prompt to expected to know the end of the execution of
the command given.public java.lang.String[] getPromptList()
public void setCommand(java.lang.String command)
setPromptList will have only one
entry for the prompt.
If more than one command needs to be executed use the
setCommandList method.command - to be executed after making the connection to the
device.setCommandList(String[] cmdList)public java.lang.String getCommand()
public void setTargetPort(java.lang.String p)
p - the port value in string formatpublic java.lang.String getTargetPort()
public void setPassword(java.lang.String passwd)
passwd, - the password reqd. to connect to the device as LoginName.public java.lang.String getPassword()
public void setLoginName(java.lang.String loginName)
loginName, - the username reqd. to connect to the device.public java.lang.String getLoginName()
public java.lang.String getLoginPrompt()
public void setLoginPrompt(java.lang.String loginPrompt)
loginPrompt - the prompt which requests the user to enter the
loginName.public java.lang.String getPasswordPrompt()
public void setPasswordPrompt(java.lang.String passwordPrompt)
passwordPrompt, - the prompt which requests the user to enter the
password.public java.lang.String getShellPrompt()
public void setShellPrompt(java.lang.String shellPrompt)
shellPrompt - the prompt which informs the user about the
successful login and asks the user to enter the commands.public java.util.Properties getPromptAction()
setPromptAction(Properties)public void setPromptAction(java.util.Properties prop)
prop.setProperty(prompt, cmd);
When no action or command is defined for a prompt, it will be
assumed as the command prompt. Note that the suffix, if any, should
also be given in the command set for the prompt, as no
suffix would be appended to the command, when it is sent.prop - prompts and its command as a Properties object.#getCLIPromptAction()public boolean isPerformPing()
boolean value to indicate if ping needs to be done.public void setPerformPing(boolean flag)
flag - a boolean value to enable/disable ping.public void copy(Property property)
copy in class Propertyproperty - the property object containing the properties to be
setpublic void setProperties(java.util.Hashtable prop)
PropertyName Meaning host TargetHost port TargetPort loginPrompt login Prompt loginName login name to be used password The password for login passwordPrompt The password prompt to be used shellPrompt The shell prompt to be used timeout The request timeout commandList The list of commands to be sent promptList The prompts that will be received for the command sent. promptAction The prompt and action to be performed for it. performPing The flag to indicate if ping is to be done.For example:
// Create the Hashtable for setting the properties
Hashtable table = new Hashtable();
// Set the various parameters
table.put("host","test");
table.put("port","23");
table.put("loginName","guest");
table.put("password, "gugest");
// Create a new CLIProperty
CLIProperty prop = new CLIProperty();
// Set all the properties
prop.setProperties(table);
The above code sets the basic parameters like the host, port,
login name and password.setProperties in class Propertyprop - the hashtable containing the various property names (as keys)
and their values.public java.util.Hashtable getProperties()
setProperties() method.getProperties in class PropertysetProperties(Hashtable prop)public void setSessionId(java.lang.String sessId)
setSessionId in class PropertysessionID - the session IDpublic java.lang.String getSessionId()
getSessionId in class Propertypublic java.lang.String getCombinedPropKey()
getCombinedPropKey in class Propertypublic java.lang.String getEventKey()
getEventKey in class Propertypublic java.lang.String getSessionKey()
getSessionKey in class Property
|
WebNMS 5 API Specification | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||