Ejemplo n.º 1
0
def module_rhel_client_by_ip(module_org, smart_proxy_location,
                             rhel7_contenthost, target_sat):
    """Setup a broker rhel client to be used in remote execution by ip"""
    rhel7_contenthost.configure_rex(satellite=target_sat, org=module_org)
    update_vm_host_location(rhel7_contenthost,
                            location_id=smart_proxy_location.id)
    yield rhel7_contenthost
Ejemplo n.º 2
0
def module_vm_client_by_ip(rhel7_contenthost, module_org, smart_proxy_location,
                           default_sat):
    """Setup a VM client to be used in remote execution by ip"""
    rhel7_contenthost.configure_rex(satellite=default_sat, org=module_org)
    update_vm_host_location(rhel7_contenthost,
                            location_id=smart_proxy_location.id)
    yield rhel7_contenthost
Ejemplo n.º 3
0
def vm_content_hosts(request, module_loc, module_repos_collection):
    distro = module_repos_collection.distro
    with VMBroker(nick=distro, host_classes={'host': ContentHost},
                  _count=2) as clients:
        for client in clients:
            module_repos_collection.setup_virtual_machine(client)
            update_vm_host_location(client, module_loc.id)
        yield clients
Ejemplo n.º 4
0
def vm_content_hosts(request, module_loc, module_repos_collection):
    clients = []
    for _ in range(2):
        client = VirtualMachine(distro=module_repos_collection.distro)
        clients.append(client)
        request.addfinalizer(client.destroy)
        client.create()
        module_repos_collection.setup_virtual_machine(client)
        update_vm_host_location(client, module_loc.id)
    return clients
Ejemplo n.º 5
0
def vm_content_hosts(request, module_loc, module_repos_collection):
    clients = []
    for _ in range(2):
        client = VirtualMachine(distro=module_repos_collection.distro)
        clients.append(client)
        request.addfinalizer(client.destroy)
        client.create()
        module_repos_collection.setup_virtual_machine(client)
        update_vm_host_location(client, module_loc.id)
    return clients
Ejemplo n.º 6
0
def vm_content_hosts(module_loc, module_repos_collection, default_sat):
    distro = module_repos_collection.distro
    with VMBroker(nick=distro, host_classes={'host': ContentHost},
                  _count=2) as clients:
        for client in clients:
            module_repos_collection.setup_virtual_machine(
                client, default_sat, install_katello_agent=False)
            add_remote_execution_ssh_key(client.ip_addr)
            update_vm_host_location(client, module_loc.id)
        yield clients
Ejemplo n.º 7
0
def vm_content_hosts(smart_proxy_location, module_repos_collection,
                     default_sat):
    distro = module_repos_collection.distro
    with VMBroker(nick=distro, host_classes={'host': ContentHost},
                  _count=2) as clients:
        for client in clients:
            module_repos_collection.setup_virtual_machine(
                client, default_sat, install_katello_agent=False)
            client.add_rex_key(satellite=default_sat)
            update_vm_host_location(client, smart_proxy_location.id)
        yield clients
Ejemplo n.º 8
0
def test_positive_run_job_template_multiple_hosts_by_ip(
    session, module_org, smart_proxy_location, target_sat
):
    """Run a job template against multiple hosts by ip

    :id: c4439ec0-bb80-47f6-bc31-fa7193bfbeeb

    :Setup: Create a working job template.

    :Steps:

        1. Set remote_execution_connect_by_ip on hosts to true
        2. Navigate to the hosts page and select at least two hosts
        3. Click the "Select Action"
        4. Select the job and appropriate template
        5. Run the job

    :expectedresults: Verify the job was successfully ran against the hosts

    :CaseLevel: System
    """
    with VMBroker(nick='rhel7', host_classes={'host': ContentHost}, _count=2) as hosts:
        host_names = []
        for host in hosts:
            host_names.append(host.hostname)
            host.configure_rex(satellite=target_sat, org=module_org)
            update_vm_host_location(host, location_id=smart_proxy_location.id)
        with session:
            session.location.select(smart_proxy_location.name)
            hosts = session.host.search(
                ' or '.join([f'name="{hostname}"' for hostname in host_names])
            )
            assert {host['Name'] for host in hosts} == set(host_names)
            job_status = session.host.schedule_remote_job(
                host_names,
                {
                    'job_category': 'Commands',
                    'job_template': 'Run Command - SSH Default',
                    'template_content.command': 'ls',
                    'schedule': 'Execute now',
                },
            )
            assert job_status['overview']['job_status'] == 'Success'
            assert {host_job['Host'] for host_job in job_status['overview']['hosts_table']} == set(
                host_names
            )
            assert all(
                host_job['Status'] == 'success'
                for host_job in job_status['overview']['hosts_table']
            )
