def get_gates(): try: service_list = OrderedDict() env_list = dict() now = Delorean.now() today_holiday = blueprint.mongo.get_today_holiday() for group in blueprint.mongo.get_groups(): env_list[group] = set() service_list[group] = dict() for service_name in blueprint.mongo.get_services_in_group(group): service = blueprint.mongo.get_gate(group, service_name) for env in service['environments']: env_list[group].add(env) if service['environments'][env]['state_timestamp']: service['environments'][env]['state_age'] = ( now - (now - parse(service['environments'][env] ['state_timestamp']))).humanize() if service['environments'][env]['message_timestamp']: service['environments'][env]['message_age'] = ( now - (now - parse(service['environments'][env] ['message_timestamp']))).humanize() service['environments'][env][ 'api_closed'] = gates.gate_is_closed( service, blueprint.config, env) for t in service['environments'][env]["queue"]: t["age"] = (now - (now - parse(t["updated"]))).humanize() service_list[group][service_name] = service env_list[group] = sorted(env_list[group]) return view_util.render("gates.html", 'Gates', env_list=env_list, gate_list=service_list, info_list=gates.generate_info( blueprint.config), today_holiday=today_holiday) except (ConnectionFailure, OperationFailure, Exception) as error: print("error" + str(error)) raise
def gates(): try: service_list = OrderedDict() env_list = dict() now = Delorean.now() for group in blueprint.mongo.get_groups(): env_list[group] = set() service_list[group] = dict() for service_name in blueprint.mongo.get_services_in_group(group): service = blueprint.mongo.get_gate(group, service_name) for env in service["environments"]: env_list[group].add(env) if service["environments"][env]["state_timestamp"]: service["environments"][env]["state_age"] = ( now - (now - parse(service["environments"][env]["state_timestamp"])) ).humanize() if service["environments"][env]["message_timestamp"]: service["environments"][env]["message_age"] = ( now - (now - parse(service["environments"][env]["message_timestamp"])) ).humanize() service["environments"][env]["api_closed"] = gate_is_closed(service, env) for t in service["environments"][env]["queue"]: t["age"] = (now - (now - parse(t["updated"]))).humanize() service_list[group][service_name] = service env_list[group] = sorted(env_list[group]) return view_util.render( "gates.html", "Gates", env_list=env_list, gate_list=service_list, info_list=util.generate_info(blueprint.config), ) except (ConnectionFailure, OperationFailure) as error: return view_util.error_page(error.message)
def error_page(error): return view_util.render("error.html", "Error", error=error)