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.conch.telnet.Telnet --+
                                                     |
                                                    TelnetClientProtocol

State-machine-based class for telnet

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

Nested Classes | [hide private]
Inherited from `twisted.conch.telnet.Telnet` (private): `_OptionState`

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.conch.telnet.Telnet`: `__init__`, `commandReceived`, `connectionLost`, `disableLocal`, `disableRemote`, `do`, `do_no_false`, `do_no_true`, `do_yes_false`, `do_yes_true`, `dont`, `dont_no_false`, `dont_no_true`, `dont_yes_false`, `dont_yes_true`, `enableLocal`, `enableRemote`, `getOptionState`, `negotiate`, `requestNegotiation`, `telnet_DO`, `telnet_DONT`, `telnet_WILL`, `telnet_WONT`, `unhandledCommand`, `unhandledSubnegotiation`, `will`, `will_no_false`, `will_no_true`, `will_yes_false`, `will_yes_true`, `wont`, `wont_no_false`, `wont_no_true`, `wont_yes_false`, `wont_yes_true` Inherited from `twisted.conch.telnet.Telnet` (private): `_do`, `_dont`, `_will`, `_wont`, `_write` 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.conch.telnet.Telnet`: `doMap`, `dontMap`, `willMap`, `wontMap` Inherited from `twisted.internet.protocol.BaseProtocol`: `connected`

Instance Variables | [hide private]
Inherited from `twisted.conch.telnet.Telnet`: `commandMap`, `negotiationMap`, `options`, `state`, `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

### iac_DONT(self, feature) | source code
Do we support this telnet feature? Reply back appropriately. Parameters: `feature` (string) - IAC feature request

### iac_WILL(self, feature) | source code
Do we support this telnet feature? Reply back appropriately. Parameters: `feature` (string) - IAC feature request

### iac_WONT(self, feature) | source code
Do we support this telnet feature? Reply back appropriately. Parameters: `feature` (string) - IAC feature request

### _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

### 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

### 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

### 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 Overrides: twisted.conch.telnet.Telnet.applicationDataReceived

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

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

### curCommand(self) | source code
Return the current command to run Returns: string next command to run