def add_event(self, summary, device, component, severity, evclasskey, evclass=None): """ Create a new event. @type summary: string @param summary: New event's summary @type device: string @param device: Device uid to use for new event @type component: string @param component: Component uid to use for new event @type severity: string @param severity: Severity of new event. Can be one of the following: Critical, Error, Warning, Info, Debug, or Clear @type evclasskey: string @param evclasskey: The Event Class Key to assign to this event @type evclass: string @param evclass: Event class for the new event @rtype: DirectResponse """ try: self.zep.create(summary, severity, device, component, eventClassKey=evclasskey, eventClass=evclass) return DirectResponse.succeed("Created event") except NoConsumersException: # This occurs if the event is queued but there are no consumers - i.e. zeneventd is not # currently running. msg = 'Queued event. Check zeneventd status on <a href="/zport/About/zenossInfo">Daemons</a>' return DirectResponse.succeed(msg, sticky=True) except PublishException, e: # This occurs if there is a failure publishing the event to the queue. log.exception("Failed creating event") return DirectResponse.exception(e, "Failed to create event")
def parseFilter(self, source): try: response = self._getFacade().parseFilter(source) return DirectResponse.succeed(data=response) except Exception, e: log.exception(e) return DirectResponse.exception(e, "Error parsing filter source. Please check your syntax.")
def add_event(self, summary, device, component, severity, evclasskey, evclass=None): """ Create a new event. @type summary: string @param summary: New event's summary @type device: string @param device: Device id to use for new event @type component: string @param component: Component uid to use for new event @type severity: string @param severity: Severity of new event. Can be one of the following: Critical, Error, Warning, Info, Debug, or Clear @type evclasskey: string @param evclasskey: The Event Class Key to assign to this event @type evclass: string @param evclass: Event class for the new event @rtype: DirectResponse """ device = device.strip() # ZEN-2479: support entries like "localhost " try: self.zep.create(summary, severity, device, component, eventClassKey=evclasskey, eventClass=evclass, immediate=True) return DirectResponse.succeed("Created event") except NoConsumersException: # This occurs if the event is queued but there are no consumers - i.e. zeneventd is not # currently running. msg = 'Queued event. Check zeneventd status on <a href="/zport/About/zenossInfo">Daemons</a>' return DirectResponse.succeed(msg, sticky=True) except PublishException, e: # This occurs if there is a failure publishing the event to the queue. log.exception("Failed creating event") return DirectResponse.exception(e, "Failed to create event")
def parseFilter(self, source): try: response = self._getFacade().parseFilter(source) return DirectResponse.succeed(data=response) except Exception, e: log.exception(e) return DirectResponse.exception( e, 'Error parsing filter source. Please check your syntax.')
def add_event(self, summary, device, component, severity, evclasskey, evclass=None, monitor=None, **kwargs): """ Create a new event. @type summary: string @param summary: New event's summary @type device: string @param device: Device id to use for new event @type component: string @param component: Component uid to use for new event @type severity: string @param severity: Severity of new event. Can be one of the following: Critical, Error, Warning, Info, Debug, or Clear @type evclasskey: string @param evclasskey: The Event Class Key to assign to this event @type evclass: string @param evclass: Event class for the new event @rtype: DirectResponse For other parameters please see class Event. """ device = device.strip() # ZEN-2479: support entries like "localhost " try: self.zep.create(summary, severity, device, component, eventClassKey=evclasskey, eventClass=evclass, monitor=monitor, **kwargs) return DirectResponse.succeed("Created event") except NoConsumersException: # This occurs if the event is queued but there are no consumers - i.e. zeneventd is not # currently running. msg = 'Queued event. Check zeneventd status on <a href="/zport/dmd/daemons">Services</a>' return DirectResponse.succeed(msg, sticky=True) except PublishException, e: # This occurs if there is a failure publishing the event to the queue. log.exception("Failed creating event") return DirectResponse.exception(e, "Failed to create event")