Esempio n. 1
0
def swift_restart():
    global running_hosts

    while not rexists("/etc/swift/swift.conf"):
        log_info("Still need swift.conf...")
        sleep(2)
    while not rexists("/etc/swift/account.ring.gz"):
        log_info("Still need account.ring.gz...")
        sleep(2)
    while not rexists("/etc/swift/container.ring.gz"):
        log_info("Still need container.ring.gz...")
        sleep(2)
    while not rexists("/etc/swift/object.ring.gz"):
        log_info("Still need object.ring.gz...")
        sleep(2)

    run("swift-init stop all; true")
    run("swift-init start all; true")

    log_success("Restarted!")
    running_hosts.value += 1

    while running_hosts.value < len(env.hosts):
        log_info("%d/%d hosts running" % (running_hosts.value, len(env.hosts)))
        sleep(1)
Esempio n. 2
0
def upload_proxy_config():
    if not current_role('proxy'):
        return
    address = get_address(env.host, private=True)

    # Upload proxy configs

    if not rexists("/etc/swift/swift.conf"):
        # Generate a secure secret server-side
        log_info("Not swift.conf found, generating ring!")
        hash_prefix = local("od -t x4 -N 8 -A n </dev/random"
                            "| sed -e 's/ //g'", capture=True)
    else:
        hash_prefix = run("grep swift_hash_path_suffix /etc/swift/swift.conf "
                          "| sed -e 's/.*=[[:space:]]*//'")

    swift_sync_key = hash_prefix
    super_admin_key = hash_prefix

    upload_template("config/dispersion.conf", "/etc/swift/dispersion.conf",
                    {'private_address': address}, backup=False)
    upload_template("config/proxy-server.conf", "/etc/swift/proxy-server.conf",
                    {'private_address': address,
                     'host': env.host,
                     'swift_sync_key': swift_sync_key,
                     'super_admin_key': super_admin_key,
                     'host_prefix': env.host_prefix,
                     'host_short': get_short_name(env.host)}, backup=False)
    upload_template("config/swift.conf", "/etc/swift/swift.conf",
                    {'hash_prefix': hash_prefix}, backup=False)
    prefix = ''
    if current_profile() == 'freebsd':
        prefix = '/usr/local'
    upload_template("config/rsyslog.conf", "{prefix}/etc/rsyslog.conf".format(
        prefix=prefix), backup=False)
Esempio n. 3
0
def cluster_prep(name=None):
    run("hostname %s" % (env.host_string))
    run("cp -f /usr/share/zoneinfo/America/Chicago /etc/localtime")
    run("cp -f /etc/motd /etc/motd.bak")
    run("echo '' > /etc/motd")

    if rexists("/etc/rc.conf"):
        sed('/etc/rc.conf', '^hostname=.*$', 'hostname="%s"' %
            (env.host_string))
    elif rexists("/etc/hostname"):
        run("echo '' > /etc/hostname")
        append("/etc/hostname", env.host_string)

    zshrc = "config/%s/.zshrc" % name
    if exists(zshrc) and rexists("/usr/local/bin/zsh"):
        put(zshrc, "~")
        run("chsh -s /usr/local/bin/zsh")
Esempio n. 4
0
def create_datadisks(disk=None, command=None):
    if not disk or not command:
        return
    if not rexists(disk):
        run(command)