def run(): region = vps_util.my_region() print "Starting offload server for region %s." % region qname = region + ":offloadq" q = redisq.Queue(qname, redis_shell, TIMEOUT) while True: task, remover = q.next_job() if task: name, ip = task.split('|') print "Offloading users from %s (%s)" % (name, ip) txn = redis_shell.pipeline() vps_util.actually_offload_proxy(name, ip, pipeline=txn) remover(txn) cm = vps_util.cm_by_name(name) txn.lpush(cm + ':retireq', task) txn.execute() else: time.sleep(10)
def retire_ips(*ips): nip = names_by_ip() pairs = [] ips = list(set(ips)) wnames = filter(nip.get, ips) if len(wnames) != len(ips): print "Some IPs don't have names to them:" for ip in set(ips) - set(wnames): print " ", ip if raw_input("Do you want to retire all others? (y/N): ") != 'y': return ips_by_cm = {} for ip in wnames: ips_by_cm.setdefault(vps_util.cm_by_name(nip[ip]), []).append(ip) for cm, ips in ips_by_cm.iteritems(): entries = ["%s|%s" % (nip[ip], ip) for ip in ips] print "The following entries will be retired for cloudmaster " + cm for s in entries: print " ", s if raw_input("OK to retire? (y/N) ") == "y": r().lpush(cm + ':retireq', *entries)
def run(): region = vps_util.my_region() print "Starting offload server for region %s." % region qname = region + ":offloadq" q = redisq.Queue(qname, redis_shell, TIMEOUT) while True: task, remover = q.next_job() if task: name, ip = task.split('|') print "Offloading users from %s (%s)" % (name, ip) txn = redis_shell.pipeline() try: vps_util.actually_offload_proxy(name, ip, pipeline=txn) except vps_util.ProxyGone: print >> sys.stderr, "Tried to offload no longer existing proxy %s (%s)" % ( name, ip) remover(redis_shell) continue remover(txn) cm = vps_util.cm_by_name(name) txn.lpush(cm + ':retireq', task) txn.execute() else: time.sleep(10)
def in_production(name): return (not name.startswith('fp-') or vps_util.cm_by_name(name) in ['doams3', 'dosgp1'])