示例#1
0
文件: brocade.py 项目: wkumari/ldpush
 def _Connect(self,
              username=None,
              password=None,
              ssh_keys=None,
              enable_password=None,
              ssl_cert_set=None):
     _ = enable_password, ssl_cert_set
     self._connection = pexpect_connection.ParamikoSshConnection(
         self.loopback_ipv4,
         username,
         password,
         self._success,
         timeout=self.timeout_connect,
         find_prompt=True,
         ssh_keys=ssh_keys,
         # Brocade case 1101014 - \n\r\0 newlines in some 'tm voq' outputs.
         ssh_client=self.ssh_client,
         find_prompt_prefix=r'(?:^|\n|\n\r\0)')
     try:
         self._connection.Connect()
         self._DisablePager()
         self.connected = True
     except pexpect_connection.ConnectionError, e:
         self.connected = False
         raise exceptions.ConnectError(e)
示例#2
0
文件: ios.py 项目: tqangxl/ldpush
 def _Connect(self,
              username,
              password=None,
              ssh_keys=None,
              enable_password=None,
              ssl_cert_set=None):
     _ = ssl_cert_set
     self._connection = pexpect_connection.ParamikoSshConnection(
         self.loopback_ipv4,
         username,
         password,
         self._success,
         timeout=self.timeout_connect,
         find_prompt=True,
         ssh_keys=ssh_keys,
         enable_password=enable_password)
     try:
         self._connection.Connect()
         self._DisablePager()
         self.connected = True
     except pexpect_connection.ConnectionError as e:
         self.connected = False
         raise exceptions.ConnectError(e)
     except pexpect_connection.TimeoutError as e:
         self.connected = False
         raise exceptions.ConnectError(
             'Timed out connecting to %s(%s) after '
             '%s seconds.' % (self.host, self.loopback_ipv4, str(e)))