def open(self):
"""Opens a new SSH connection if the transport layer is missing.
This can be called if an active SSH connection is open already.
"""
# Create a new SSH connection if the transport layer is missing.
if self.ssh:
transport_active = False
if self.ssh.get_transport():
transport_active = self.ssh.get_transport().is_active()
if not transport_active:
try:
self._connect(self.ssh)
except Exception as e:
msg = "Error connecting via ssh: %s" % e
self._logger.error(msg)
raise paramiko.SSHException(msg)
评论列表
文章目录