SHARE
TWEET

Untitled

a guest Jan 19th, 2017 114 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Device(object):
  2.     """ Connects to a Cisco device through telnet """
  3.    
  4.     def __init__(self, host=None, password=None, username=None, enable_password=None):
  5.         self.host = host
  6.         self.username = username
  7.         self.password = password
  8.         self.enable_password = enable_password
  9.        
  10.         self.connected = False
  11.         self._connection = None
  12.        
  13.         if self.username == '':
  14.             self.username = None
  15.  
  16.        
  17.     def connect(self, host=None, port=23, timeout=5):
  18.         if host is None:
  19.             host = self.host
  20.            
  21.         self._connection = telnetlib.Telnet(host, port, timeout)
  22.         self._authenticate()
  23.         self._get_hostname()
  24.        
  25.         self.cmd("term len 0")
  26.        
  27.         self.connected = True
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top