當前位置: 首頁>>代碼示例>>Python>>正文


Python interfaces.IGUIDManager類代碼示例

本文整理匯總了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)
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:7,代碼來源:zendmd.py

示例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
         }
開發者ID:c0ns0le,項目名稱:zenoss-4,代碼行數:26,代碼來源:processfacade.py

示例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)
開發者ID:bbc,項目名稱:zenoss-prodbin,代碼行數:27,代碼來源:views.py

示例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)
開發者ID:zenoss,項目名稱:ZenPacks.zenoss.OpenStackInfrastructure,代碼行數:25,代碼來源:test_impact.py

示例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
         }
開發者ID:bbc,項目名稱:zenoss-prodbin,代碼行數:34,代碼來源:processfacade.py

示例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]]
開發者ID:SteelHouseLabs,項目名稱:zenoss-prodbin,代碼行數:26,代碼來源:Portlets.py

示例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)
開發者ID:SteelHouseLabs,項目名稱:zenoss-prodbin,代碼行數:56,代碼來源:UserSettings.py

示例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
開發者ID:zenoss,項目名稱:ZenPacks.zenoss.CalculatedPerformance,代碼行數:11,代碼來源:ElementPool.py

示例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
開發者ID:SteelHouseLabs,項目名稱:zenoss-prodbin,代碼行數:14,代碼來源:statuses.py

示例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
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:7,代碼來源:zep.py

示例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)
開發者ID:SteelHouseLabs,項目名稱:zenoss-prodbin,代碼行數:8,代碼來源:event.py

示例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)
開發者ID:SteelHouseLabs,項目名稱:zenoss-prodbin,代碼行數:9,代碼來源:zepfacade.py

示例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
開發者ID:dougsyer,項目名稱:ZenPacks.zenoss.Dashboard,代碼行數:19,代碼來源:facades.py

示例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,
        }
開發者ID:bbc,項目名稱:zenoss-prodbin,代碼行數:10,代碼來源:processing.py

示例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
開發者ID:bbc,項目名稱:zenoss-prodbin,代碼行數:42,代碼來源:Portlets.py


注:本文中的Products.ZenUtils.guid.interfaces.IGUIDManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。