edu.internet2.hopi.dragon
Class DragonCSA

java.lang.Object
  extended by edu.internet2.hopi.dragon.DragonCSA

public class DragonCSA
extends java.lang.Object

Issue basic DRAGON CSA CLI commands via telnet. Can be used to setup, teardown, and poll information about LSPs.

Author:
Andrew Lake (alake@internet2.edu)

Constructor Summary
DragonCSA()
          Constructor that creates telnet client and sets default values
 
Method Summary
 java.lang.String command(java.lang.String cmd)
          Issues commands to DRAGON CSA CLI
 void disconnect()
          Disconnects telnet session.
 java.util.ArrayList<DragonLSP> getAllLSPs()
          Maps all LSPs a CSA currently participates in and stores them in a list.
 java.lang.String getError()
          Get error message reported by any of the methods in this class.
 DragonLSP getLSPByName(java.lang.String lspName)
          Maps already existing LSP to an LSP object.
 java.lang.String getPromptPattern()
          Returns pattern used to identify command prompt
 java.util.ArrayList<java.lang.String> listLSPs()
          Returns a list of the names of all the LSPs in which a DRAGON CSA participates
 boolean login(java.lang.String host, int port, java.lang.String password)
          Logs user into DRAGON CSA telnet
 boolean lspExists(java.lang.String lspName)
          Checks whether an LSP with a given name exists.
 java.lang.String readUntil(java.lang.String pattern)
          Reads output from telnet until the specified pattern is reached.
 void setPromptPattern(java.lang.String pattern)
          Sets pattern used to identify the CLI command prompt.
 boolean setupLSP(DragonLSP lsp)
          Creates and commits LSP with the parameters of the LSP object passed to it.
 boolean teardownLSP(java.lang.String lspName)
          Removes LSP with the given LSP name
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DragonCSA

public DragonCSA()
Constructor that creates telnet client and sets default values

Method Detail

login

public boolean login(java.lang.String host,
                     int port,
                     java.lang.String password)
Logs user into DRAGON CSA telnet

Parameters:
host - hostname of machine running DRAGON CSA telnet server
port - port that on which DRAGON telnet server is running
password - password for CSA
Returns:
boolean value that is true if login succeeds and false if it fails

command

public java.lang.String command(java.lang.String cmd)
Issues commands to DRAGON CSA CLI

Parameters:
cmd - command to run on DRAGON CSA CLI
Returns:
output of command

readUntil

public java.lang.String readUntil(java.lang.String pattern)
Reads output from telnet until the specified pattern is reached. promptPattern is often useful when used in conjunction with this method.

Parameters:
pattern - Regular expression used to determine when output should stop being read
Returns:
output read until pattern is found

disconnect

public void disconnect()
Disconnects telnet session. Should be called when telnet session is complete.


setupLSP

public boolean setupLSP(DragonLSP lsp)
Creates and commits LSP with the parameters of the LSP object passed to it. LSP is created in UNI mode with implicit ingress and egress channels.

Parameters:
lsp - LSP object with parameters of the LSP to be setup
Returns:
boolean that is true if setup succeeds and false if fails

teardownLSP

public boolean teardownLSP(java.lang.String lspName)
Removes LSP with the given LSP name

Parameters:
lspName - Name of LSP to be deleted
Returns:
Returns true if LSP teardown succeeds and false if it fails. Most likely failure occurs when LSP does not exist.

lspExists

public boolean lspExists(java.lang.String lspName)
Checks whether an LSP with a given name exists. Does so by running the 'show lsp lspName' command

Parameters:
lspName - Name of LSP whose existence needs to be verified.
Returns:
truw if lsp exists, false if it does not exists

getLSPByName

public DragonLSP getLSPByName(java.lang.String lspName)
Maps already existing LSP to an LSP object. LSP is specified by LSP name. Uses 'show lsp lspName' CLI command to retrieve paramters.

Parameters:
lspName - name of LSP to map to object
Returns:
returns LSP object with parameters of the specified LSP. null if LSP fails to be retrieved (i.e. LSP does not exist)

getAllLSPs

public java.util.ArrayList<DragonLSP> getAllLSPs()
Maps all LSPs a CSA currently participates in and stores them in a list. LSPs of all statuses are included in the list.

Returns:
list of lsps currently enetered into DRAGON

listLSPs

public java.util.ArrayList<java.lang.String> listLSPs()
Returns a list of the names of all the LSPs in which a DRAGON CSA participates

Returns:
A list of the names of all the LSPs in which a CSA currently participates

getError

public java.lang.String getError()
Get error message reported by any of the methods in this class. Error message may also contain errors returned by DRAGON CSA CLI.

Returns:
Last error message reported by a method call

setPromptPattern

public void setPromptPattern(java.lang.String pattern)
Sets pattern used to identify the CLI command prompt. This is used to determine when a command is complete.

Parameters:
pattern - Regular expression pattern used to identify command prompt

getPromptPattern

public java.lang.String getPromptPattern()
Returns pattern used to identify command prompt

Returns:
Pattern used to identify command prompt