def addTrigger(self, newId): try: data = self._getFacade().addTrigger(newId) except DuplicateTriggerName as tnc: log.debug("Exception DuplicateTriggerName: %s" % tnc) return DirectResponse.fail(str(tnc)) else: audit('UI.Trigger.Add', newId) return DirectResponse.succeed(data=data)
def addTrigger(self, newId): try: data = self._getFacade().addTrigger(newId) except DuplicateTriggerName as tnc: log.debug("Exception DuplicateTriggerName: %s" % tnc) return DirectResponse.fail(str(tnc)) else: audit('UI.Trigger.Add', newId) return DirectResponse.succeed(data=data)
def updateDetails(self, evid, **detailInfo): """ On success, returns the status. """ try: resp = self.zep.updateDetails(evid, **detailInfo) except ServiceResponseError as ex: return DirectResponse.fail(msg=str(ex)) audit('UI.Event.UpdateEventDetails', self.context, evid=evid, details=detailInfo) return DirectResponse.succeed(status=resp['status'])
def updateDetails(self, evid, **detailInfo): """ On success, returns the status. """ try: resp = self.zep.updateDetails(evid, **detailInfo) except ServiceResponseError as ex: return DirectResponse.fail(msg=str(ex)) audit('UI.Event.UpdateEventDetails', self.context, evid=evid, details=detailInfo) return DirectResponse.succeed(status=resp['status'])
def importConfiguration(self, triggers=None, notifications=None): try: tcount = len(triggers) if triggers is not None else 0 ncount = len(notifications) if notifications is not None else 0 facade = self._getFacade() itcount, incount = facade.importConfiguration(triggers, notifications) msg = "Imported %d of %d triggers and %d of %d notifications" % (tcount, itcount, ncount, incount) audit("UI.TriggerNotification.Import", msg) return DirectResponse.succeed(msg=msg) except Exception as ex: audit("UI.TriggerNotification.Import", "Failed to import trigger/notification data") log.exception("Unable to import data:\ntriggers=%s\nnotifications=%s", repr(triggers), repr(notifications)) return DirectResponse.fail(str(ex))
def importConfiguration(self, triggers=None, notifications=None): try: tcount = len(triggers) if triggers is not None else 0 ncount = len(notifications) if notifications is not None else 0 facade = self._getFacade() itcount, incount = facade.importConfiguration(triggers, notifications) msg = "Imported %d of %d triggers and %d of %d notifications" % ( tcount, itcount, ncount, incount) audit('UI.TriggerNotification.Import', msg) return DirectResponse.succeed(msg=msg) except Exception as ex: audit('UI.TriggerNotification.Import', "Failed to import trigger/notification data") log.exception("Unable to import data:\ntriggers=%s\nnotifications=%s", repr(triggers), repr(notifications)) return DirectResponse.fail(str(ex))
def getRouterMethods(self, router=None): """ Return a JSON list of methods, arguments and documentation Example usage from zendmd: from Products.Zuul.routers.introspection import IntrospectionRouter zz = IntrospectionRouter(dmd) pprint(zz.getRouterMethods('DeviceRouter').data) """ if router is not None: klasses = self._getRouterByName(router) if klasses: # TODO: log something? klass = klasses[0] else: return DirectResponse.fail(msg="No router named '%s' found" % router) else: klass = self.__class__ methods = {} for name, code in inspect.getmembers(klass): if name.startswith('_'): continue if not inspect.ismethod(code): continue argspec = inspect.getargspec(code) if argspec.defaults is None: args = argspec.args[1:] # Ignore 'self' kwargs = {} else: n = len(argspec.defaults) args = argspec.args[1:-n] # Ignore 'self' kwargs = dict(zip(argspec.args[-n:], argspec.defaults)) methods[name] = dict( documentation=inspect.getdoc(code), kwargs=kwargs, args=args, ) return DirectResponse(data=Zuul.marshal(methods))
def getRouterMethods(self, router=None): """ Return a JSON list of methods, arguments and documentation Example usage from zendmd: from Products.Zuul.routers.introspection import IntrospectionRouter zz = IntrospectionRouter(dmd) pprint(zz.getRouterMethods('DeviceRouter').data) """ if router is not None: klasses = self._getRouterByName(router) if klasses: # TODO: log something? klass = klasses[0] else: return DirectResponse.fail(msg="No router named '%s' found" % router) else: klass = self.__class__ methods = {} for name, code in inspect.getmembers(klass): if name.startswith('_'): continue if not inspect.ismethod(code): continue argspec = inspect.getargspec(code) if argspec.defaults is None: args = argspec.args[1:] # Ignore 'self' kwargs = {} else: n = len(argspec.defaults) args = argspec.args[1:-n] # Ignore 'self' kwargs = dict(zip(argspec.args[-n:], argspec.defaults)) methods[name] = dict( documentation=inspect.getdoc(code), kwargs=kwargs, args=args, ) return DirectResponse(data=Zuul.marshal(methods))
def addTrigger(self, newId): try: data = self._getFacade().addTrigger(newId) except DuplicateTriggerName, tnc: log.debug("Exception DuplicateTriggerName: %s" % tnc) return DirectResponse.fail(str(tnc))
def addTrigger(self, newId): try: data = self._getFacade().addTrigger(newId) except DuplicateTriggerName, tnc: log.debug("Exception DuplicateTriggerName: %s" % tnc) return DirectResponse.fail(str(tnc))