예제 #1
0
    def test_compare_servers_to_local_mismatchdata(self):
        LOCINSTANCEID = 'i-aaaaaaaa'
        LOCSTARTTIME  = '2012-01-01T01:01:01.000Z'
        LOCPUBIP = '0.0.0.0'
        LOCSTATE = 'running'
        LOCALSTATEDICT = {LOCINSTANCEID : (LOCSTARTTIME, LOCPUBIP, LOCSTATE)}

        INSTANCEID = LOCINSTANCEID
        STARTTIME = LOCSTARTTIME
        DIFFPUBDNSNAME = 'ec2-0-0-0-1.c'
        STATE = 'stopped'
        REMOTEPROPTUPLIST = [(STARTTIME, INSTANCEID, DIFFPUBDNSNAME, STATE)]
        monitor.compare_servers_to_local(REMOTEPROPTUPLIST, LOCALSTATEDICT, self.STDOUT, self.STDERR)
예제 #2
0
    def test_compare_servers_to_local_success(self):
        LOCINSTANCEID = 'i-aaaaaaaa'
        LOCSTARTTIME  = '2012-01-01T00:00:00.000Z'
        LOCPUBIP = '0.0.0.0'
        LOCSTATE = 'running'
        LOCALSTATEDICT = {LOCINSTANCEID : (LOCSTARTTIME, LOCPUBIP, LOCSTATE)}

        INSTANCEID = LOCINSTANCEID
        STARTTIME = LOCSTARTTIME
        PUBDNSNAME = 'ec2-0-0-0-0.c'
        STATE = 'running'
        REMOTEPROPTUPLIST = [(STARTTIME, INSTANCEID, PUBDNSNAME, STATE)]
        monitor.compare_servers_to_local(REMOTEPROPTUPLIST, LOCALSTATEDICT, self.STDOUT, self.STDERR)
예제 #3
0
    def test_compare_servers_to_local_mismatchdata(self):
        LOCINSTANCEID = 'i-aaaaaaaa'
        LOCSTARTTIME = '2012-01-01T01:01:01.000Z'
        LOCPUBIP = '0.0.0.0'
        LOCSTATE = 'running'
        LOCALSTATEDICT = {LOCINSTANCEID: (LOCSTARTTIME, LOCPUBIP, LOCSTATE)}

        INSTANCEID = LOCINSTANCEID
        STARTTIME = LOCSTARTTIME
        DIFFPUBDNSNAME = 'ec2-0-0-0-1.c'
        STATE = 'stopped'
        REMOTEPROPTUPLIST = [(STARTTIME, INSTANCEID, DIFFPUBDNSNAME, STATE)]
        monitor.compare_servers_to_local(REMOTEPROPTUPLIST, LOCALSTATEDICT,
                                         self.STDOUT, self.STDERR)
예제 #4
0
    def test_compare_servers_to_local_success(self):
        LOCINSTANCEID = 'i-aaaaaaaa'
        LOCSTARTTIME = '2112-01-01T00:00:00.000Z'
        LOCPUBIP = '0.0.0.0'
        LOCSTATE = 'running'
        LOCALSTATEDICT = {LOCINSTANCEID: (LOCSTARTTIME, LOCPUBIP, LOCSTATE)}

        INSTANCEID = LOCINSTANCEID
        STARTTIME = LOCSTARTTIME
        PUBDNSNAME = 'ec2-0-0-0-0.c'
        STATE = 'running'
        REMOTEPROPTUPLIST = [(STARTTIME, INSTANCEID, PUBDNSNAME, STATE)]
        monitor.compare_servers_to_local(REMOTEPROPTUPLIST, LOCALSTATEDICT,
                                         self.STDOUT, self.STDERR)
