def checker(stdout, stderr):
    d = wait_for_EC2_properties(ec2accesskeyid, ec2secretkey, endpoint_uri,
                                ServerInfoParser(('launchTime', 'instanceId'), ('dnsName', 'instanceState.name')),
                                POLL_TIME, ADDRESS_WAIT_TIME, sys.stdout, stderr)

    d.addCallback(lambda remoteproperties: compare_servers_to_local(remoteproperties, localstate, stdout, stderr))

    d.addCallback(lambda host_list: check_servers(host_list, monitor_privkey_path, stdout, stderr))

    return d
Пример #2
0
def wait_for_EC2_addresses(ec2accesskeyid, ec2secretkey, endpoint_uri, stdout, stderr,
                           *instance_ids):
    return wait_for_EC2_properties(ec2accesskeyid, ec2secretkey, endpoint_uri, AddressParser(),
                                   POLL_TIME, ADDRESS_WAIT_TIME, stdout, stderr, *instance_ids)
endpoint_uri = 'https://ec2.us-east-1.amazonaws.com/'
config = Config()

ec2secretpath = '../secret_config/ec2secret'
ec2accesskeyid = str(config.other['ec2_access_key_id'])
ec2secretkey = FilePath(ec2secretpath).getContent().strip()

monitor_privkey_path = str(config.other['monitor_privkey_path'])
admin_privkey_path = str(config.other['admin_privkey_path'])

POLL_TIME = 10
ADDRESS_WAIT_TIME = 60

d = wait_for_EC2_properties(
    ec2accesskeyid, ec2secretkey, endpoint_uri,
    ServerInfoParser(('launchTime', 'instanceId'), ('dnsName', )), POLL_TIME,
    ADDRESS_WAIT_TIME, sys.stdout, sys.stderr)


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)
endpoint_uri = 'https://ec2.us-east-1.amazonaws.com/'
config = Config()

ec2secretpath='../secret_config/ec2secret'
ec2accesskeyid = str(config.other['ec2_access_key_id'])
ec2secretkey = FilePath(ec2secretpath).getContent().strip()

monitor_privkey_path = str(config.other['monitor_privkey_path'])
admin_privkey_path = str(config.other['admin_privkey_path'])


POLL_TIME = 10
ADDRESS_WAIT_TIME = 60

d = wait_for_EC2_properties(ec2accesskeyid, ec2secretkey, endpoint_uri,
                            ServerInfoParser(('launchTime', 'instanceId'), ('dnsName',)),
                            POLL_TIME, ADDRESS_WAIT_TIME, sys.stdout, sys.stderr)

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:
ssec2_secret = FilePath(ssec2_secret_path).getContent().strip()
ssec2_accesskeyid = FilePath(ssec2_accesskeyid_path).getContent().strip()

monitor_privkey_path = str(config.other["monitor_privkey_path"])
admin_privkey_path = str(config.other["ssec2admin_privkey_path"])


POLL_TIME = 10
ADDRESS_WAIT_TIME = 60

d = wait_for_EC2_properties(
    ssec2_accesskeyid,
    ssec2_secret,
    endpoint_uri,
    ServerInfoParser(("launchTime", "instanceId"), ("dnsName",)),
    POLL_TIME,
    ADDRESS_WAIT_TIME,
    sys.stdout,
    sys.stderr,
)


def update_known_hosts(publichost):
    arg_list = [
        "ssh",
        "-o",
        "HostKeyAlgorithms=ssh-rsa",
        "-o",
        "StrictHostKeyChecking=no",
        "-i",
        monitor_privkey_path,