Example #1
0
def make_cluster(conn, cluster_desc, deploy_timeout, min_nodes,
                 reuse_cluster_id=None, ignore_task_errors=False):
    if reuse_cluster_id is None:
        for cluster_obj in fuel_rest_api.get_all_clusters(conn):
            if cluster_obj.name == cluster_desc['name']:
                logger.info("Deleting old cluster.... this may takes a while")
                cluster_obj.delete()
                wd = fuel_rest_api.with_timeout(60, "Wait cluster deleted")
                wd(lambda co: not co.check_exists())(cluster_obj)
                break

        logger.info("Start deploying cluster")

        c = deploy_cluster(conn, cluster_desc, deploy_timeout, min_nodes,
                           ignore_task_errors=ignore_task_errors)

        with log_error("!Get list of nodes"):
            nodes = list(c.get_nodes())
            c.nodes = fuel_rest_api.NodeList(nodes)
    else:
        msg = "Will reuse existing cluster with id={0}"
        logger.info(msg.format(reuse_cluster_id))
        with log_error("Reflecting cluster {0}".format(reuse_cluster_id)):
            c = fuel_rest_api.reflect_cluster(conn, reuse_cluster_id)

    try:
        yield c
    finally:
        if reuse_cluster_id is None:
            with log_error("Starts dropping cluster"):
                c.delete()
Example #2
0
def deploy_cluster(conn,
                   cluster_desc,
                   deploy_timeout,
                   min_nodes,
                   ignore_task_errors=False):

    msg_templ = "Waiting till at least {0} nodes became available"
    logger.info(msg_templ.format(min_nodes))

    cluster = cert_heat.create_cluster(conn, cluster_desc)

    url = "%s/#cluster/%s/nodes" % (conn.root_url, cluster.id)

    try:
        if not make_user_to_setup_networks(url):
            raise SystemExit()
    except:
        logger.info("Exiting. Removing cluster")
        cluster.delete()
        wd = fuel_rest_api.with_timeout(60, "Wait cluster deleted")
        wd(lambda co: not co.check_exists())(cluster)
        raise

    logger.info("Start deploing. This may takes a hours. " +
                "You may follow deployment process in FUEL UI " +
                "in you browser")

    cluster.deploy(deploy_timeout, ignore_task_errors=ignore_task_errors)
    return cluster
Example #3
0
def make_cluster(conn, cluster_desc, deploy_timeout, min_nodes):
    for cluster_obj in fuel_rest_api.get_all_clusters(conn):
        if cluster_obj.name == cluster_desc['name']:

            if logger is not None:
                logger.info("Deleting old cluster.... this may takes a while")

            cluster_obj.delete()
            wd = fuel_rest_api.with_timeout(60, "Wait cluster deleted")
            wd(lambda co: not co.check_exists())(cluster_obj)

            break

    if logger is not None:
        logger.info("Start deploying cluster")

    c = deploy_cluster(conn, cluster_desc, deploy_timeout, min_nodes)
    nodes = list(c.get_nodes())
    c.nodes = fuel_rest_api.NodeList(nodes)

    # c = fuel_rest_api.reflect_cluster(conn, 30)

    try:
        yield c
    finally:
        if logger is not None:
            logger.info("Start dropping cluster")
        c.delete()
Example #4
0
def deploy_cluster(conn, cluster_desc, deploy_timeout, min_nodes,
                   ignore_task_errors=False):

    msg_templ = "Waiting till at least {0} nodes became available"
    logger.info(msg_templ.format(min_nodes))

    cluster = cert_heat.create_cluster(conn, cluster_desc)

    url = "%s/#cluster/%s/nodes" % (conn.root_url, cluster.id)

    try:
        if not make_user_to_setup_networks(url):
            raise SystemExit()
    except:
        logger.info("Exiting. Removing cluster")
        cluster.delete()
        wd = fuel_rest_api.with_timeout(60, "Wait cluster deleted")
        wd(lambda co: not co.check_exists())(cluster)
        raise

    logger.info("Start deploing. This may takes a hours. " +
                "You may follow deployment process in FUEL UI " +
                "in you browser")

    cluster.deploy(deploy_timeout, ignore_task_errors=ignore_task_errors)
    return cluster
def main(argv):
    args = parse_command_line(argv)
    conn = login(args.fuelurl, args.auth)
    cluster = yaml.load(open(args.config_file).read())

    for cluster_obj in fuel_rest_api.get_all_clusters(conn):
        if cluster_obj.name == cluster['name']:
            cluster_obj.delete()
            wd = fuel_rest_api.with_timeout(60, "Wait cluster deleted")
            wd(lambda co: not co.check_exists())(cluster_obj)

    create_cluster(conn, cluster)
Example #6
0
def run_all_ostf_tests(conn, cluster_id, timeout):
    testsets = conn.get('/ostf/testsets/{}'.format(cluster_id))
    tests = [testset['id'] for testset in testsets]

    for test_name in tests:

        data = {'testset': test_name,
                'tests': [],
                'metadata': {'cluster_id': cluster_id}}

        run_id = conn.post('ostf/testruns', [data])[0]['id']

        def check_ready(run_id):
            status = conn.get('/ostf/testruns/{}'.format(run_id))
            return status['status'] == 'finished'

        wt = fuel_rest_api.with_timeout(timeout,
                                        "run test " + test_name)
        wt(check_ready)(run_id)

        yield conn.get('/ostf/testruns/{}'.format(run_id))
