Beispiel #1
0
def split_server(msg):
    if os.path.exists(split_flag_filename):
        print "Not splitting myself again."
        return
    srvid = redis_shell.hget('srvip->srv', ip)
    if not srvid or not redis_shell.zrank(region + ':slices',
                                          srvid):
        print "I was not open, so I won't try to split myself."
        flag_as_done(split_flag_filename)
        return
    for attempt in xrange(7):
        try:
            resp = subprocess.check_output(['curl',
                                            '-i',
                                            '-X', 'POST',
                                            '-H', 'X-Lantern-Auth-Token: ' + auth_token,
                                            'https://config.getiantem.org/split-server'])
            if "Server successfully split" in resp:
                flag_as_done(split_flag_filename)
                send_alarm("Chained proxy split",
                            " split because I " + msg)
                break
            else:
                print "Bad response:"
                print resp
        except:
            traceback.print_exc()
        time.sleep(2 << attempt)
    else:
        send_alarm("Unable to split chained fallback",
                    "I tried to split myself because I %s, but I couldn't." % msg)
Beispiel #2
0
def destroy_vps(name):
    vps_shell(dc_by_name(name)).destroy_vps(name)
    srv = redis_shell.hget('name->srv', name)
    if srv:
        txn = redis_shell.pipeline()
        txn.hdel('name->srv', name)
        txn.hdel('srv->name', srv)
        txn.execute()
Beispiel #3
0
def destroy_vps(name):
    vps_shell(dc_by_name(name)).destroy_vps(name)
    srv = redis_shell.hget('name->srv', name)
    if srv:
        txn = redis_shell.pipeline()
        txn.hdel('name->srv', name)
        txn.hdel('srv->name', srv)
        txn.execute()
Beispiel #4
0
def am_I_closed():
    srv = redis_shell.hget('name->srv', instance_id)
    if srv is None:
        print "I'm retired or a baked in proxy"
        return False
    if redis_shell.zscore(region + ':slices', srv) is not None:
        print "I'm open"
        return False
    print "I'm closed"
    return True
def srv2region(srv):
    return redis_shell.hget('srv->user-region', srv)
def srv2region(srv):
    return redis_shell.hget('srv->user-region', srv)