Exemplo n.º 1
0
 def test(self, dmd):
     from Products.Zuul.interfaces import ICatalogTool
     results = ICatalogTool(dmd.Devices).search(
         'Products.ZenModel.DeviceOrganizer.DeviceOrganizer')
     instances = ICatalogTool(
         dmd.Devices).search('Products.ZenModel.Device.Device')
     tree = PathIndexCache(results, instances, 'devices')
    def getEdges(self):
        for impact in super(DeviceRelationsProvider, self).getEdges():
            yield impact

        # File Systems
        for obj in self._object.os.filesystems():
            yield edge(guid(obj), self.guid())

        # Processors
        for obj in self._object.hw.cpus():
            yield edge(guid(obj), self.guid())

        # Cluster Services
        for obj in self._object.os.clusterservices():
            yield edge(guid(obj), self.guid())

        for obj in self._object.os.winrmservices():
            yield edge(self.guid(), guid(obj))

        # Look up for HyperV server with same IP
        try:
            dc = self._object.getDmdRoot('Devices').getOrganizer(
                '/Server/Microsoft/HyperV')
        except Exception:
            return

        results = ICatalogTool(dc).search(
            types=('ZenPacks.zenoss.Microsoft.HyperV.HyperVVSMS.HyperVVSMS', ))

        for brain in results:
            obj = brain.getObject()
            if obj.ip == self._object.id:
                yield edge(self.guid(), guid(obj))
Exemplo n.º 3
0
    def _processSearch(self,
                       limit=None,
                       start=None,
                       sort='name',
                       dir='ASC',
                       params=None,
                       uid=None,
                       criteria=()):
        ob = self._getObject(uid) if isinstance(uid, basestring) else uid
        cat = ICatalogTool(ob)

        reverse = dir == 'DESC'
        qs = []
        query = None
        if params:
            if 'name' in params:
                qs.append(MatchRegexp('name', '(?i).*%s.*' % params['name']))
        if qs:
            query = And(*qs)

        return cat.search("Products.ZenModel.OSProcessClass.OSProcessClass",
                          start=start,
                          limit=limit,
                          orderby=sort,
                          reverse=reverse,
                          query=query)
Exemplo n.º 4
0
    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_)
Exemplo n.º 5
0
    def getAddTemplateTargets(self, query=None):
        """
        @returns list of targets for our new template
        """
        cat = ICatalogTool(self._dmd)
        results = []
        # it can be any device class that we add the template too
        brains = cat.search(types=[DeviceClass])
        for brain in brains:
            # HACK: use the path to get the organizer name so we don't have to wake up the object
            label = brain.getPath()
            if label == "/zport/dmd/Devices":
                label = "/"
            else:
                label = label.replace("/zport/dmd/Devices/", "/")

            results.append(dict(uid=brain.getPath(), label=label))
        # the display is organizer name and we do not index it
        # so filter after the query
        if query is not None:
            results = [
                result for result in results
                if query.lower() in result['label'].lower()
            ]
        return sorted(results, key=lambda org: org['label'])
Exemplo n.º 6
0
    def deleteNode(self, uid):
        """
        Remove a report or report organizer.

        @type  uid: string
        @param uid: The UID of the node to delete
        @rtype:   [dictionary]
        @return:  B{Properties}:
           - tree: (dictionary) Object representing the new Reports tree
        """
        # make sure we are not deleting a required node
        if uid in essentialReportOrganizers:
            raise Exception('You cannot delete this organizer')

        # Getting all of the child nodes for auditing purposes
        node = self.context.dmd.unrestrictedTraverse(uid)
        brains = ICatalogTool(node).search((ReportClass,BaseReport))
        family = []
        for brain in brains:
            family.append([brain.getPath(), isinstance(brain.getObject(), ReportClass)])

        self._getFacade().deleteNode(uid)

        # Audit messaging
        for name, isOrganizer in family:
            if isOrganizer:
                audit('UI.Organizer.Delete', name)
            else:
                audit('UI.Report.Delete', name)

        contextUid = '/'.join(uid.split('/')[:-1])
        return self._getTreeUpdates(contextUid)
    def migrate(self, pack):
        results = ICatalogTool(pack.dmd.Devices).search(Tenant)

        LOG.info("starting: %s total devices", results.total)
        progress = ProgressLogger(
            LOG,
            prefix="progress",
            total=results.total,
            interval=PROGRESS_LOG_INTERVAL)

        objects_migrated = 0

        for brain in results:
            try:
                if self.updateRelations(brain.getObject()):
                    objects_migrated += 1
            except Exception:
                LOG.exception(
                    "error updating relationships for %s",
                    brain.id)

            progress.increment()

        LOG.info(
            "finished: %s of %s devices required migration",
            objects_migrated,
            results.total)
    def remove(self, app, leaveObjects=False):
        if not leaveObjects:
            self.remove_plugin_symlinks()

            log.info(
                'Removing ZenPacks.zenoss.OrderedComponentLists components')
            cat = ICatalogTool(app.zport.dmd)

            # Search the catalog for components of this zenpacks type.
            if NEW_COMPONENT_TYPES:
                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])

            log.info(
                'Removing ZenPacks.zenoss.OrderedComponentLists relationships from existing devices'
            )
            self._buildDeviceRelations()

        super(ZenPack, self).remove(app, leaveObjects=leaveObjects)
