def ssh_connect(connection): """Method to connect to remote system using ssh protocol. :param connection: a Connection object. :returns: paramiko.SSHClient -- an active ssh connection. :raises: PowerVMConnectionFailed """ try: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(connection.host, username=connection.username, password=connection.password, port=connection.port, key_filename=connection.keyfile, timeout=constants.POWERVM_CONNECTION_TIMEOUT) LOG.debug("SSH connection with %s established successfully." % connection.host) # send TCP keepalive packets every 20 seconds ssh.get_transport().set_keepalive(20) return ssh except Exception: LOG.exception(_('Connection error connecting PowerVM manager')) raise exception.PowerVMConnectionFailed()
def ssh_connect(connection): """Method to connect to remote system using ssh protocol. :param connection: a Connection object. :returns: paramiko.SSHClient -- an active ssh connection. :raises: PowerVMConnectionFailed """ try: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(connection.host, username=connection.username, password=connection.password, port=connection.port) return ssh except Exception: LOG.exception(_('Connection error connecting PowerVM manager')) raise exception.PowerVMConnectionFailed()
def fake_copy_file_to_device(source_path, device): raise exception.PowerVMConnectionFailed()