예제 #1
0
 def get_active(self):
     master_list = []
     try:
         mm = MasterInstance()
         masters = mm.scan()
         for m in masters:
             if m.status == 'LAUNCH' and m.ipaddr != u'no-ip-yet':
                 master_list.append(m)
     except Exception, e:
         raise
예제 #2
0
 def get_terminated(self):
     master_list = []
     try:
         mm = MasterInstance()
         masters = mm.scan()
         for m in masters:
             if m.status == 'TERMINATE':
                 master_list.append(m)
     except Exception, e:
         raise
예제 #3
0
    def create_or_update_master(self, instanceid, modified, ipaddr, status):
        '''Attempt to retrieve the item update and save it, failing that create it and save it'''
        # no default value for instanceid, has be supplied
        if not instanceid:
            raise
        try:
            r = ddb.MasterInstance.get(instanceid)
            #print "Master entry exists for instanceid %s" % instanceid
            if modified:
                r.modified = modified
            if ipaddr:
                r.ipaddr = unicode(ipaddr)
            if status:
                r.status = unicode(status)
            r.save(raise_on_conflict=True)
        #except ConflictError:  --- add this in later, design saves us from issue for now
        #    # giving a second try to save the data
        #    time.sleep(2)
        #    self.create_or_update_master(instanceid, modified, ipaddr, status)

        except boto.exception.BotoClientError:
            #print "Minion entry does not exist for instanceid %s, creating one." % instanceid
            mm = MasterInstance()
            mm.instanceid = instanceid
            if modified:
                mm.modified = modified
            if ipaddr:
                mm.ipaddr = unicode(ipaddr)
            if status:
                mm.status = unicode(status)
            mm.save()
        except Exception, e:
            print "unhandled exception: %s" % e
            raise