示例#1
0
    def remove_monitor(self, snap: ModelSnapshot, context: dict):
        if not self._active_monitors.get(snap.id, None):
            throw_exception("remove_monitor", f"Monitor for {snap.id} is not known")

        self._active_monitors.pop(snap.id)

        return snap
示例#2
0
    def create_monitor(self, snap: ModelSnapshot, context: dict):
        if self._active_monitors.get(snap.id, None):
            throw_exception("create_monitor", f"Monitor for {snap.id} is already known")

        self._active_monitors[snap.id] = dict(snapshot=snap)

        return snap
示例#3
0
 def on_post(self, req, resp, command):
     # Get endpoint
     endpoint = self.endpoint_map.get(command)
     if endpoint:
         # Command implemented, process request
         resp.context['result'] = endpoint(req)
         resp.set_header('Powered-By', 'Falcon')
         resp.status = falcon.HTTP_200
     else:
         # Command not implemented, raise issue
         throw_exception("on_post", "ERROR: Unfortunately, the command {} is not available yet.".format(command))
示例#4
0
 def on_delete(self, req, resp, command):
     self.logger.warning(
         'DELETE request received at endpoint "{}", resp "{}", command "{}"'.format(req.path, resp, command))
     # Get endpoint
     endpoint = self.endpoint_map.get(command)
     if endpoint:
         # Command implemented, process request
         resp.context['result'] = endpoint(req)
         resp.set_header('Powered-By', 'Falcon')
         resp.status = falcon.HTTP_200
     else:
         # Command not implemented, raise issue
         throw_exception("on_delete", "ERROR: Unfortunately, the command {} is not available yet.".format(command))