Exemple #1
0
    def statuses(self, request, environment_id, deployment_id):
        target = {
            "environment_id": environment_id,
            "deployment_id": deployment_id
        }
        policy.check("statuses_deployments", request.context, target)

        unit = db_session.get_session()
        query = unit.query(models.Status) \
            .filter_by(task_id=deployment_id) \
            .order_by(models.Status.created)
        deployment = verify_and_get_deployment(unit, environment_id,
                                               deployment_id)

        if 'service_id' in request.GET:
            service_id_set = set(request.GET.getall('service_id'))
            environment = deployment.description
            entity_ids = []
            for service in environment.get('services', []):
                if service['?']['id'] in service_id_set:
                    id_map = utils.build_entity_map(service)
                    entity_ids = entity_ids + id_map.keys()
            if entity_ids:
                query = query.filter(models.Status.entity_id.in_(entity_ids))
            else:
                return {'reports': []}

        result = query.all()
        return {'reports': [status.to_dict() for status in result]}
Exemple #2
0
    def statuses(self, request, environment_id, deployment_id):
        target = {"environment_id": environment_id,
                  "deployment_id": deployment_id}
        policy.check("statuses_deployments", request.context, target)

        unit = db_session.get_session()
        query = unit.query(models.Status) \
            .filter_by(task_id=deployment_id) \
            .order_by(models.Status.created)
        deployment = verify_and_get_deployment(unit, environment_id,
                                               deployment_id)

        if 'service_id' in request.GET:
            service_id_set = set(request.GET.getall('service_id'))
            environment = deployment.description
            entity_ids = []
            for service in environment.get('services', []):
                if service['?']['id'] in service_id_set:
                    id_map = utils.build_entity_map(service)
                    entity_ids = entity_ids + id_map.keys()
            if entity_ids:
                query = query.filter(models.Status.entity_id.in_(entity_ids))
            else:
                return {'reports': []}

        result = query.all()
        return {'reports': [status.to_dict() for status in result]}
Exemple #3
0
 def last(self, request, environment_id):
     session_id = None
     if hasattr(request, 'context') and request.context.session:
         session_id = request.context.session
     services = core_services.CoreServices.get_data(environment_id,
                                                    '/services', session_id)
     session = db_session.get_session()
     result = {}
     for service in services or []:
         service_id = service['?']['id']
         entity_ids = utils.build_entity_map(service).keys()
         last_status = session.query(models.Status). \
             filter(models.Status.entity_id.in_(entity_ids)). \
             order_by(desc(models.Status.created)). \
             first()
         if last_status:
             result[service_id] = last_status.to_dict()
         else:
             result[service_id] = None
     return {'lastStatuses': result}
Exemple #4
0
 def last(self, request, environment_id):
     session_id = None
     if hasattr(request, "context") and request.context.session:
         session_id = request.context.session
     services = core_services.CoreServices.get_data(environment_id, "/services", session_id)
     session = db_session.get_session()
     result = {}
     for service in services or []:
         service_id = service["?"]["id"]
         entity_ids = utils.build_entity_map(service).keys()
         last_status = (
             session.query(models.Status)
             .filter(models.Status.entity_id.in_(entity_ids))
             .order_by(desc(models.Status.created))
             .first()
         )
         if last_status:
             result[service_id] = last_status.to_dict()
         else:
             result[service_id] = None
     return {"lastStatuses": result}
Exemple #5
0
 def last(self, request, environment_id):
     session_id = None
     if hasattr(request, 'context') and request.context.session:
         session_id = request.context.session
     services = core_services.CoreServices.get_data(environment_id,
                                                    '/services',
                                                    session_id)
     session = db_session.get_session()
     result = {}
     for service in services:
         service_id = service['?']['id']
         entity_ids = utils.build_entity_map(service).keys()
         last_status = session.query(models.Status). \
             filter(models.Status.entity_id.in_(entity_ids)). \
             order_by(desc(models.Status.created)). \
             first()
         if last_status:
             result[service_id] = last_status.to_dict()
         else:
             result[service_id] = None
     return {'lastStatuses': result}