Ejemplo n.º 9
0
def vm_content_hosts_module_stream(module_loc,
                                   module_repos_collection_module_stream):
    distro = module_repos_collection_module_stream.distro
    with VMBroker(nick=distro, host_classes={'host': ContentHost},
                  _count=2) as clients:
        for client in clients:
            module_repos_collection_module_stream.setup_virtual_machine(
                client, install_katello_agent=False)
            add_remote_execution_ssh_key(client.ip_addr)
            update_vm_host_location(client, module_loc.id)
        smart_proxy = (entities.SmartProxy().search(
            query={'search': f'name={settings.server.hostname}'})[0].read())
        smart_proxy.location.append(entities.Location(id=module_loc.id))
        smart_proxy.update(['location'])
        yield clients
Ejemplo n.º 10
0
def vm_content_hosts_module_stream(module_loc, module_repos_collection_module_stream):
    distro = module_repos_collection_module_stream.distro
    with VirtualMachine(distro=distro) as client1, VirtualMachine(distro=distro) as client2:
        clients = [client1, client2]
        for client in clients:
            module_repos_collection_module_stream.setup_virtual_machine(
                client,
                install_katello_agent=False
            )
            add_remote_execution_ssh_key(client.ip_addr)
            update_vm_host_location(client, module_loc.id)
        smart_proxy = entities.SmartProxy().search(
            query={'search': 'name={0}'.format(settings.server.hostname)})[0].read()
        smart_proxy.location.append(entities.Location(id=module_loc.id))
        smart_proxy.update(['location'])
        yield clients
Ejemplo n.º 11
0
def test_positive_run_job_template_multiple_hosts_by_ip(
        session, module_org, module_loc):
    """Run a job template against multiple hosts by ip

    :id: c4439ec0-bb80-47f6-bc31-fa7193bfbeeb

    :Setup: Create a working job template.

    :Steps:

        1. Set remote_execution_connect_by_ip on hosts to true
        2. Navigate to the hosts page and select at least two hosts
        3. Click the "Select Action"
        4. Select the job and appropriate template
        5. Run the job

    :expectedresults: Verify the job was successfully ran against the hosts

    :CaseLevel: System
    """
    with VirtualMachine(distro=DISTRO_DEFAULT) as client_1, VirtualMachine(
            distro=DISTRO_DEFAULT) as client_2:
        vm_clients = [client_1, client_2]
        host_names = [client.hostname for client in vm_clients]
        for client in vm_clients:
            _setup_vm_client_host(client, module_org.label)
            update_vm_host_location(client, location_id=module_loc.id)
        with session:
            hosts = session.host.search(' or '.join(
                [f'name="{hostname}"' for hostname in host_names]))
            assert {host['Name'] for host in hosts} == set(host_names)
            job_status = session.host.schedule_remote_job(
                host_names,
                {
                    'job_category': 'Commands',
                    'job_template': 'Run Command - SSH Default',
                    'template_content.command': 'ls',
                    'schedule': 'Execute now',
                },
            )
            assert job_status['overview']['job_status'] == 'Success'
            assert {
                host_job['Host']
                for host_job in job_status['overview']['hosts_table']
            } == set(host_names)
            assert all(host_job['Status'] == 'success'
                       for host_job in job_status['overview']['hosts_table'])
Ejemplo n.º 12
0
def module_rhel_client_by_ip(module_org, module_loc, rhel7_contenthost):
    """Setup a broker rhel client to be used in remote execution by ip"""
    _setup_host_client(rhel7_contenthost, module_org.label)
    update_vm_host_location(rhel7_contenthost, location_id=module_loc.id)
    yield rhel7_contenthost
Ejemplo n.º 13
0
def module_vm_client_by_ip(rhel7_contenthost, module_org, module_loc):
    """Setup a VM client to be used in remote execution by ip"""
    _setup_vm_client_host(rhel7_contenthost, module_org.label)
    update_vm_host_location(rhel7_contenthost, location_id=module_loc.id)
    yield rhel7_contenthost
Ejemplo n.º 14
0
def module_vm_client_by_ip(module_org, module_loc):
    """Setup a VM client to be used in remote execution by ip"""
    with VirtualMachine(distro=DISTRO_DEFAULT) as vm_client:
        _setup_vm_client_host(vm_client, module_org.label)
        update_vm_host_location(vm_client, location_id=module_loc.id)
        yield vm_client
Ejemplo n.º 15
0
def module_rhel_client_by_ip(module_org, module_loc, rhel7_contenthost,
                             default_sat):
    """Setup a broker rhel client to be used in remote execution by ip"""
    rhel7_contenthost.configure_rex(satellite=default_sat, org=module_org)
    update_vm_host_location(rhel7_contenthost, location_id=module_loc.id)
    yield rhel7_contenthost