Exemplo n.º 9
0
    def _serviceSearch(self,
                       limit=None,
                       start=None,
                       sort='name',
                       dir='ASC',
                       params=None,
                       uid=None,
                       criteria=()):
        cat = ICatalogTool(self._getObject(uid))
        reverse = dir == 'DESC'

        qs = []
        query = None
        if params:
            if 'name' in params:
                qs.append(MatchRegexp('name', '(?i).*%s.*' % params['name']))
            if 'port' in params:
                qs.append(MatchRegexp('port', '(?i).*%s.*' % params['port']))
        if qs:
            query = And(*qs)

        return cat.search("Products.ZenModel.ServiceClass.ServiceClass",
                          start=start,
                          limit=limit,
                          orderby=sort,
                          reverse=reverse,
                          query=query)
Exemplo n.º 10
0
    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
Exemplo n.º 11
0
    def _search_catalog(self, obj, types=(), paths=(), query=None):
        if USE_MODEL_CATALOG:
            catalog = IModelCatalogTool(obj)
        else:
            catalog = ICatalogTool(obj)

        return catalog.search(types=types, paths=paths, query=query)
Exemplo n.º 12
0
 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)
Exemplo n.º 13
0
    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()
 def migrate(self, pack):
     hd_fs_brains = ICatalogTool(pack.dmd.Devices).search(HardDisk)
     for result in hd_fs_brains:
         try:
             notify(IndexingEvent(result.getObject()))
         except Exception:
             continue
    def remove(self, app, leaveObjects=False):
        if not leaveObjects:

            from Products.ZenModel.DeviceHW import DeviceHW

            NEW_COMPONENT_TYPES = tuple([x for x in productNames])

            log.info('Removing ZenPacks.community.CiscoEnvmonE components')
            cat = ICatalogTool(app.zport.dmd)

            # Search the catalog for components of this zenpacks type.
            if NEW_COMPONENT_TYPES:
                for brain in cat.search(types=NEW_COMPONENT_TYPES):
                    component = brain.getObject()
                    component.getPrimaryParent()._delObject(component.id)

            hw_relations = ("ciscoenvvoltagesensors", "ciscoenvtempsensors"
                            "ciscoenvfans"
                            "ciscoenvpowersupplies")

            # remote HW component relations
            DeviceHW._relations = tuple(
                [x for x in DeviceHW._relations if x[0] not in hw_relations])

            log.info('Removing ZenPacks.community.CiscoEnvMonE'
                     'relationships from existing devices')

            self._buildHWRelations()

        super(ZenPack, self).remove(app, leaveObjects=leaveObjects)
Exemplo n.º 16
0
 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
Exemplo n.º 17
0
    def migrate(self, dmd):
        # Add state datasource/datapoint to subclasses
        # This will catch any device specific templates and make this migration quicker
        results = ICatalogTool(
            dmd.Devices.Server.Microsoft).search(RRDTemplate)
        if results.total == 0:
            return
        log.info('Searching for WinService templates.')
        templates = []
        for result in results:
            try:
                template = result.getObject()
            except Exception:
                continue
            if getattr(template, 'targetPythonClass',
                       '') == 'ZenPacks.zenoss.Microsoft.Windows.WinService':
                templates.append(template)

        progress = progresslog.ProgressLogger(log,
                                              prefix="WinService state",
                                              total=results.total,
                                              interval=PROGRESS_LOG_INTERVAL)

        for template in templates:
            progress.increment()
            self.add_state_ds_dp(template)
Exemplo n.º 18
0
    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)
