def __init__(self): self.secret = os.environ.get('_abaco_secret') self.ch = ClientsChannel() self.credentials = {} for tenant in get_tenants(): self.credentials[tenant] = {'username': os.environ.get('_abaco_{}_username'.format(tenant), ''), 'password': os.environ.get('_abaco_{}_password'.format(tenant), '')}
def main(): logger.info("Running abaco health checks. Now: {}".format(time.time())) # TODO - turning off the check_spawners call in the health process for now as there seem to be some issues. # the way the check works currently is to look for a spawner with a specific name. However, that check does not # appear to be working currently. # check_spawners() try: clean_up_ipc_dirs() except Exception as e: logger.error("Got exception from clean_up_ipc_dirs: {}".format(e)) try: ttl = Config.get('workers', 'worker_ttl') except Exception as e: logger.error( "Could not get worker_ttl config. Exception: {}".format(e)) try: ttl = int(ttl) except Exception as e: logger.error("Invalid ttl config: {}. Setting to -1.".format(e)) ttl = -1 ids = get_actor_ids() logger.info("Found {} actor(s). Now checking status.".format(len(ids))) for aid in ids: # manage_workers(id) check_workers(aid, ttl) tenants = get_tenants() for t in tenants: logger.debug( "health process cleaning up apim_clients for tenant: {}".format(t)) clean_up_apim_clients(t)
def check_common(self, cmd): # validate the secret if not cmd.get('secret') == self.secret: return False, 'Invalid secret.' # validate tenant if not cmd.get('tenant') in get_tenants(): return False, 'Invalid client passed: {}'.format(cmd.get('tenant')) return True, ''
def check_common(self, cmd): """Common check for new and delete client requests.""" # validate the secret if not cmd.get('secret') == self.secret: m = 'Invalid secret.' logger.error(m) return False, m # validate tenant if not cmd.get('tenant') in get_tenants(): m = 'Invalid client passed: {}'.format(cmd.get('tenant')) logger.error(m) return False, m logger.debug("common params were valid.") return True, ''
def __init__(self): self.secret = os.environ.get('_abaco_secret') ready = False i = 0 while not ready: try: self.ch = ClientsChannel() ready = True except RuntimeError as e: i = i + 1 if i > 10: raise e self.credentials = {} for tenant in get_tenants(): self.credentials[tenant] = { 'username': os.environ.get('_abaco_{}_username'.format(tenant), ''), 'password': os.environ.get('_abaco_{}_password'.format(tenant), '') }