def stop_commands_on_host(cohs): groups = CoHManager.setCoHsStateStopped(cohs) session = sqlalchemy.orm.create_session() for cmd_id, count in groups.items(): cmd = session.query(Commands).get(cmd_id) # update stats cmd.sum_running -= count cmd.sum_stopped += count session.add(cmd) session.close()
def stop_commands_on_host(cohs): groups = CoHManager.setCoHsStateStopped(cohs) session = sqlalchemy.orm.create_session() for cmd_id, count in groups.items(): cmd = session.query(Commands).get(cmd_id) # update stats cmd.sum_running -= count cmd.sum_stopped += count session.add(cmd) session.close()
def process_non_valid(scheduler_name, non_fatal_steps, ids_to_exclude=[]): # Mutable list ids_to_exclude used as default argument to a method or function database = MscDatabase() session = create_session() now = time.strftime("%Y-%m-%d %H:%M:%S") commands_query = session.query(CommandsOnHost).\ select_from(database.commands_on_host.join(database.commands) ).filter(not_(database.commands_on_host.c.current_state.in_(("failed", "over_timed", "done"))) ).filter(database.commands.c.end_date < now ).filter(or_(database.commands_on_host.c.scheduler == '', database.commands_on_host.c.scheduler == scheduler_name, database.commands_on_host.c.scheduler == None)) #commands_query = commands_query.limit(top) if len(ids_to_exclude) > 0: commands_query = commands_query.filter( not_(database.commands_on_host.c.id.in_(ids_to_exclude))) fls = [] otd = [] for q in commands_query.all(): if any_failed(q.id, non_fatal_steps) or q.attempts_failed > 0: fls.append(q.id) else: otd.append(q.id) #yield q.id session.close() if len(otd) > 0: logging.getLogger().info("Switching %d circuits to overtimed" % len(otd)) CoHManager.setCoHsStateOverTimed(otd) if len(fls) > 0: logging.getLogger().info("Switching %d circuits to failed" % len(fls)) CoHManager.setCoHsStateFailed(fls)
def process_non_valid(scheduler_name, non_fatal_steps, ids_to_exclude = []): # Mutable list ids_to_exclude used as default argument to a method or function database = MscDatabase() session = create_session() now = time.strftime("%Y-%m-%d %H:%M:%S") commands_query = session.query(CommandsOnHost).\ select_from(database.commands_on_host.join(database.commands) ).filter(not_(database.commands_on_host.c.current_state.in_(("failed", "over_timed", "done"))) ).filter(database.commands.c.end_date < now ).filter(or_(database.commands_on_host.c.scheduler == '', database.commands_on_host.c.scheduler == scheduler_name, database.commands_on_host.c.scheduler == None)) #commands_query = commands_query.limit(top) if len(ids_to_exclude) > 0 : commands_query = commands_query.filter(not_(database.commands_on_host.c.id.in_(ids_to_exclude))) fls = [] otd = [] for q in commands_query.all(): if any_failed(q.id, non_fatal_steps) or q.attempts_failed > 0 : fls.append(q.id) else : otd.append(q.id) #yield q.id session.close() if len(otd) > 0 : logging.getLogger().info("Switching %d circuits to overtimed" % len(otd)) CoHManager.setCoHsStateOverTimed(otd) if len(fls) > 0 : logging.getLogger().info("Switching %d circuits to failed" % len(fls)) CoHManager.setCoHsStateFailed(fls)
def switch_commands_to_start(cohs): CoHManager.setCoHsStateScheduled(cohs)
def switch_commands_to_stop(cohs): CoHManager.setCoHsStateStopped(cohs)
def switch_commands_to_start(cohs): CoHManager.setCoHsStateScheduled(cohs)
def switch_commands_to_stop(cohs): CoHManager.setCoHsStateStopped(cohs)