fixtures.ssh_client module

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

Loop through the appliance stack and close ssh connections

fixtures.ssh_client.ssh_client(uses_ssh)[source]

SSH Client Fixture

Usage:

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
    ssh_client.run_rake_command('evm:stop')

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
    ssh_client.run_command('some_command')

    # Instantiate a client aimed at a different hostname
    ssh_client_2 = ssh_client(hostname='different.host')
    ssh_client_2.run_command('some_other_command')

    # 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='different.host', **credentials['ssh'])
fixtures.ssh_client.ssh_client_modscope(uses_ssh)[source]

See ssh_client().