Package Products :: Package DataCollector :: Module TelnetClient :: Class TelnetClientProtocol
[hide private]
[frames] | no frames]

Class TelnetClientProtocol

source code

twisted.internet.protocol.BaseProtocol --+        
                                         |        
        twisted.internet.protocol.Protocol --+    
                                             |    
               twisted.protocols.telnet.Telnet --+
                                                 |
                                                TelnetClientProtocol

State-machine-based class for telnet

To switch from one state to the next, methods return the next state.

Instance Methods [hide private]
 
connectionMade(self)
Called when a telnet session is established
source code
 
iac_DO(self, feature)
Do we support this telnet feature? Reply back appropriately.
source code
 
iac_DONT(self, feature)
Do we support this telnet feature? Reply back appropriately.
source code
 
iac_WILL(self, feature)
Do we support this telnet feature? Reply back appropriately.
source code
 
iac_WONT(self, feature)
Do we support this telnet feature? Reply back appropriately.
source code
 
_iac_response(self, action, feature)
Respond to IAC request with our response
source code
 
write(self, data)
Write data across the wire and record it.
source code
 
processChunk(self, chunk)
Given data returned from the remote device, test out the current chunk of data to determine whether or not to switch states, or just add the chunk to the list of data received from the host.
source code
 
processLine(self, line)
Call a method that looks like 'telnet_*' where '*' is filled in by the current mode.
source code
 
dataReceived(self, data)
Look for data and send to processLine()
source code
 
applicationDataReceived(self, bytes)
Store any bytes received
source code
 
startTimeout(self, timeout=1, timeoutfunc=None)
Start a timer to decide if we continue or not.
source code
 
cancelTimeout(self)
Cancel the timeout timer
source code
 
defaultTimeout(self)
Reset the timeout timer
source code
string
loginTimeout(self, loginTries=0)
Called when the timeout timer expires.
source code
string
telnet_Login(self, data)
Called when login prompt is expected
source code
string
telnet_Password(self, data)
Called when the password prompt is expected
source code
string
telnet_Enable(self, unused)
Switch to 'enable' mode on a Cisco device
source code
string
telnet_EnablePassword(self, data)
Called when the enable password prompt is expected
source code
string
telnet_FindPrompt(self, data)
Called after login to figure out the command prompt
source code
string
telnet_ClearPromptData(self, unused)
Called to try to restore sanity to output from the user.
source code
string
telnet_SendCommand(self, unused)
Get a command of the command stack and send it
source code
string
telnet_Command(self, data)
Process the data from a sent command If there are no more commands move to final state
source code
string
curCommand(self)
Return the current command to run
source code

Inherited from twisted.protocols.telnet.Telnet: iacSBchunk, iac_IP, loggedIn, loginPrompt, telnet_User, welcomeMessage

Inherited from twisted.internet.protocol.Protocol: connectionLost

Inherited from twisted.internet.protocol.BaseProtocol: makeConnection

Class Variables [hide private]
  mode = 'Login'
  timeout = 0
  timeoutID = None
  p1 = ""
  p2 = ""
  commandPrompt = ""
  command = ''
  enabled = -1
  scCallLater = None
  bytes = ''
  lastwrite = ''
  result = ''
  buffer = ""

Inherited from twisted.protocols.telnet.Telnet: delimiters, echo, gotIAC, iacByte, lastLine

Inherited from twisted.internet.protocol.BaseProtocol: connected, transport

Method Details [hide private]

connectionMade(self)

source code 

Called when a telnet session is established

Overrides: twisted.internet.protocol.BaseProtocol.connectionMade

iac_DO(self, feature)

source code 

Do we support this telnet feature? Reply back appropriately.

Parameters:
  • feature (string) - IAC feature request
Overrides: twisted.protocols.telnet.Telnet.iac_DO

iac_DONT(self, feature)

source code 

Do we support this telnet feature? Reply back appropriately.

Parameters:
  • feature (string) - IAC feature request
