当前位置: 首页>>代码示例>>Python>>正文


Python interfaces.ICatalogTool类代码示例

本文整理汇总了Python中Products.Zuul.interfaces.ICatalogTool的典型用法代码示例。如果您正苦于以下问题:Python ICatalogTool类的具体用法?Python ICatalogTool怎么用?Python ICatalogTool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ICatalogTool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: remove

    def remove(self, app, leaveObjects=False):
        if not leaveObjects:
            log.info('Removing Hadoop components')
            cat = ICatalogTool(app.zport.dmd)
            for brain in cat.search(types=NEW_COMPONENT_TYPES):
                component = brain.getObject()
                component.getPrimaryParent()._delObject(component.id)

            # Remove our Device relations additions.
            Device._relations = tuple(
                [x for x in Device._relations
                    if x[0] not in NEW_DEVICE_RELATIONS])
            # Remove zHBaseMasterPort if HBase ZenPack is not installed
            try:
                self.dmd.ZenPackManager.packs._getOb(
                    'ZenPacks.zenoss.HBase'
                )
            except AttributeError:
                if self.dmd.Devices.hasProperty('zHBaseMasterPort'):
                    self.dmd.Devices.deleteZenProperty('zHBaseMasterPort')
                    log.debug('Removing zHBaseMasterPort property')

            log.info('Removing Hadoop device relationships')
            self._buildDeviceRelations()

        super(ZenPack, self).remove(app, leaveObjects=leaveObjects)
开发者ID:ssOleg,项目名称:ZenPacks.zenoss.Hadoop,代码行数:26,代码来源:__init__.py

示例2: hidden

    def hidden(self):
        """
        Make sure we don't show the root node of a tree
        if we don't have permission on it or any of its children
        """
        # always show the root Device organizer so restricted users can see
        # all of the devices they have access to
        if self.uid == '/zport/dmd/Devices':
            return False

        # make sure we are looking at a root node
        pieces = self.uid.split('/')
        if len(pieces) != 4:
            return False

        # check for our permission
        manager = getSecurityManager()
        obj = self._object.unrestrictedTraverse(self.uid)
        if manager.checkPermission("View", obj):
            return False

        # search the catalog to see if we have permission with any of the children
        cat = ICatalogTool(obj)
        numInstances = cat.count('Products.ZenModel.DeviceOrganizer.DeviceOrganizer', self.uid)


        # if anything is returned we have view permissions on a child
        return not numInstances > 0
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:28,代码来源:tree.py

示例3: getSubComponents

 def getSubComponents(self, dmd):
     i = 0
     catalog = ICatalogTool(dmd.Devices)
     COMPONENT = 'Products.ZenModel.DeviceComponent.DeviceComponent'
     query = Eq('monitored', '1')
     for brain in catalog.search(COMPONENT, query=query):
         i += 1
         obj = None
         try:
             obj = brain.getObject()
         except KeyError:
             continue
         dev = obj.device()
         status = obj.getStatus()
         row = (dict(
                 getParentDeviceTitle=obj.getParentDeviceTitle(),
                 hostname=obj.getParentDeviceTitle(),
                 name=obj.name(),
                 meta_type=obj.meta_type,
                 getInstDescription=obj.getInstDescription(),
                 getStatusString=obj.convertStatus(status),
                 getDeviceLink=obj.getDeviceLink(),
                 getPrimaryUrlPath=obj.getPrimaryUrlPath(),
                 cssclass=obj.getStatusCssClass(status),
                 status=status
                 ))
         obj._p_invalidate()
         dev._p_invalidate()
         if i % 100 == 0:
             transaction.abort()
         yield Utils.Record(**row)
开发者ID:c0ns0le,项目名称:zenoss-4,代码行数:31,代码来源:monitoredcomponents.py

示例4: getDeviceBrains

 def getDeviceBrains(self, uid=None, start=0, limit=50, sort='name',
                     dir='ASC', params=None, hashcheck=None):
     cat = ICatalogTool(self._getObject(uid))
     reverse = dir=='DESC'
     qs = []
     query = None
     globFilters = {}
     if params is None:
         params = {}
     for key, value in params.iteritems():
         if key == 'ipAddress':
             ip = ensureIp(value)
             try:
                 checkip(ip)
             except IpAddressError:
                 pass
             else:
                 if numbip(ip):
                     minip, maxip = getSubnetBounds(ip)
                     qs.append(Between('ipAddress', str(minip), str(maxip)))
         elif key == 'deviceClass':
             qs.append(MatchRegexp('uid', '(?i).*%s.*' %
                                   value))
         elif key == 'productionState':
             qs.append(Or(*[Eq('productionState', str(state))
                          for state in value]))
         else:
             globFilters[key] = value
     if qs:
         query = And(*qs)
     brains = cat.search('Products.ZenModel.Device.Device', start=start,
                        limit=limit, orderby=sort, reverse=reverse,
                         query=query, globFilters=globFilters, hashcheck=hashcheck)
     return brains