Exemplo n.º 19
0
 def cutover(self, dmd):
     items = ICatalogTool(dmd).search('Products.ZenModel.ZenMenuItem.ZenMenuItem')
     for brain in items:
         menuitem = brain.getObject()
         action = menuitem.action
         if action in ('../viewHistory', 'viewHistory', 'viewNewHistory'):
             menuitem.__primary_parent__.removeRelation(menuitem)
 def cutover(self, dmd):
     log.info(
         "Removing ignoreParameters and ignoreParametersWhenModeling from all OSProcessClass objects"
     )
     try:
         for brain in ICatalogTool(dmd).search(OSProcessClass):
             try:
                 pc = brain.getObject()
             except Exception:
                 log.warn("Failed to get %s", brain.getPath())
             else:
                 try:
                     ignore = False
                     if getattr(pc, 'ignoreParameters', False):
                         ignore = True
                         pc.ignoreParameters = False
                     if getattr(pc, 'ignoreParametersWhenModeling', False):
                         ignore = True
                         pc.ignoreParametersWhenModeling = False
                     if ignore and not getattr(pc, 'replaceRegex', False):
                         pc.replaceRegex = '.*'
                         pc.replacement = pc.name
                 except Exception:
                     log.warn("Failed to migrate %s",
                              brain.getPath(),
                              exc_info=True)
     except Exception:
         log.fail('Unable to search for OSProcessClass objects')
    def migrate(self, pack):
        LOG.info("Reindexing Processes")
        results = ICatalogTool(pack.getDmdRoot("Devices")).search(
            types=('ZenPacks.zenoss.Microsoft.Windows.OSProcess.OSProcess', ))

        if not results.total:
            return

        LOG.info("Found {} Processes that may require indexing".format(
            results.total))
        progress = progresslog.ProgressLogger(LOG,
                                              prefix="progress",
                                              total=results.total,
                                              interval=PROGRESS_LOG_INTERVAL)

        objects_migrated = 0

        for result in results:
            if self.migrate_result(result):
                objects_migrated += 1

            progress.increment()

        LOG.info("Finished indexing {} of {} Processes".format(
            objects_migrated, results.total))
Exemplo n.º 22
0
 def cutover(self, dmd):
     if not hasattr(dmd, '_clearedUserSettingsExtJs4'):
         for brain in ICatalogTool(dmd).search(
                 'Products.ZenModel.UserSettings.UserSettings'):
             user = brain.getObject()
             if hasattr(user, '_browser_state'):
                 del brain.getObject()._browser_state
         dmd._clearedUserSettingsExtJs4 = True
Exemplo n.º 23
0
    def _findDevices(self, identifier, ipAddress, limit=None):
        """
        Returns a tuple ([device brains], [devices]) searching manage IP and
        interface IPs. limit is the maximum total number in both lists.
        """
        dev_cat = ICatalogTool(self._devices)

        try:
            ip_address = next(i for i in (ipAddress, identifier) if isip(i))
            ip_decimal = ipToDecimal(ip_address)
        except Exception:
            ip_address = None
            ip_decimal = None

        query_set = Or(Eq('id', identifier), Eq('name', identifier))
        if ip_decimal is not None:
            query_set.addSubquery(Eq('ipAddress', str(ip_decimal)))
        device_brains = list(
            dev_cat.search(types=Device,
                           query=query_set,
                           limit=limit,
                           filterPermissions=False))

        limit = None if limit is None else limit - len(device_brains)
        if not limit:
            return device_brains, []

        if ip_decimal is not None:
            # don't search interfaces for 127.x.x.x IPv4 addresses
            if ipToDecimal('126.255.255.255') < ip_decimal < ipToDecimal(
                    '128.0.0.0'):
                ip_decimal = None
            # don't search interfaces for the ::1 IPv6 address
            elif ipToDecimal('::1') == ip_decimal:
                ip_decimal = None
        if ip_decimal is None:
            return [], []

        net_cat = ICatalogTool(self._networks)
        results = net_cat.search(types=IpAddress,
                                 query=(Eq('name', ip_address)),
                                 limit=limit,
                                 filterPermissions=False)
        devices = [brain.getObject().device() for brain in results]

        return device_brains, devices
Exemplo n.º 24
0
 def findMatchingOrganizers(self, organizerClass, organizerPath, userFilter):
     filterRegex = '(?i)^%s.*%s.*' % (organizerPath, userFilter)
     if self.validRegex(filterRegex):
         orgquery = (Eq('objectImplements','Products.ZenModel.%s.%s' % (organizerClass, organizerClass)) &
                     MatchRegexp('uid', filterRegex))
         paths = [b.getPath() for b in ICatalogTool(self._dmd).search(query=orgquery)]
         if paths:
             return Generic('path', {'query':paths})
Exemplo n.º 25
0
 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)