Overrides: twisted.protocols.telnet.Telnet.iac_DONT

iac_WILL(self, feature)

source code 

Do we support this telnet feature? Reply back appropriately.

Parameters:
  • feature (string) - IAC feature request
Overrides: twisted.protocols.telnet.Telnet.iac_WILL

iac_WONT(self, feature)

source code 

Do we support this telnet feature? Reply back appropriately.

Parameters:
  • feature (string) - IAC feature request
Overrides: twisted.protocols.telnet.Telnet.iac_WONT

_iac_response(self, action, feature)

source code 

Respond to IAC request with our response

Parameters:
  • action (string) - IAC action
  • feature (string) - IAC feature request

write(self, data)

source code 

Write data across the wire and record it.

Parameters:
  • data (string) - data to write
Overrides: twisted.protocols.telnet.Telnet.write

processChunk(self, chunk)

source code 

Given data returned from the remote device, test out the current chunk of data to determine whether or not to switch states, or just add the chunk to the list of data received from the host.

If we find the end condition for the state, process the line.

Parameters:
  • chunk (string) - data
Overrides: twisted.protocols.telnet.Telnet.processChunk

processLine(self, line)

source code 

Call a method that looks like 'telnet_*' where '*' is filled in by the current mode. telnet_* methods should return a string which will become the new mode.

Parameters:
  • line (string) - data
Overrides: twisted.protocols.telnet.Telnet.processLine

dataReceived(self, data)

source code 

Look for data and send to processLine()

Parameters:
  • data (string) - output from telnet
Overrides: twisted.internet.protocol.Protocol.dataReceived

applicationDataReceived(self, bytes)

source code 

Store any bytes received

Parameters:
  • bytes (string) - output from telnet

startTimeout(self, timeout=1, timeoutfunc=None)

source code 

Start a timer to decide if we continue or not.

Parameters:
  • timeout (integer) - time in seconds to wait
  • timeoutfunc (function) - override for the default timeout timer

loginTimeout(self, loginTries=0)

source code 

Called when the timeout timer expires.

Parameters:
  • loginTries (integer) - number of login failures to accept
Returns: string
next state (Done, Login)

telnet_Login(self, data)

source code 

Called when login prompt is expected

Parameters:
  • data (string) - data sent back from the remote device
Returns: string
next state (Login, Password)

telnet_Password(self, data)

source code 

Called when the password prompt is expected

Parameters:
  • data (string) - data sent back from the remote device
Returns: string
next state (Password, FindPrompt)
Overrides: twisted.protocols.telnet.Telnet.telnet_Password

telnet_Enable(self, unused)

source code 

Switch to 'enable' mode on a Cisco device

Parameters:
  • unused (string) - unused (unused)
Returns: string
next state (Password)

telnet_EnablePassword(self, data)

source code 

Called when the enable password prompt is expected

Parameters:
  • data (string) - data sent back from the remote device
Returns: string
next state (EnablePassword, FindPrompt)

telnet_FindPrompt(self, data)

source code 

Called after login to figure out the command prompt

Parameters:
  • data (string) - data sent back from the remote device
Returns: string
next state (ClearPromptData, FindPrompt, Password)

telnet_ClearPromptData(self, unused)

source code 

Called to try to restore sanity to output from the user. Send an empty string to get back a prompt

Parameters:
  • unused (string) - unused (unused)
Returns: string
next state (ClearPromptData)

telnet_SendCommand(self, unused)

source code 

Get a command of the command stack and send it

Parameters:
  • unused (string) - unused (unused)
Returns: string
next state (Command)

telnet_Command(self, data)

source code 

Process the data from a sent command If there are no more commands move to final state

Parameters:
  • data (string) - data sent back from the remote device
Returns: string
next state (Command, Done)
Overrides: twisted.protocols.telnet.Telnet.telnet_Command

curCommand(self)

source code 

Return the current command to run

Returns: string
next command to run