Example #1
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 #2
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()
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 #4
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 #5
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 #6
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 #7
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 #8
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)