Exemplo n.º 26
0
    def run(self):
        if len(sys.argv) < 2:
            raise ValueError("Usage: reportable.py <device name>")

        device_name = sys.argv[1]

        import ZenPacks.zenoss.ZenETL
        zcml.load_config('configure.zcml', ZenPacks.zenoss.ZenETL)

        import ZenPacks.zenoss.vSphere
        zcml.load_config('configure.zcml', ZenPacks.zenoss.vSphere)

        self.connect()

        device = self.dmd.Devices.findDevice(device_name)
        if not device:
            raise ValueError("Device not found")

        for brain in ICatalogTool(device).search():
            try:
                component = brain.getObject()
            except Exception:
                # ignore a stale entry
                pass
            else:
                factory = IReportableFactory(component)

                for reportable in factory.exports():
                    if reportable.id in ('os', 'hw'):
                        # not my problem.
                        continue

                    print "      adapter=%s.%s -> %s.%s" % (
                        factory.__class__.__module__,
                        factory.__class__.__name__,
                        reportable.__class__.__module__,
                        reportable.__class__.__name__,
                    )
                    print "      reportable.entity_class_name=%s" % reportable.entity_class_name
                    print "      reportable.id=%s, sid=%s" % (reportable.id,
                                                              reportable.sid)

                    props = reportable.reportProperties()

                    for name, type_, value, length in props:
                        if name in ('snmpindex', 'monitor', 'productionState',
                                    'preMWProductionState'):
                            # boring, so let's omit them.
                            continue

                        if length == -1:
                            print "         %s [%s] = %s" % (name, type_,
                                                             value)
                        else:
                            print "         %s [%s.%s] = %s" % (name, type_,
                                                                length, value)

                    print ""
Exemplo n.º 27
0
    def migrate(self, pack):
        dmd = pack.getDmd()

        try:
            deviceclass = dmd.Devices.getOrganizer(DEVICECLASS)
        except Exception:
            return

        # This would be done by zenpacklib, but good to log it and be explicit.
        if deviceclass.getZ(PROP_zPythonClass) != TO_zPythonClass:
            LOG.info(
                "changing %s %s to %s",
                deviceclass.getOrganizerName(),
                PROP_zPythonClass,
                TO_zPythonClass)

            deviceclass.setZenProperty(PROP_zPythonClass, TO_zPythonClass)

        # Remove any overrides of zPythonClass in child device classes.
        for subdc in deviceclass.getSubOrganizers():
            if subdc.hasProperty(PROP_zPythonClass):
                LOG.info(
                    "removing %s override of %s",
                    subdc.getOrganizerName(),
                    PROP_zPythonClass)

                subdc.deleteZenProperty(PROP_zPythonClass)

        # Estimated total. Only as correct as the global catalog.
        total = ICatalogTool(deviceclass).search(BaseDevice).total
        LOG.info("converting approximately %s devices", total)

        # Add progress indication. This could take a while if there are a lot
        # of Linux devices.
        progress = progresslog.ProgressLogger(
            LOG,
            prefix="progress",
            total=total,
            interval=PROGRESS_LOG_INTERVAL)

        # Move devices that aren't a LinuxDevice back into their same device
        # class. This will cause them to be recreated with the new type. We
        # don't use the catalog to find devices here because we want to be
        # absolutely sure that we convert all devices.
        with pausedAndOptimizedReindexing():
            with logLevel("zen.GraphChangeFactory", level=logging.ERROR):
                for device in deviceclass.getSubDevicesGen_recursive():
                    if not isinstance(device, LinuxDevice):
                        reclass_device(device, LinuxDevice)

                        # LinuxDevice has more relations than Device. We must
                        # cause them to be created on the reclassed device.
                        device.buildRelations()

                        progress.increment()

        LOG.info("finished converting %s devices", progress.pos)
Exemplo n.º 28
0
 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())
Exemplo n.º 29
0
 def _migrateWinPerfDataSource(self, dmd):
     from ZenPacks.zenoss.WindowsMonitor.datasources.WinPerfDataSource import WinPerfDataSource
     oldCls = "ZenPacks.zenoss.ZenWinPerf.datasources.WinPerfDataSource.WinPerfDataSource"
     results = ICatalogTool(dmd).search(oldCls)
     log.info("Converting %d datasources", results.total)
     for brain in results:
         obj = brain.getObject()
         obj.__class__ = WinPerfDataSource
         obj._p_changed = True
         self._persistDataSource(obj)
    def reindex_catalog(cls, context, zcatalog, classname):
        from Products.Zuul.interfaces import ICatalogTool

        for result in ICatalogTool(context).search(types=(classname, )):
            try:
                obj = result.getObject()
            except Exception as e:
                cls.LOG.warning("failed to index non-existent object: %s", e)
            else:
                zcatalog.catalog_object(obj, obj.getPrimaryId())