def _install_cluster(client, cluster):
    cluster = client.install_cluster(cluster_id=cluster.id)
    utils.wait_till_cluster_is_in_status(
        client=client,
        cluster_id=cluster.id,
        timeout=consts.START_CLUSTER_INSTALLATION_TIMEOUT,
        statuses=[consts.ClusterStatus.INSTALLING],
    )
    utils.wait_till_all_hosts_are_in_status(
        client=client,
        cluster_id=cluster.id,
        nodes_count=len(cluster.hosts),
        statuses=[
            consts.NodesStatus.INSTALLING,
            consts.NodesStatus.INSTALLING_IN_PROGRESS,
        ],
        interval=30,
    )
def run_install_flow(client, cluster_id, kubeconfig_path, pull_secret, tf=None):
    log.info("Verifying cluster exists")
    cluster = client.cluster_get(cluster_id)
    client.update_cluster_install_config(cluster_id, {"networking": {"networkType": "OpenShiftSDN"}})
    log.info("Verifying pull secret")
    verify_pull_secret(client=client, cluster=cluster, pull_secret=pull_secret)
    log.info("Wait till cluster is ready")
    utils.wait_till_cluster_is_in_status(
        client=client,
        cluster_id=cluster_id,
        statuses=[consts.ClusterStatus.READY, consts.ClusterStatus.INSTALLING],
    )
    cluster = client.cluster_get(cluster_id)
    if cluster.status == consts.ClusterStatus.READY:
        log.info("Install cluster %s", cluster_id)
        _install_cluster(client=client, cluster=cluster)

    else:
        log.info("Cluster is already in installing status, skipping install command")

    log.info("Download kubeconfig-noingress")
    client.download_kubeconfig_no_ingress(
        cluster_id=cluster_id, kubeconfig_path=kubeconfig_path
    )

    wait_till_installed(client=client, cluster=cluster)

    log.info("Download kubeconfig")
    waiting.wait(
        lambda: client.download_kubeconfig(
            cluster_id=cluster_id, kubeconfig_path=kubeconfig_path
        )
        is None,
        timeout_seconds=240,
        sleep_seconds=20,
        expected_exceptions=Exception,
        waiting_for="Kubeconfig",
    )

    # set new vips
    if tf:
        cluster_info = client.cluster_get(cluster.id)
        tf.set_new_vip(cluster_info.api_vip)
def wait_till_installed(client, cluster, timeout=60 * 60 * 2):
    log.info("Waiting %s till cluster finished installation", timeout)
    # TODO: Change host validation for only previous known hosts
    try:
        utils.wait_till_all_hosts_are_in_status(
            client=client,
            cluster_id=cluster.id,
            nodes_count=len(cluster.hosts),
            statuses=[consts.NodesStatus.INSTALLED],
            timeout=timeout,
            interval=60,
        )
        utils.wait_till_cluster_is_in_status(
            client=client,
            cluster_id=cluster.id,
            statuses=[consts.ClusterStatus.INSTALLED],
            timeout=consts.CLUSTER_INSTALLATION_TIMEOUT,
        )
    finally:
        download_logs_from_all_hosts(client=client, cluster_id=cluster.id)
Example #4
0
 def wait_until_cluster_is_ready_for_install(cluster_id, api_client):
     utils.wait_till_cluster_is_in_status(
         client=api_client,
         cluster_id=cluster_id,
         statuses=[consts.ClusterStatus.READY])