本文整理汇总了Python中Products.ZenUtils.extdirect.router.DirectResponse.succeed方法的典型用法代码示例。如果您正苦于以下问题:Python DirectResponse.succeed方法的具体用法?Python DirectResponse.succeed怎么用?Python DirectResponse.succeed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.ZenUtils.extdirect.router.DirectResponse
的用法示例。
在下文中一共展示了DirectResponse.succeed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_event
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import succeed [as 别名]
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")
示例2: queryArchive
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import succeed [as 别名]
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: parseFilter
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import succeed [as 别名]
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.")
示例4: getConfig
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import succeed [as 别名]
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)
示例5: updateTrigger
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import succeed [as 别名]
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)
示例6: clear_device_heartbeats
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import succeed [as 别名]
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)
示例7: getConfig
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import succeed [as 别名]
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)
示例8: getNotificationTypes
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import succeed [as 别名]
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)
示例9: getSecurityPermissions
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import succeed [as 别名]
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)
示例10: exportConfiguration
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import succeed [as 别名]
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
)
示例11: removeTrigger
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import succeed [as 别名]
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)
示例12: removeTrigger
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import succeed [as 别名]
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)
示例13: updateNotification
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import succeed [as 别名]
def updateNotification(self, **data):
notificationUid = data['uid']
response = self._getFacade().updateNotification(**data)
audit('UI.Notification.Edit', notificationUid,
data=data, maskFields='password')
return DirectResponse.succeed(
msg="Notification updated successfully.",
data=Zuul.marshal(response)
)
示例14: addTrigger
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import succeed [as 别名]
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)
示例15: setDmdSettings
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import succeed [as 别名]
def setDmdSettings(self, **kwargs):
"""
Accepts key value pair of dmd settings
"""
dmd = self.context.zport.dmd
for key, value in kwargs.iteritems():
if hasattr(dmd, key):
setattr(dmd, key, value)
return DirectResponse.succeed()