开发者ID:c0ns0le,项目名称:zenoss-4,代码行数:34,代码来源:__init__.py

示例5: getIpAddresses

    def getIpAddresses(self, limit=0, start=0, sort='ipAddressAsInt', dir='DESC',
              params=None, uid=None, criteria=()):
        infos = []
        cat = ICatalogTool(self._getObject(uid))
        reverse = dir=='DESC'

        brains = cat.search("Products.ZenModel.IpAddress.IpAddress",
                            start=start, limit=limit,
                            orderby=sort, reverse=reverse)

        for brain in brains:
            infos.append(IInfo(unbrain(brain)))

        devuuids = set(info.device.uuid for info in infos if info.device)

        # get ping severities
        zep = getFacade('zep')
        pingSeverities = zep.getEventSeverities(devuuids,
                                                      severities=(),
                                                      status=(),
                                                      eventClass=Status_Ping)
        self._assignPingStatuses(infos, pingSeverities)

        # get snmp severities
        snmpSeverities = zep.getEventSeverities(devuuids,
                                                      severities=(),
                                                      status=(),
                                                      eventClass=Status_Snmp)
        self._assignSnmpStatuses(infos, snmpSeverities)

        return SearchResults(infos, brains.total, brains.hash_)
开发者ID:c0ns0le,项目名称:zenoss-4,代码行数:31,代码来源:networkfacade.py

示例6: moveProcess

    def moveProcess(self, uid, targetUid):
        obj = self._getObject(uid)
        target = self._getObject(targetUid)
        brainsCollection = []

        # reindex all the devices and processes underneath this guy and the target
        for org in (obj.getPrimaryParent().getPrimaryParent(), target):
            catalog = ICatalogTool(org)
            brainsCollection.append(catalog.search(OSProcess))

        if isinstance(obj, OSProcessClass):
            source = obj.osProcessOrganizer()
            source.moveOSProcessClasses(targetUid, obj.id)
            newObj = getattr(target.osProcessClasses, obj.id)
        elif isinstance(obj, OSProcessOrganizer):
            source = aq_parent(obj)
            source.moveOrganizer(targetUid, (obj.id,))
            newObj = getattr(target, obj.id)
        else:
            raise Exception('Illegal type %s' % obj.__class__.__name__)

        # fire the object moved event for the process instances (will update catalog)
        for brains in brainsCollection:
            objs = imap(unbrain, brains)
            for item in objs:
                notify(ObjectMovedEvent(item, item.os(), item.id, item.os(), item.id))


        return newObj.getPrimaryPath()
开发者ID:SteelHouseLabs,项目名称:zenoss-prodbin,代码行数:29,代码来源:processfacade.py

示例7: interfaces_by_type

def interfaces_by_type(device, type_):
    """Yield Interface objects matching the given type."""
    catalog = ICatalogTool(device.primaryAq())

    search_results = catalog.search(
        types=('ZenPacks.Rackspace.BTI7200.%s.%s' % (type_, type_)))

    for result in search_results.results:
        yield result.getObject()
开发者ID:Hackman238,项目名称:ZenPacks.Rackspace.BTI7200,代码行数:9,代码来源:utils.py

示例8: removeSoftwareAndOperatingSystems

 def removeSoftwareAndOperatingSystems(self, dmd):
     """
     Find everything that is an OperationSystem Or
     Software and unindex it
     """
     cat = ICatalogTool(dmd)
     brains = cat.search(types=(OperatingSystem,Software))
     for brain in brains:
         dmd.global_catalog.uncatalog_object(brain.getPath())
开发者ID:SteelHouseLabs,项目名称:zenoss-prodbin,代码行数:9,代码来源:SpeedUpGlobalCatalog.py