예제 #5
0
    def test_compare_servers_to_local_missingremoteinstance(self):
        LOCINSTANCEID = 'i-'+'a'*8
        LOCSTARTTIME  = '2012-01-01T00:00:00.000Z'
        LOCPUBIP = '0.0.0.0'
        LOCSTATE = 'running'
        LOCINSTANCEID2 = 'i-'+'b'*8
        LOCSTARTTIME2 = '2012-01-01T01:00:00.000Z'
        LOCPUBIP2 = '3.3.3.3'
        LOCSTATE2 = 'running'
        LOCALSTATEDICT = {LOCINSTANCEID : (LOCSTARTTIME, LOCPUBIP, LOCSTATE),
                          LOCINSTANCEID2 : (LOCSTARTTIME2, LOCPUBIP2, LOCSTATE2)}

        INSTANCEID = LOCINSTANCEID
        STARTTIME = LOCSTARTTIME
        PUBDNSNAME = 'ec2-0-0-0-0.c'
        STATE = 'running'

        REMOTEPROPTUPLIST = [(STARTTIME, INSTANCEID, PUBDNSNAME, STATE)]
        monitor.compare_servers_to_local(REMOTEPROPTUPLIST, LOCALSTATEDICT, self.STDOUT, self.STDERR)
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
    def test_compare_servers_to_local_unexpectedinstance(self):
        LOCINSTANCEID = 'i-'+'a'*8
        LOCSTARTTIME  = '2112-01-01T00:00:00.000Z'
        LOCPUBIP = '0.0.0.0'
        LOCSTATE = 'running'
        LOCALSTATEDICT = {LOCINSTANCEID : (LOCSTARTTIME, LOCPUBIP, LOCSTATE)}

        INSTANCEID = LOCINSTANCEID
        STARTTIME = LOCSTARTTIME
        PUBDNSNAME = 'ec2-0-0-0-0.c'
        STATE = 'running'

        INSTANCEID2 = 'i-'+'b'*8
        STARTTIME2 = '2112-01-01T01:00:00.000Z'
        PUBDNSNAME2 = 'ec2-2-2-2-2.c'
        STATE2 = 'running'
        REMOTEPROPTUPLIST = [(STARTTIME, INSTANCEID, PUBDNSNAME, STATE),
                             (STARTTIME2, INSTANCEID2, PUBDNSNAME2, STATE2)]
        monitor.compare_servers_to_local(REMOTEPROPTUPLIST, LOCALSTATEDICT, self.STDOUT, self.STDERR)
예제 #8
0
    def test_compare_servers_to_local_unexpectedinstance(self):
        LOCINSTANCEID = 'i-' + 'a' * 8
        LOCSTARTTIME = '2112-01-01T00:00:00.000Z'
        LOCPUBIP = '0.0.0.0'
        LOCSTATE = 'running'
        LOCALSTATEDICT = {LOCINSTANCEID: (LOCSTARTTIME, LOCPUBIP, LOCSTATE)}

        INSTANCEID = LOCINSTANCEID
        STARTTIME = LOCSTARTTIME
        PUBDNSNAME = 'ec2-0-0-0-0.c'
        STATE = 'running'

        INSTANCEID2 = 'i-' + 'b' * 8
        STARTTIME2 = '2112-01-01T01:00:00.000Z'
        PUBDNSNAME2 = 'ec2-2-2-2-2.c'
        STATE2 = 'running'
        REMOTEPROPTUPLIST = [(STARTTIME, INSTANCEID, PUBDNSNAME, STATE),
                             (STARTTIME2, INSTANCEID2, PUBDNSNAME2, STATE2)]
        monitor.compare_servers_to_local(REMOTEPROPTUPLIST, LOCALSTATEDICT,
                                         self.STDOUT, self.STDERR)
예제 #9
0
lasterrors = None
lasterrorsfp = FilePath(lasterrorspath)
if lasterrorsfp.exists():
    lasterrors = lasterrorsfp.getContent()

POLL_TIME = 10
ADDRESS_WAIT_TIME = 60

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, sys.stdout, stderr))

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


def cb(x):
    if isinstance(x, Failure):
        print >> stderr, str(x)
        if hasattr(x.value, 'response'):
            print >> stderr, x.value.response

    errors = stderr.getvalue()
    print >> sys.stderr, errors
    if errors != lasterrors:
        d2 = send_monitoring_report(errors)
    (launch_time, instance_id, publichost, status) = propertytuple
    localstate[instance_id] = (launch_time, publichost, status)

lasterrors = None
lasterrorsfp = FilePath(lasterrorspath)
if lasterrorsfp.exists():
    lasterrors = lasterrorsfp.getContent()

POLL_TIME = 10
ADDRESS_WAIT_TIME = 60

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, sys.stdout, stderr))

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

def cb(x):
    if isinstance(x, Failure):
        print >>stderr, str(x)
        if hasattr(x.value, 'response'):
            print >>stderr, x.value.response

    errors = stderr.getvalue()
    print >>sys.stderr, errors
    if errors != lasterrors:
        d2 = send_monitoring_report(errors)
        def _sent(ign):
            lasterrorsfp.setContent(errors)