def compare_servers_to_local(remotepropstuplelist, localstate, stdout, stderr, now=None): if now is None: now = time.time() running_list = [] for (rpt_launch_time, rpt_instance_id, rpt_host, rpt_status) in remotepropstuplelist: rpt_publichost = pubIPextractor(rpt_host) rpt_publichost_s = rpt_publichost or '<no public IP>' if not localstate.has_key(rpt_instance_id): # unknown instance launch_time = parse_iso_time(rpt_launch_time) if now - launch_time < 10*60: print >>stdout, ("Note: Ignoring unknown %s instance %s at %s because it was launched less than 10 minutes ago at %s." % (rpt_status, rpt_instance_id, rpt_publichost_s, rpt_launch_time)) else: print >>stderr, ("Warning: The %s instance %s at %s launched at %s is not in the list of known servers." % (rpt_status, rpt_instance_id, rpt_publichost_s, rpt_launch_time)) if rpt_status == 'running' and rpt_publichost: running_list.append(rpt_publichost) else: # known instance (launch_time, publichost, status) = localstate[rpt_instance_id] if status == 'ignore' or (status == 'not_running' and rpt_status != 'running'): print >>stdout, ("Note: Ignoring %s instance %s at %s launched at %s." % (rpt_status, rpt_instance_id, rpt_publichost_s, rpt_launch_time)) else: if rpt_status == 'running' and rpt_publichost: running_list.append(rpt_publichost) if publichost != rpt_publichost: print >>stderr, ("Warning: The %s instance %s launched at %s changed public IP from %s to %s." % (rpt_status, rpt_instance_id, rpt_launch_time, publichost, rpt_publichost_s)) if launch_time != rpt_launch_time: print >>stderr, ("Warning: The %s instance %s at %s changed launch time from %s to %s (probably restarted)." % (rpt_status, rpt_instance_id, rpt_publichost_s, launch_time, rpt_launch_time)) if status != rpt_status: print >>stderr, ("Warning: The %s instance %s at %s launched at %s was expected to be %s." % (rpt_status, rpt_instance_id, rpt_publichost_s, rpt_launch_time, status)) del localstate[rpt_instance_id] printed_heading = False for key in localstate: (s_launch_time, s_publichost, s_status) = localstate[key] if s_status not in ('ignore', 'not_running'): if not printed_heading: print >>stderr print >>stderr, "The following known servers were not found by the AWS query:" printed_heading = True print >>stderr, ("Instance ID: %s Public IP: %-15s Launch time: %s Expected status: %s" % (key, s_publichost, s_launch_time, s_status)) if printed_heading: print >>stderr return running_list
def notify_servers(remotepropstuplelist): for rpt in remotepropstuplelist: publichost = pubIPextractor(rpt[2]) if not publichost: print >>sys.stderr, ("Warning: Host launched at %s with instance ID %s has no public IP (maybe it has been terminated)." % (rpt[0], rpt[1])) else: print "Notifying %r about gatherer at: %s ..." % (publichost, gatherer_furl) try: register_gatherer(publichost, admin_privkey_path, sys.stdout, sys.stderr, gatherer_type, gatherer_furl) except: traceback.print_exc()
def upgrade_servers(remotepropstuplelist): for rpt in remotepropstuplelist: publichost = pubIPextractor(rpt[2]) if not publichost: print >> sys.stderr, ( "Warning: Host launched at %s with instance ID %s has no public IP (maybe it has been terminated)." % (rpt[0], rpt[1])) else: print "Checking and maybe updating %r..." % (publichost, ) try: update_known_hosts(publichost) except: traceback.print_exc()
def upgrade_servers(remotepropstuplelist): for rpt in remotepropstuplelist: publichost = pubIPextractor(rpt[2]) if not publichost: print >>sys.stderr, ("Warning: Host launched at %s with instance ID %s has no public IP (maybe it has been terminated)." % (rpt[0], rpt[1])) else: print "Upgrading %r..." % (publichost,) try: #set_up_monitors(publichost, monitor_privkey_path, sys.stdout, sys.stderr) #update_packages(publichost, admin_privkey_path, sys.stdout, sys.stderr) update_tahoe(publichost, admin_privkey_path, sys.stdout, sys.stderr, do_update_txaws=False) except: traceback.print_exc()
def upgrade_servers(remote_properties): for rpt in remote_properties: publichost = pubIPextractor(rpt[2]) if not publichost: print >> sys.stderr, ( "Warning: Host launched at %s with instance ID %s has no public IP (maybe it has been terminated)." % (rpt[0], rpt[1]) ) else: print "Checking and maybe updating %r..." % (publichost,) try: update_known_hosts(publichost) except: traceback.print_exc()
def notify_servers(remotepropstuplelist): for rpt in remotepropstuplelist: publichost = pubIPextractor(rpt[2]) if not publichost: print >> sys.stderr, ( "Warning: Host launched at %s with instance ID %s has no public IP (maybe it has been terminated)." % (rpt[0], rpt[1])) else: print "Notifying %r about gatherer at: %s ..." % (publichost, gatherer_furl) try: register_gatherer(publichost, admin_privkey_path, sys.stdout, sys.stderr, gatherer_type, gatherer_furl) except: traceback.print_exc()
def upgrade_servers(remotepropstuplelist): for rpt in remotepropstuplelist: publichost = pubIPextractor(rpt[2]) if not publichost: print >> sys.stderr, ( "Warning: Host launched at %s with instance ID %s has no public IP (maybe it has been terminated)." % (rpt[0], rpt[1])) else: print "Upgrading %r..." % (publichost, ) try: #set_up_monitors(publichost, monitor_privkey_path, sys.stdout, sys.stderr) #update_packages(publichost, admin_privkey_path, sys.stdout, sys.stderr) update_tahoe(publichost, admin_privkey_path, sys.stdout, sys.stderr, do_update_txaws=False) except: traceback.print_exc()
def compare_servers_to_local(remotepropstuplelist, localstate, stdout, stderr, now=None): if now is None: now = time.time() running_list = [] for (rpt_launch_time, rpt_instance_id, rpt_host, rpt_status) in remotepropstuplelist: rpt_publichost = pubIPextractor(rpt_host) rpt_publichost_s = rpt_publichost or '<no public IP>' if not localstate.has_key(rpt_instance_id): # unknown instance launch_time = parse_iso_time(rpt_launch_time) if now - launch_time < 10 * 60: print >> stdout, ( "Note: Ignoring unknown %s instance %s at %s because it was launched less than 10 minutes ago at %s." % (rpt_status, rpt_instance_id, rpt_publichost_s, rpt_launch_time)) elif rpt_status == 'terminated': print >> stdout, ( "Note: Ignoring %s instance %s at %s launched at %s." % (rpt_status, rpt_instance_id, rpt_publichost_s, rpt_launch_time)) else: print >> stderr, ( "Warning: The %s instance %s at %s launched at %s is not in the list of known servers." % (rpt_status, rpt_instance_id, rpt_publichost_s, rpt_launch_time)) if rpt_status == 'running' and rpt_publichost: running_list.append(rpt_publichost) else: # known instance (launch_time, publichost, status) = localstate[rpt_instance_id] if status == 'ignore' or (status == 'not_running' and rpt_status != 'running'): print >> stdout, ( "Note: Ignoring %s instance %s at %s launched at %s." % (rpt_status, rpt_instance_id, rpt_publichost_s, rpt_launch_time)) else: if rpt_status == 'running' and rpt_publichost: running_list.append(rpt_publichost) if publichost != rpt_publichost: print >> stderr, ( "Warning: The %s instance %s launched at %s changed public IP from %s to %s." % (rpt_status, rpt_instance_id, rpt_launch_time, publichost, rpt_publichost_s)) if launch_time != rpt_launch_time: print >> stderr, ( "Warning: The %s instance %s at %s changed launch time from %s to %s (probably restarted)." % (rpt_status, rpt_instance_id, rpt_publichost_s, launch_time, rpt_launch_time)) if status != rpt_status: print >> stderr, ( "Warning: The %s instance %s at %s launched at %s was expected to be %s." % (rpt_status, rpt_instance_id, rpt_publichost_s, rpt_launch_time, status)) del localstate[rpt_instance_id] printed_heading = False for key in localstate: (s_launch_time, s_publichost, s_status) = localstate[key] if s_status not in ('ignore', 'not_running'): if not printed_heading: print >> stderr print >> stderr, "The following known servers were not found by the AWS query:" printed_heading = True print >> stderr, ( "Instance ID: %s Public IP: %-15s Launch time: %s Expected status: %s" % (key, s_publichost, s_launch_time, s_status)) if printed_heading: print >> stderr return running_list
def write_serverinfo(pathtoserverinfo, remotepropstuplelist): serverinfofp = FilePath(pathtoserverinfo) serverinfofp.setContent("") for rpt in remotepropstuplelist: append_record(serverinfofp, rpt[0], rpt[1], pubIPextractor(rpt[2]))
def list_public_hosts(remotepropstuplelist): for rpt in remotepropstuplelist: publichost = pubIPextractor(rpt[2]) if publichost: print publichost