示例9: _buildCache

 def _buildCache(self, orgtype=None, instancetype=None, relname=None, treePrefix=None, orderby=None):
     if orgtype and not getattr(self._root, "_cache", None):
         cat = ICatalogTool(self._object.unrestrictedTraverse(self.uid))
         results = cat.search(orgtype, orderby=orderby)
         if instancetype:
             instanceresults = cat.search(instancetype, orderby=None)
             self._root._cache = PathIndexCache(results, instanceresults, relname, treePrefix)
         else:
             self._root._cache = PathIndexCache(results)
     return self._root._cache
开发者ID:jpeacock-zenoss,项目名称:zenoss-prodbin,代码行数:10,代码来源:tree.py

示例10: getInstances

    def getInstances(self, uid=None, start=0, limit=50, sort='name',
                     dir='ASC', params=None):
        # do the catalog search
        cat = ICatalogTool(self._getObject(uid))
        reverse = bool(dir == 'DESC')
        brains = cat.search(self._instanceClass, start=start, limit=limit,
                            orderby=sort, reverse=reverse)
        objs = imap(unbrain, brains)

        # convert to info objects
        return SearchResults(imap(IInfo, objs), brains.total, brains.hash_)
开发者ID:ssbunyk,项目名称:zenoss-prodbin,代码行数:11,代码来源:__init__.py

示例11: remote_createAllUsers

 def remote_createAllUsers(self):
     cat = ICatalogTool(self.dmd)
     brains = cat.search(("Products.ZenModel.Device.Device", "Products.ZenModel.DeviceClass.DeviceClass"))
     users = []
     for brain in brains:
         device = brain.getObject()
         user = self._create_user(device)
         if user is not None:
             users.append(user)
     fmt = 'SnmpTrapConfig.remote_createAllUsers {0} users'
     log.debug(fmt.format(len(users)))
     return users
开发者ID:SteelHouseLabs,项目名称:zenoss-prodbin,代码行数:12,代码来源:SnmpTrapConfig.py

示例12: getSubComponents

 def getSubComponents(self):
     cat = ICatalogTool(self)
     query = And(Not(Eq('objectImplements', 'Products.ZenModel.ComponentGroup.ComponentGroup')),
                 Not(Eq('objectImplements', 'Products.ZenModel.Device.Device')))
     brains = cat.search(query=query)
     children = []
     for brain in brains:
         try:
             children.append(brain.getObject())
         except:
             pass
     return children
开发者ID:bbc,项目名称:zenoss-prodbin,代码行数:12,代码来源:ComponentGroup.py

示例13: interfaces_by_names

def interfaces_by_names(device, interface_names, type_='Interface'):
    """Yield Interface objects matching the given names."""
    catalog = ICatalogTool(device.primaryAq())

    name_equals = (Eq('name', x) for x in interface_names)

    search_results = catalog.search(
        types=('ZenPacks.Rackspace.BTI7200.%s.%s' % (type_, type_,)),
        query=Or(*name_equals))

    for result in search_results.results:
        yield result.getObject()
开发者ID:Hackman238,项目名称:ZenPacks.Rackspace.BTI7200,代码行数:12,代码来源:utils.py

示例14: keyword_search

def keyword_search(root, keywords):
    """Generate objects that match one or more of given keywords."""
    if isinstance(keywords, basestring):
        keywords = [keywords]
    elif isinstance(keywords, set):
        keywords = list(keywords)

    if keywords:
        catalog = ICatalogTool(root)
        query = In('searchKeywords', keywords)
        for result in catalog.search(query=query):
            try:
                yield result.getObject()
            except Exception:
                pass
开发者ID:zenoss,项目名称:ZenPacks.zenoss.LinuxMonitor,代码行数:15,代码来源:util.py

示例15: __init__

 def __init__(self, ob, root=None, parent=None):
     self._root = root or self
     if getattr(self._root, '_ob_cache', None) is None:
         self._root._ob_cache = {}
     if not ICatalogBrain.providedBy(ob):
         brain = ICatalogTool(ob).getBrain(ob)
         if brain is None:
             raise UncataloguedObjectException(ob)
         # We already have the object - cache it here so _get_object doesn't
         # have to look it up again.
         self._root._ob_cache[brain.getPath()] = ob
         ob = brain
     self._object = ob
     self._parent = parent or None
     self._severity = None
开发者ID:wkharold,项目名称:zenoss-prodbin,代码行数:15,代码来源:tree.py


注:本文中的Products.Zuul.interfaces.ICatalogTool类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。