Ejemplo n.º 1
0
def unconfigured_appliances(request, appliance, pytestconfig):
    with sprout_appliances(
            appliance,
            preconfigured=False,
            count=3,
            config=pytestconfig,
            provider_type='rhevm',
    ) as apps:
        yield apps
        _collect_logs(request.config, apps)
Ejemplo n.º 2
0
def configured_appliance(request, appliance, pytestconfig):
    with sprout_appliances(
            appliance,
            preconfigured=True,
            count=1,
            config=pytestconfig,
            provider_type='rhevm',
    ) as apps:
        yield apps[0]
        _collect_logs(request.config, apps)
Ejemplo n.º 3
0
def get_apps(requests, appliance, old_version, count, preconfigured,
             pytest_config):
    """Requests appliance from sprout based on old_versions, edits partitions and adds
        repo file for update"""
    series = appliance.version.series()
    update_url = "update_url_{}".format(series.replace(".", ""))
    usable = []
    sp = SproutClient.from_config(
        sprout_user_key=pytest_config.option.sprout_user_key or None)
    available_versions = set(sp.call_method("available_cfme_versions"))
    for a in available_versions:
        if a.startswith(old_version):
            usable.append(Version(a))
    usable_sorted = sorted(usable, key=lambda o: o.version)
    picked_version = usable_sorted[-1]
    apps = []
    pool_id = None
    try:
        apps, pool_id = sp.provision_appliances(
            count=count,
            preconfigured=preconfigured,
            provider_type="rhevm",
            lease_time=180,
            version=str(picked_version),
        )
        url = cfme_data["basic_info"][update_url]
        assert get_puddle_cfme_version(url) == appliance.version
        for app in apps:
            app.db.extend_partition()
            app.ssh_client.run_command(
                f"curl {url} -o /etc/yum.repos.d/update.repo")

        yield apps
    except AuthException:
        msg = (
            'Sprout credentials key or yaml maps missing or invalid,'
            'unable to provision appliance version {}'.format(picked_version))
        logger.exception(msg)
        pytest.skip(msg)
    finally:
        _collect_logs(pytest_config, apps)
        for app in apps:
            app.ssh_client.close()
        if pool_id:
            sp.destroy_pool(pool_id)