Example #1
0
def ssh_client(**kwargs):
    """Context manager that returns an SSH client. The SSH connection is
    opened before entering, and closed before leaving.

    """
    client = SSHClient(**kwargs)
    if not client.connect():
        raise Exception("Cannot create SSH connection with %s" % (client,))
    try:
        yield client
    finally:
        client.close()
Example #2
0
def ssh_client(**kwargs):
    """Context manager that returns an SSH client. The SSH connection is
    opened before entering, and closed before leaving.

    """
    client = SSHClient(**kwargs)
    if not client.connect():
        raise Exception("Cannot create SSH connection with %s" % (client, ))
    try:
        yield client
    finally:
        client.close()
Example #3
0
 def test_close_success(self):
     client = ShellOutSSHClient(hostname='localhost', username='******')
     self.assertTrue(client.close())
 def test_close_success(self):
     client = ShellOutSSHClient(hostname='localhost', username='******')
     self.assertTrue(client.close())