예제 #1
0
    async def api_realm_status(self, client_ctx, msg):
        msg = realm_status_serializer.req_load(msg)

        try:
            status = await self.get_status(client_ctx.organization_id,
                                           client_ctx.device_id,
                                           msg["realm_id"])

        except RealmAccessError:
            return realm_status_serializer.rep_dump({"status": "not_allowed"})

        except RealmNotFoundError as exc:
            return realm_status_serializer.rep_dump({
                "status": "not_found",
                "reason": str(exc)
            })

        return realm_status_serializer.rep_dump({
            "status":
            "ok",
            "in_maintenance":
            status.in_maintenance,
            "maintenance_type":
            status.maintenance_type,
            "maintenance_started_on":
            status.maintenance_started_on,
            "maintenance_started_by":
            status.maintenance_started_by,
            "encryption_revision":
            status.encryption_revision,
        })
예제 #2
0
 async def api_realm_stats(self, client_ctx, msg):
     msg = realm_stats_serializer.req_load(msg)
     try:
         stats = await self.get_stats(
             client_ctx.organization_id, client_ctx.device_id, msg["realm_id"]
         )
     except RealmAccessError:
         return realm_status_serializer.rep_dump({"status": "not_allowed"})
     except RealmNotFoundError as exc:
         return realm_status_serializer.rep_dump({"status": "not_found", "reason": str(exc)})
     return realm_stats_serializer.rep_dump(
         {"status": "ok", "blocks_size": stats.blocks_size, "vlobs_size": stats.vlobs_size}
     )