def upload_cfg(redis_shell, dc, access_data): ip = access_data['addr'].split(':')[0] # DRY: flashlight/genconfig/cloud.yaml.tmpl access_data.update(pipeline=True, trusted=True, qos=10, weight=1000000) redis_shell.rpush( dc + ":srvq", "%s|\n %s" % (ip, yaml.dump({'fallback-' + ip: access_data})))
def upload_cfg(redis_shell, dc, access_data): ip = access_data['addr'].split(':')[0] # DRY: flashlight/genconfig/cloud.yaml.tmpl access_data.update(pipeline=True, trusted=True, qos=10, weight=1000000) redis_shell.rpush(dc + ":srvq", "%s|\n %s" % (ip, yaml.dump({'fallback-' + ip: access_data})))
def destroy_until_dc(srvq, dc): """ Pop proxies off the server queue, retire them and destroy them, until we hit one with the desired DC. This is used when we want to quickly start serving a user region from a specific datacenter. """ while True: entry = redis_shell.rpop(srvq) ip, name, cfg = entry.split('|') print "popping", name next_dc = dc_by_name(name) if next_dc == dc: print "pushing back", name redis_shell.rpush(srvq, entry) return retire_proxy(name=name, ip=ip, reason="Flushing server queue")
def register_vps(redis_shell, dc, name): print "Registering VPS", name redis_shell.rpush(dc + ':vpss', name) redis_shell.incr(dc + ':vpss:version')
def register_vps(name): print "Registering VPS", name redis_shell.rpush(CM + ':vpss', name) redis_shell.incr(CM + ':vpss:version')