fixtures.ssh_client module

fixtures.ssh_client.pytest_sessionfinish(session, exitstatus)[source]

Loop through the appliance stack and close ssh connections


SSH Client Fixture


def test_ssh(ssh_client):
    # Run a basic command
    result = ssh_client.run_command('ls -al')
    # rc is the numeric return code from the called command,
    # so 0 means everything is OK.
    assert result.rc == 0
    # and the output is available, too
    print result.output

    # Run a task using the CFME rails runner CLI
    ssh_client.run_rails_command('do stuff')

    # More useful: Run a rake task using the correct invokation

Additionally, the ssh_client fixture can be used to create other ssh clients, if you need to connect to multiple hosts in a test run:

def test_multiple_ssh(ssh_client):
    # Normal behavior still works

    # Instantiate a client aimed at a different hostname
    ssh_client_2 = ssh_client(hostname='')

    # Username and password can be changed, too
    ssh_client_3 = ssh_client(username='foo', password='bar')

    # Hint: **credentials['credentials_key'], e.g.
    ssh_client_4 = ssh_client(hostname='', **credentials['ssh'])

See ssh_client().