Esempio n. 1
0
 def __init__(self):
     with open('logging.json') as jl:
         dictConfig(json.load(jl))
     logging.info('MachineMidwife: Starting.')
     threading.Thread.__init__(self)
     self.daemon = True
     self.settings = Settings()
     if self.settings.max_instances >= aws.get_max_instances():
         logging.error('maximum instances setting larger than your AWS EC2 capacity, this can lead to an inconsistent state!')
     self.client = redis.Redis('db')
     self.job_pub_sub = self.client.pubsub()
     self.job_pub_sub.subscribe(['jobs'])
     self.apprentice = self.Apprentice(self.client)
Esempio n. 2
0
 def __init__(self):
     with open('logging.json') as jl:
         dictConfig(json.load(jl))
     logging.info('MachineMidwife: Starting.')
     threading.Thread.__init__(self)
     self.daemon = True
     self.settings = Settings()
     if self.settings.max_instances >= aws.get_max_instances():
         logging.error(
             'maximum instances setting larger than your AWS EC2 capacity, this can lead to an inconsistent state!'
         )
     self.client = redis.Redis('db')
     self.job_pub_sub = self.client.pubsub()
     self.job_pub_sub.subscribe(['jobs'])
     self.apprentice = self.Apprentice(self.client)
Esempio n. 3
0
 def choke_full(self):
     """Can we start more instances?"""
     instances = self.waldos()
     count = aws.active_instance_count()
     max_instances = aws.get_max_instances()
     max_storage = aws.get_storage_usage(instances)
     if count is not None and max_instances is not None and count >= max_instances:
         logging.debug('currently using your maximum AWS EC2 capacity (%d/%d)' % (count, max_instances))
         return True
     if len(instances) >= self.settings.max_instances:
         logging.warning('maximum amount of instances in use (%d of %d)' % (len(instances), self.settings.max_instances))
         return True
     if max_storage is not None and max_storage >= self.settings.max_storage:
         logging.warning('maximum amount of storage in use (%d of %d)' % (max_storage, self.settings.max_storage))
         return True
     return False
Esempio n. 4
0
 def choke_full(self):
     """Can we start more instances?"""
     instances = self.waldos()
     count = aws.active_instance_count()
     max_instances = aws.get_max_instances()
     max_storage = aws.get_storage_usage(instances)
     if count is not None and max_instances is not None and count >= max_instances:
         logging.debug(
             'currently using your maximum AWS EC2 capacity (%d/%d)' %
             (count, max_instances))
         return True
     if len(instances) >= self.settings.max_instances:
         logging.warning('maximum amount of instances in use (%d of %d)' %
                         (len(instances), self.settings.max_instances))
         return True
     if max_storage is not None and max_storage >= self.settings.max_storage:
         logging.warning('maximum amount of storage in use (%d of %d)' %
                         (max_storage, self.settings.max_storage))
         return True
     return False