Example #1
0
    status, resp = client.update_host_config(host_id,
                                             hostname='%s%s' %
                                             (HOST_NAME_PREFIX, host_id),
                                             roles=roles)
    print 'set roles to host %s status: %s, resp: %s' % (host_id, status, resp)

# deploy cluster.
status, resp = client.deploy_hosts(cluster_id)
print 'deploy cluster %s status: %s, resp: %s' % (cluster_id, status, resp)

# get intalling progress.
while True:
    status, resp = client.get_cluster_installing_progress(cluster_id)
    print 'get cluster %s installing progress status: %s, resp: %s' % (
        cluster_id, status, resp)
    progress = resp['progress']
    if (progress['state'] not in ['UNINITIALIZED', 'INSTALLING']
            or progress['percentage'] >= 1.0):
        break

    for host_id in host_ids:
        status, resp = client.get_host_installing_progress(host_id)
        print 'get host %s installing progress status: %s, resp: %s' % (
            host_id, status, resp)

    time.sleep(10)

status, resp = client.get_dashboard_links(cluster_id)
print 'get cluster %s dashboardlinks status: %s, resp: %s' % (cluster_id,
                                                              status, resp)
Example #2
0
    ):
        break
    if (
        time.time() > timeout
    ):
        raise Exception("Timeout! The system is not ready in time.")

    for host_id in host_ids:
        status, resp = client.get_host_installing_progress(host_id)
        print 'get host %s installing progress status: %s, resp: %s' % (
            host_id, status, resp)

    time.sleep(60)


status, resp = client.get_dashboard_links(cluster_id)
print 'get cluster %s dashboardlinks status: %s, resp: %s' % (
    cluster_id, status, resp)
dashboardlinks = resp['dashboardlinks']
if not dashboardlinks.keys():
    raise Exception("Dashboard link is not found!")
for x in dashboardlinks.keys():
    if x in ("os-dashboard", "os-controller"):
        dashboardurl = dashboardlinks.get(x)
        if dashboardurl is None:
            raise Exception("No dashboard link is found")
        r = requests.get(dashboardurl, verify=False)
        r.raise_for_status()
        match = re.search(
            r'(?m)(http://\d+\.\d+\.\d+\.\d+:5000/v2\.0)', r.text)
        if match: