Exemple #1
0
def deploy(ansible_vms_to_deploy, deploy_scripts, working_dir, request):
    if deployment_utils.is_deployed(working_dir):
        LOGGER.info("Environment already deployed")
        return

    LOGGER.info("Waiting for SSH on the VMs")
    ansible_vms_to_deploy.wait_for_connection(timeout=120)

    # set static hostname to match the one assigned by DNS
    ansible_vms_to_deploy.shell("hostnamectl set-hostname $(hostname)")

    # disable all repos
    package_mgmt.disable_all_repos(ansible_vms_to_deploy)

    # dnf is grumpy when it has no repos to work with
    package_mgmt.add_dummy_repo(ansible_vms_to_deploy)

    # add custom repos
    custom_repos = request.config.getoption('--custom-repo')
    if custom_repos is not None:
        custom_repos = package_mgmt.expand_jenkins_repos(custom_repos)
        package_mgmt.add_custom_repos(ansible_vms_to_deploy, custom_repos)
        ansible_vms_to_deploy.shell(
            'dnf upgrade --nogpgcheck -y -x ovirt-release-master')
        # check if packages from custom repos were used
        if not request.config.getoption('--skip-custom-repos-check'):
            package_mgmt.check_installed_packages(ansible_vms_to_deploy)

    # report package versions
    package_mgmt.report_ovirt_packages_versions(ansible_vms_to_deploy)

    # run deployment scripts
    runs = [
        functools.partial(run_scripts, hostname, scripts)
        for hostname, scripts in deploy_scripts.items()
    ]
    utils.invoke_different_funcs_in_parallel(*runs)

    # mark env as deployed
    deployment_utils.mark_as_deployed(working_dir)
def check_installed_packages(all_hostnames):
    package_mgmt.check_installed_packages(all_hostnames)
def deploy(
    ansible_all,
    ansible_hosts,
    deploy_scripts,
    deploy_hosted_engine,
    root_dir,
    working_dir,
    request,
    run_scripts,
    set_sar_interval,
    ost_images_distro,
    ssh_key_file,
    backend,
    management_network_name,
    management_network_supports_ipv4,
):
    if deployment_utils.is_deployed(working_dir):
        LOGGER.info("Environment already deployed")
        return

    LOGGER.info("Waiting for SSH on the VMs")
    ansible_all.wait_for_connection(timeout=120)

    # set static hostname to match the one assigned by DNS
    ansible_all.shell("hostnamectl set-hostname $(hostname)")

    # start IPv6 proxy for dnf so we can update packages
    if not management_network_supports_ipv4:
        LOGGER.info("Start sshd_proxy service and configure DNF for IPv6")
        # can't use a fixture since VMs may not be up yet
        ip = list(backend.ip_mapping().values())[0][management_network_name][0]
        start_sshd_proxy(
            ansible_all,
            ipaddress.ip_interface(f"{ip}/64").network[1],
            root_dir,
            ssh_key_file,
        )

    # disable all repos
    package_mgmt.disable_all_repos(ansible_all)

    # add custom repos
    custom_repos = request.config.getoption('--custom-repo')
    if custom_repos is not None:
        repo_urls = package_mgmt.expand_repos(custom_repos, working_dir,
                                              ost_images_distro)
        package_mgmt.add_custom_repos(ansible_all, repo_urls)
        ansible_all.shell(
            'dnf upgrade --nogpgcheck -y --disableplugin versionlock -x ovirt-release-master,ovirt-release-master-tested,ovirt-engine-appliance,rhvm-appliance,ovirt-node-ng-image-update,redhat-virtualization-host-image-update,ovirt-release-host-node'
        )
        # check if packages from custom repos were used
        if not request.config.getoption(
                '--skip-custom-repos-check') and not deploy_hosted_engine:
            package_mgmt.check_installed_packages(ansible_all)

    # report package versions
    package_mgmt.report_ovirt_packages_versions(ansible_all)

    # run deployment scripts
    runs = [
        functools.partial(run_scripts, hostname, scripts)
        for hostname, scripts in deploy_scripts.items()
    ]
    utils.invoke_different_funcs_in_parallel(*runs)

    # setup vdsm coverage on hosts if desired
    if request.config.getoption('--vdsm-coverage'):
        coverage.vdsm.setup(ansible_hosts)

    # setup sar stat utility
    set_sar_interval()

    # mark env as deployed
    deployment_utils.mark_as_deployed(working_dir)
def test_check_installed_packages(request, ansible_all):
    if request.config.getoption('--skip-custom-repos-check'):
        pytest.skip('the check was disabled by the run argument')

    package_mgmt.check_installed_packages(ansible_all)