Example #7
0
def run_all_ostf_tests(conn, cluster_id, timeout):
    testsets = conn.get('/ostf/testsets/{0}'.format(cluster_id))
    tests = [testset['id'] for testset in testsets]

    for test_name in tests:

        data = {'testset': test_name,
                'tests': [],
                'metadata': {'cluster_id': cluster_id}}

        run_id = conn.post('ostf/testruns', [data])[0]['id']

        def check_ready(run_id):
            status = conn.get('/ostf/testruns/{0}'.format(run_id))
            return status['status'] == 'finished'

        wt = fuel_rest_api.with_timeout(timeout,
                                        "run test " + test_name)
        wt(check_ready)(run_id)

        yield conn.get('/ostf/testruns/{0}'.format(run_id))
Example #8
0
def main(argv):
    args = parse_command_line(argv)

    logger.info("Connecting to fuel")
    conn = login(args.fuelurl, args.auth)

    logger.info("Loading config from " + args.config_file)
    cluster = yaml.load(open(args.config_file).read())

    logger.info("Will deploy cluster {0!r}".format(cluster['name']))
    logger.info("Checking already created clusters")

    for cluster_obj in fuel_rest_api.get_all_clusters(conn):
        if cluster_obj.name == cluster['name']:
            logger.info("Found cluster, will delete it")
            cluster_obj.delete()
            wd = fuel_rest_api.with_timeout(60, "Wait cluster deleted")
            wd(lambda co: not co.check_exists())(cluster_obj)

    new_cluster_obj = create_cluster(conn, cluster)
    templ = 'Cluster ready - navigate to "{0}#cluster/{1}/nodes"'
    logger.info(templ.format(args.fuelurl, new_cluster_obj.id))
Example #9
0
def main(argv):
    args = parse_command_line(argv)

    logger.info("Connecting to fuel")
    conn = login(args.fuelurl, args.auth)

    logger.info("Loading config from " + args.config_file)
    cluster = yaml.load(open(args.config_file).read())

    logger.info("Will deploy cluster {0!r}".format(cluster['name']))
    logger.info("Checking already created clusters")

    for cluster_obj in fuel_rest_api.get_all_clusters(conn):
        if cluster_obj.name == cluster['name']:
            logger.info("Found cluster, will delete it")
            cluster_obj.delete()
            wd = fuel_rest_api.with_timeout(60, "Wait cluster deleted")
            wd(lambda co: not co.check_exists())(cluster_obj)

    new_cluster_obj = create_cluster(conn, cluster)
    templ = 'Cluster ready - navigate to "{0}#cluster/{1}/nodes"'
    logger.info(templ.format(args.fuelurl, new_cluster_obj.id))
Example #10
0
def make_cluster(conn,
                 cluster_desc,
                 deploy_timeout,
                 min_nodes,
                 reuse_cluster_id=None,
                 ignore_task_errors=False):
    if reuse_cluster_id is None:
        for cluster_obj in fuel_rest_api.get_all_clusters(conn):
            if cluster_obj.name == cluster_desc['name']:
                logger.info("Deleting old cluster.... this may takes a while")
                cluster_obj.delete()
                wd = fuel_rest_api.with_timeout(60, "Wait cluster deleted")
                wd(lambda co: not co.check_exists())(cluster_obj)
                break

        logger.info("Start deploying cluster")

        c = deploy_cluster(conn,
                           cluster_desc,
                           deploy_timeout,
                           min_nodes,
                           ignore_task_errors=ignore_task_errors)

        with log_error("!Get list of nodes"):
            nodes = list(c.get_nodes())
            c.nodes = fuel_rest_api.NodeList(nodes)
    else:
        msg = "Will reuse existing cluster with id={0}"
        logger.info(msg.format(reuse_cluster_id))
        with log_error("Reflecting cluster {0}".format(reuse_cluster_id)):
            c = fuel_rest_api.reflect_cluster(conn, reuse_cluster_id)

    try:
        yield c
    finally:
        if reuse_cluster_id is None:
            with log_error("Starts dropping cluster"):
                c.delete()
Example #11
0
def delete_if_exists(conn, name):
    for cluster_obj in fuel_rest_api.get_all_clusters(conn):
        if cluster_obj.name == name:
            cluster_obj.delete()
            wd = fuel_rest_api.with_timeout(60, "Wait cluster deleted")
            wd(lambda co: not co.check_exists())(cluster_obj)
Example #12
0
def delete_if_exists(conn, name):
    for cluster_obj in fuel_rest_api.get_all_clusters(conn):
        if cluster_obj.name == name:
            cluster_obj.delete()
            wd = fuel_rest_api.with_timeout(60, "Wait cluster deleted")
            wd(lambda co: not co.check_exists())(cluster_obj)