本文整理汇总了Python中Products.ZenUtils.guid.interfaces.IGUIDManager类的典型用法代码示例。如果您正苦于以下问题:Python IGUIDManager类的具体用法?Python IGUIDManager怎么用?Python IGUIDManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IGUIDManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lookupGuid
def lookupGuid(guid):
"""
Given a guid this returns the object that it identifies
"""
from Products.ZenUtils.guid.interfaces import IGUIDManager
manager = IGUIDManager(dmd)
return manager.getObject(guid)
示例2: getProcessList
def getProcessList(self, deviceGuid):
if deviceGuid and len(deviceGuid) > 0:
s = ''
try:
device = IGUIDManager(self._dmd).getObject(deviceGuid)
s = '# ' + device.id
response = Response()
zenmodelerOpts = ['run', '--now', '--debug', '-v10', '-d', device.id]
exitCode = device.perfServer().executeCollectorCommand('zenmodeler', zenmodelerOpts, REQUEST=None, write=response.write)
processList = response.getLines()
if not exitCode:
filterProcessLine = re.compile('DEBUG zen\.osprocessmatcher: COMMAND LINE: (?P<process>.*)$')
for processListLine in processList:
m = filterProcessLine.search(processListLine)
if m:
s += '\n' + m.group('process')
else:
s += "==> " + str(exitCode)
for line in processList:
s += '\n# ' + line.strip()
except Exception, e:
s += '\n# ' + str(e)
yield {
'uid': '0',
'process': s
}
示例3: __call__
def __call__(self, *args, **kwargs):
"""
Takes a guid in the request and redirects the browser to the
object's url
"""
manager = IGUIDManager(self.context)
request = self.request
response = self.request.response
obj = None
guid = request.get('guid', None)
if not guid:
return response.write("The guid paramater is required")
# they passed in a uid instead of a guid
try:
if guid.startswith("/zport/dmd/"):
obj = self.context.unrestrictedTraverse(unquote(guid))
else:
obj = manager.getObject(guid)
except KeyError:
pass
if not obj:
return response.write("Could not look up guid %s" % guid)
path = obj.absolute_url_path()
return response.redirect(path)
示例4: impacts_for
def impacts_for(thing):
'''
Return a two element tuple.
First element is a list of object ids impacted by thing. Second element is
a list of object ids impacting thing.
'''
from ZenPacks.zenoss.Impact.impactd.interfaces \
import IRelationshipDataProvider
impacted_by = []
impacting = []
guid_manager = IGUIDManager(thing.getDmd())
for subscriber in subscribers([thing], IRelationshipDataProvider):
for edge in subscriber.getEdges():
source = guid_manager.getObject(edge.source)
impacted = guid_manager.getObject(edge.impacted)
if source.id == thing.id:
impacted_by.append(impacted.id)
elif impacted.id == thing.id:
impacting.append(source.id)
return (impacted_by, impacting)
示例5: getProcessList
def getProcessList(self, deviceGuid):
if deviceGuid and len(deviceGuid) > 0:
s = ''
try:
import subprocess
from Products.ZenUtils.Utils import binPath
device = IGUIDManager(self._dmd).getObject(deviceGuid)
s = '# ' + device.id
zenmodelerOpts = ['run', '--now', '--debug', '-v10', '-d', device.id]
isPerfMonRemote = False
zenmodelerName = 'zenmodeler'
zenmodelerPath = binPath(zenmodelerName)
monitorId = device.perfServer().id
if monitorId != 'localhost':
zenmodelerName = monitorId + '_' + zenmodelerName
zenmodelerPath = binPath(zenmodelerName)
if len(zenmodelerPath) == 0:
isPerfMonRemote = True
if isPerfMonRemote:
cmd = "ssh %s %s %s" % (device.perfServer().hostname, zenmodelerName, ' '.join(zenmodelerOpts))
else:
cmd = "%s %s" % (zenmodelerPath, ' '.join(zenmodelerOpts))
processList = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT).splitlines()
filterProcessLine = re.compile('DEBUG zen\.osprocessmatcher: COMMAND LINE: (?P<process>.*)$')
for processListLine in processList:
m = filterProcessLine.search(processListLine)
if m:
s += '\n' + m.group('process')
except Exception, e:
s += '\n# ' + str(e)
yield {
'uid': '0',
'process': s
}
示例6: getDeviceDashboard
def getDeviceDashboard(self):
"""return device info for bad device to dashboard"""
zep = getFacade('zep')
manager = IGUIDManager(self.context.dmd)
deviceSeverities = zep.getDeviceIssuesDict()
zem = self.context.dmd.ZenEventManager
devdata = []
for uuid in deviceSeverities.keys():
dev = manager.getObject(uuid)
if dev and isinstance(dev, Device):
if (not zem.checkRemotePerm(ZEN_VIEW, dev)
or dev.productionState < zem.prodStateDashboardThresh
or dev.priority < zem.priorityDashboardThresh):
continue
alink = dev.getPrettyLink()
try:
severities = deviceSeverities[uuid]
severities = dict((zep.getSeverityName(sev).lower(), counts) for (sev, counts) in severities.iteritems())
pill = getEventPillME(dev, severities=severities)
except ServiceException:
continue
evts = [alink,pill]
devdata.append((evts, severities))
devdata.sort(key=lambda x:(x[1]['critical'], x[1]['error'], x[1]['warning']), reverse=True)
return [x[0] for x in devdata[:100]]
示例7: manage_addAdministrativeRole
def manage_addAdministrativeRole(self, name=None, type='device', role=None,
guid=None, uid=None, REQUEST=None):
"Add a Admin Role to the passed object"
unused(role)
mobj = None
if guid or uid:
# look up our object by either guid or uid
if guid:
manager = IGUIDManager(self.dmd)
mobj = manager.getObject(guid)
elif uid:
mobj = self.unrestrictedTraverse(uid)
else:
# use magic to look up our object
if not name:
name = REQUEST.deviceName
if type == 'device':
mobj =self.getDmdRoot("Devices").findDevice(name)
else:
try:
root = type.capitalize()+'s'
if type == "deviceClass":
mobj = self.getDmdRoot("Devices").getOrganizer(name)
else:
mobj = self.getDmdRoot(root).getOrganizer(name)
except KeyError: pass
if not mobj:
if REQUEST:
messaging.IMessageSender(self).sendToBrowser(
'Error',
"%s %s not found"%(type.capitalize(),name),
priority=messaging.WARNING
)
return self.callZenScreen(REQUEST)
else: return
roleNames = [ r.id for r in mobj.adminRoles() ]
if self.id in roleNames:
if REQUEST:
messaging.IMessageSender(self).sendToBrowser(
'Error',
(("Administrative Role for %s %s "
"for user %s already exists.") % (type, name, self.id)),
priority=messaging.WARNING
)
return self.callZenScreen(REQUEST)
else: return
mobj.manage_addAdministrativeRole(self.id)
if REQUEST:
messaging.IMessageSender(self).sendToBrowser(
'Role Added',
("Administrative Role for %s %s for user %s added" %
(type, name, self.id))
)
audit('UI.User.AddAdministrativeRole', username=self.id,
data_={mobj.meta_type:mobj.getPrimaryId()})
return self.callZenScreen(REQUEST)
示例8: getElements
def getElements(self):
manager = IGUIDManager(self.getDmd())
memberObjs = []
for poolmember in self.members:
obj = manager.getObject(poolmember)
if obj:
memberObjs.append(obj)
else:
log.warn("Stale ElementPool member: %s", poolmember)
return memberObjs
示例9: _getDevices
def _getDevices(self, dmd, results):
"""
Look up the devices from the events.
"""
manager = IGUIDManager(dmd)
events = results['events']
for event in events:
occurrence = event['occurrence'][0]
actor_uuid = occurrence['actor'].get('element_uuid')
if not actor_uuid:
continue
dev = manager.getObject(actor_uuid)
if dev:
yield dev
示例10: __init__
def __init__(self, context, request):
super(EventsRouter, self).__init__(context, request)
self.zep = Zuul.getFacade('zep', context)
self.catalog = IModelCatalogTool(context)
self.manager = IGUIDManager(context.dmd)
self._filterParser = _FilterParser(self.zep)
self.use_permissions = False
示例11: __init__
def __init__(self, dmd, event_summary):
self._dmd = dmd
self._event_summary = event_summary
self._eventOccurrence = event_summary['occurrence'][0]
self._eventActor = self._eventOccurrence['actor']
self._eventDetails = self._findDetails(self._eventOccurrence)
self._catalog = ICatalogTool(dmd)
self._manager = IGUIDManager(dmd)
示例12: __init__
def __init__(self, context):
super(ZepFacade, self).__init__(context)
config = getGlobalConfiguration()
zep_url = config.get('zep-uri', 'http://localhost:8084')
schema = getUtility(IQueueSchema)
self.client = ZepServiceClient(zep_url, schema)
self.configClient = ZepConfigClient(zep_url, schema)
self.heartbeatClient = ZepHeartbeatClient(zep_url, schema)
self._guidManager = IGUIDManager(context.dmd)
示例13: getDeviceIssues
def getDeviceIssues(self):
zep = getFacade('zep', self._dmd)
manager = IGUIDManager(self._dmd)
deviceSeverities = zep.getDeviceIssuesDict()
zem = self.context.dmd.ZenEventManager
devdata = []
# only get the first 100 since this is just the portlet
for uuid in deviceSeverities.keys()[:100]:
dev = manager.getObject(uuid)
if dev and isinstance(dev, Device):
if (not zem.checkRemotePerm(ZEN_VIEW, dev)
or dev.productionState < zem.prodStateDashboardThresh
or dev.priority < zem.priorityDashboardThresh):
continue
severities = deviceSeverities[uuid]
info = IInfo(dev)
info.setEventSeverities(severities)
devdata.append(info)
return devdata
示例14: _initCatalogs
def _initCatalogs(self):
self._guidManager = IGUIDManager(self.dmd)
self._devices = self.dmd._getOb('Devices')
self._networks = self.dmd._getOb('Networks')
self._events = self.dmd._getOb('Events')
self._catalogs = {
DEVICE: self._devices,
}
示例15: getDeviceDashboard
def getDeviceDashboard(self):
"""return device info for bad device to dashboard"""
zep = getFacade('zep')
manager = IGUIDManager(self.context.dmd)
deviceSeverities = zep.getDeviceIssuesDict()
zem = self.context.dmd.ZenEventManager
bulk_data = []
for uuid in deviceSeverities.keys():
uuid_data = {}
uuid_data['uuid'] = uuid
severities = deviceSeverities[uuid]
try:
uuid_data['severities'] = dict((zep.getSeverityName(sev).lower(), counts) for (sev, counts) in severities.iteritems())
except ServiceException:
continue
bulk_data.append(uuid_data)
bulk_data.sort(key=lambda x:(x['severities']['critical'], x['severities']['error'], x['severities']['warning']), reverse=True)
devices_found = 0
MAX_DEVICES = 100
devdata = []
for data in bulk_data:
uuid = data['uuid']
severities = data['severities']
dev = manager.getObject(uuid)
if dev and isinstance(dev, Device):
if (not zem.checkRemotePerm(ZEN_VIEW, dev)
or dev.productionState < zem.prodStateDashboardThresh
or dev.priority < zem.priorityDashboardThresh):
continue
alink = dev.getPrettyLink()
pill = getEventPillME(dev, severities=severities)
evts = [alink,pill]
devdata.append(evts)
devices_found = devices_found + 1
if devices_found >= MAX_DEVICES:
break
return devdata