예제 #1
0
def setup_env(args):
    """Setup environment"""
    print("Loading configuration for synnefo...")

    conf = Conf(args)
    env.env = Env(conf)

    env.local = args.autoconf
    env.key_inject = args.key_inject
    env.password = env.env.password
    env.user = env.env.user
    env.shell = "/bin/bash -c"
    env.key_filename = args.ssh_key

    if args.disable_colors:
        disable_color()

    if env.env.cms.hostname in \
            [env.env.accounts.hostname, env.env.cyclades.hostname,
             env.env.pithos.hostname]:
        env.cms_pass = True
    else:
        env.cms_pass = False

    if env.env.accounts.hostname in \
            [env.env.cyclades.hostname, env.env.pithos.hostname]:
        env.csrf_disable = True
    else:
        env.csrf_disable = False

    env.roledefs = {
        "nodes": env.env.ips,
        "ips": env.env.ips,
        "accounts": [env.env.accounts.ip],
        "cyclades": [env.env.cyclades.ip],
        "pithos": [env.env.pithos.ip],
        "cms": [env.env.cms.ip],
        "mq": [env.env.mq.ip],
        "db": [env.env.db.ip],
        "mq": [env.env.mq.ip],
        "db": [env.env.db.ip],
        "ns": [env.env.ns.ip],
        "client": [env.env.client.ip],
        "router": [env.env.router.ip],
        "stats": [env.env.stats.ip],
    }

    env.enable_lvm = False
    env.enable_drbd = False
    if ast.literal_eval(env.env.create_extra_disk) and env.env.extra_disk:
        env.enable_lvm = True
        env.enable_drbd = True

    env.roledefs.update({
        "ganeti": env.env.cluster_ips,
        "master": [env.env.master.ip],
    })
예제 #2
0
def main():
    args = parse_options()

    conf = Conf(args)
    env = Env(conf)

    create_dir(env.run, False)
    create_dir(env.dns, False)

    # Check if there are keys to use
    if args.command == "keygen":
        if must_create_keys(args.force, env):
            do_create_keys(args, env)
            return 0
        else:
            print "Keys already existed.. aborting"
            return 1
    else:
        if (args.key_inject and (args.ssh_key is None)
                and must_create_keys(False, env)):
            print "No ssh keys to use. Run `snf-deploy keygen' first."
            return 1

    if args.command == "test":
        conf.print_config()

    if args.command == "cleanup":
        cleanup(args, env)

    if args.command == "packages":
        create_dir(env.packages, True)
        get_packages(args, env)

    if args.command == "vcluster":
        image(args, env)
        network(args, env)
        create_dnsmasq_files(args, env)
        dnsmasq(args, env)
        cluster(args, env)

    if args.command == "prepare":
        actions = get_actions("prepare")
        fabcommand(args, env, actions)

    if args.command == "synnefo":
        actions = get_actions("synnefo")
        fabcommand(args, env, actions)

    if args.command == "backend":
        actions = get_actions("backend")
        fabcommand(args, env, actions)

    if args.command == "ganeti":
        actions = get_actions("ganeti")
        fabcommand(args, env, actions)

    if args.command == "all":
        actions = get_actions("prepare", "synnefo", "backend")
        fabcommand(args, env, actions)

    if args.command == "add":
        if args.cluster_node:
            add_node(args, env)
        else:
            actions = get_actions("backend")
            fabcommand(args, env, actions)

    if args.command == "run":
        if not args.actions:
            print_available_actions(args.command)
        else:
            fabcommand(args, env, args.actions)
예제 #3
0
def main():
    args = parse_options()

    conf = Conf(args)
    env = Env(conf)

    create_dir(env.run, False)
    create_dir(env.dns, False)

    # Check if there are keys to use
    if args.command == "keygen":
        if must_create_keys(args.force, env):
            do_create_keys(args, env)
            return 0
        else:
            print "Keys already existed.. aborting"
            return 1
    else:
        if (args.key_inject and (args.ssh_key is None)
                and must_create_keys(False, env)):
            print "No ssh keys to use. Run `snf-deploy keygen' first."
            return 1

    if args.command == "test":
        conf.print_config()

    if args.command == "cleanup":
        cleanup(args, env)

    if args.command == "packages":
        create_dir(env.packages, True)
        get_packages(args, env)

    if args.command == "vcluster":
        image(args, env)
        network(args, env)
        create_dnsmasq_files(args, env)
        dnsmasq(args, env)
        cluster(args, env)

    if args.command == "prepare":
        actions = get_actions("prepare")
        fabcommand(args, env, actions)

    if args.command == "synnefo":
        actions = get_actions("synnefo")
        fabcommand(args, env, actions)

    if args.command == "backend":
        actions = get_actions("backend")
        fabcommand(args, env, actions)

    if args.command == "ganeti":
        actions = get_actions("ganeti")
        fabcommand(args, env, actions)

    if args.command == "all":
        actions = get_actions("prepare", "synnefo", "backend")
        fabcommand(args, env, actions)

    if args.command == "add":
        if args.cluster_node:
            add_node(args, env)
        else:
            actions = get_actions("backend")
            fabcommand(args, env, actions)

    if args.command == "run":
        if not args.actions:
            print_available_actions(args.command)
        else:
            fabcommand(args, env, args.actions)
예제 #4
0
파일: fabfile.py 프로젝트: vkoukis/synnefo
def setup_env(
    confdir="conf",
    packages="packages",
    templates="files",
    cluster_name="ganeti1",
    autoconf=False,
    disable_colors=False,
    key_inject=False,
):
    """Setup environment"""
    print("Loading configuration for synnefo...")
    print(" * Using config files under %s..." % confdir)
    print(" * Using %s and %s for packages and templates accordingly..." % (packages, templates))

    autoconf = ast.literal_eval(autoconf)
    disable_colors = ast.literal_eval(disable_colors)
    env.key_inject = ast.literal_eval(key_inject)
    conf = Conf.configure(confdir=confdir, cluster_name=cluster_name, autoconf=autoconf)
    env.env = Env(conf)

    env.local = autoconf
    env.password = env.env.password
    env.user = env.env.user
    env.shell = "/bin/bash -c"

    if disable_colors:
        disable_color()

    if env.env.cms.hostname in [env.env.accounts.hostname, env.env.cyclades.hostname, env.env.pithos.hostname]:
        env.cms_pass = True
    else:
        env.cms_pass = False

    if env.env.accounts.hostname in [env.env.cyclades.hostname, env.env.pithos.hostname]:
        env.csrf_disable = True
    else:
        env.csrf_disable = False

    env.roledefs = {
        "nodes": env.env.ips,
        "ips": env.env.ips,
        "accounts": [env.env.accounts.ip],
        "cyclades": [env.env.cyclades.ip],
        "pithos": [env.env.pithos.ip],
        "cms": [env.env.cms.ip],
        "mq": [env.env.mq.ip],
        "db": [env.env.db.ip],
        "mq": [env.env.mq.ip],
        "db": [env.env.db.ip],
        "ns": [env.env.ns.ip],
        "client": [env.env.client.ip],
        "router": [env.env.router.ip],
    }

    env.enable_lvm = False
    env.enable_drbd = False
    if ast.literal_eval(env.env.create_extra_disk) and env.env.extra_disk:
        env.enable_lvm = True
        env.enable_drbd = True

    env.roledefs.update({"ganeti": env.env.cluster_ips, "master": [env.env.master.ip]})