本文整理汇总了Python中Products.ZenUtils.extdirect.router.DirectResponse类的典型用法代码示例。如果您正苦于以下问题:Python DirectResponse类的具体用法?Python DirectResponse怎么用?Python DirectResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DirectResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parseFilter
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.")
示例2: queryArchive
def queryArchive(self, page=None, limit=0, start=0, sort='lastTime', dir='desc', params=None, exclusion_filter=None, keys=None, uid=None, detailFormat=False):
if not self._canViewEvents():
return DirectResponse.succeed(
events=[],
totalCount=0,
asof=time.time()
)
filter = self._buildFilter(uid, params)
if exclusion_filter is not None:
exclusion_filter = self._buildFilter(uid, exclusion_filter)
events = self.zep.getEventSummariesFromArchive(limit=limit, offset=start, sort=self._buildSort(sort, dir),
filter=filter, exclusion_filter=exclusion_filter)
eventFormat = EventCompatInfo
if detailFormat:
eventFormat = EventCompatDetailInfo
dmd = self.context.dmd
# filter out the component and device UUIDs that no longer exist in our system
evdata = self._filterInvalidUuids(events['events'])
eventObs = [eventFormat(dmd, e) for e in evdata]
return DirectResponse.succeed(
events=Zuul.marshal(eventObs, keys),
totalCount=events['total'],
asof=time.time()
)
示例3: add_event
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")
示例4: addTrigger
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)
示例5: updateDetails
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'])
示例6: importConfiguration
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))
示例7: updateTrigger
def updateTrigger(self, **data):
data['rule']['api_version'] = 1
data['rule']['type'] = RULE_TYPE_JYTHON
triggerUid = data['uuid']
response = self._getFacade().updateTrigger(**data)
audit('UI.Trigger.Edit', triggerUid, data_=data)
return DirectResponse.succeed(msg="Trigger updated successfully.", data=response)
示例8: getConfig
def getConfig(self):
# this data var is not a ZepConfig, it's a config structure that has been
# constructed to include default values and be keyed by the protobuf
# property name.
data = self.zep.getConfig()
config = self._mergeSchemaAndZepConfig(data, self.configSchema)
return DirectResponse.succeed(data=config)
示例9: clear_device_heartbeats
def clear_device_heartbeats(self, params, limit=None):
"""
@type params: dictionary
@param params: Key-value pair of filters for this search.
"""
if isinstance(params, basestring):
params = loads(params)
device = params['device']
log.debug('Clearing heartbeats for device: {device}'.format(device=device))
params['eventState'] = [STATUS_NEW, STATUS_ACKNOWLEDGED]
params['eventClass'] = '/Status/Heartbeat'
includeFilter, excludeFilter = self._buildRequestFilters(None, params, None, None)
status, summaryUpdateResponse = self.zep.closeEventSummaries(
eventFilter=includeFilter,
exclusionFilter=excludeFilter,
limit=limit,
)
log.debug('Done clearing heartbeats for device: {device}'.format(device=device))
log.debug(summaryUpdateResponse)
audit('UI.Device.ClearHeartbeats', device=device)
return DirectResponse.succeed(data=summaryUpdateResponse)
示例10: getNotificationTypes
def getNotificationTypes(self, query=''):
utils = getUtilitiesFor(IAction)
actionTypes = sorted(
(dict(id=id, name=util.name) for id, util in utils),
key=itemgetter('id')
)
log.debug('notification action types are: %s' % actionTypes)
return DirectResponse.succeed(data=actionTypes)
示例11: getSecurityPermissions
def getSecurityPermissions(self, uid):
"""
returns a dictionary of all the permissions a
user has on the context
"""
obj = self.context.dmd.unrestrictedTraverse(uid)
permissions = permissionsForContext(obj)
return DirectResponse.succeed(data=permissions)
示例12: exportConfiguration
def exportConfiguration(self, triggerIds=None, notificationIds=None):
facade = self._getFacade()
triggers, notifications = facade.exportConfiguration(triggerIds, notificationIds)
msg = "Exported %d triggers and %d notifications" % (len(triggers), len(notifications))
audit("UI.TriggerNotification.Export", msg)
return DirectResponse.succeed(
triggers=Zuul.marshal(triggers), notifications=Zuul.marshal(notifications), msg=msg
)
示例13: getConfig
def getConfig(self):
# this data var is not a ZepConfig, it's a config structure that has been
# constructed to include default values and be keyed by the protobuf
# property name.
data = self.zep.getConfig()
schema = self._mergeSchemaAndZepConfig(data, self.configSchema)
config = [setting for setting in schema if self.iseditable(setting['id'])]
return DirectResponse.succeed(data=config)
示例14: removeTrigger
def removeTrigger(self, uuid):
updated_count = self._getFacade().removeTrigger(uuid)
audit('UI.Trigger.Remove', uuid)
msg = "Trigger removed successfully. {count} {noun} {verb} updated.".format(
count = updated_count,
noun = 'notification' if updated_count == 1 else 'notifications',
verb = 'was' if updated_count == 1 else 'were'
)
return DirectResponse.succeed(msg=msg, data=None)
示例15: removeTrigger
def removeTrigger(self, uuid):
updated_count = self._getFacade().removeTrigger(uuid)
audit("UI.Trigger.Remove", uuid)
msg = "Trigger removed successfully. {count} {noun} {verb} updated.".format(
count=updated_count,
noun="notification" if updated_count == 1 else "notifications",
verb="was" if updated_count == 1 else "were",
)
return DirectResponse.succeed(msg=msg, data=None)