Пример #1
0
 def cutover(self, dmd):
     devices = dmd.getDmdRoot('Devices')
     zcat = devices.deviceSearch
     cat = zcat._catalog
     reindex = False
     for indexName in fieldIndexes:
         try:
             cat.addIndex(indexName, makeFieldIndex(indexName))
             reindex = True
         except CatalogError:
             pass
     for indexName in pathIndexes:
         try:
             cat.addIndex(indexName, makePathIndex(indexName))
             reindex = True
         except CatalogError:
             pass
     try:
         cat.addColumn('id')
         reindex = True
     except CatalogError:
         pass
     if reindex:
         print "Reindexing. This may take some time..."
         devices.reIndex()
 def cutover(self, dmd):
     devices = dmd.getDmdRoot('Devices')
     zcat = devices.deviceSearch
     cat = zcat._catalog
     reindex = False
     for indexName in fieldIndexes:
         try: 
             cat.addIndex(indexName, makeFieldIndex(indexName))
             reindex = True
         except CatalogError:
             pass
     for indexName in pathIndexes:
         try: 
             cat.addIndex(indexName, makePathIndex(indexName))
             reindex = True
         except CatalogError:
             pass
     try: 
         cat.addColumn('id')
         reindex = True
     except CatalogError:
         pass
     if reindex: 
         print "Reindexing. This may take some time..."
         devices.reIndex()
Пример #3
0
def createMaintenanceWindowCatalog(dmd):

    catalog_name = 'maintenanceWindowSearch'

    manage_addZCatalog(dmd, catalog_name, catalog_name)
    cat = getToolByName(dmd, catalog_name)

    id_index = makeCaseInsensitiveFieldIndex('getId')
    cat._catalog.addIndex('id', id_index)
    cat.addColumn('id')
    cat._catalog.addIndex('getPhysicalPath', makePathIndex('getPhysicalPath'))
    cat.addColumn('getPhysicalPath')
Пример #4
0
def createMaintenanceWindowCatalog(dmd):

    catalog_name = 'maintenanceWindowSearch'

    manage_addZCatalog(dmd, catalog_name, catalog_name)
    cat = getToolByName(dmd, catalog_name)

    id_index = makeCaseInsensitiveFieldIndex('getId')
    cat._catalog.addIndex('id', id_index)
    cat.addColumn('id')
    cat._catalog.addIndex('getPhysicalPath', makePathIndex('getPhysicalPath'))
    cat.addColumn('getPhysicalPath')
Пример #5
0
def createMaintenanceWindowCatalog(dmd):

    catalog_name = "maintenanceWindowSearch"

    manage_addZCatalog(dmd, catalog_name, catalog_name)
    cat = getToolByName(dmd, catalog_name)

    id_index = makeCaseInsensitiveFieldIndex("getId")
    cat._catalog.addIndex("id", id_index)
    cat.addColumn("id")
    cat._catalog.addIndex("getPhysicalPath", makePathIndex("getPhysicalPath"))
    cat.addColumn("getPhysicalPath")
Пример #6
0
def CreateRRDTemplatesCatalog(dmd, rebuild=False):
    """
    Create the searchRRDTemplates catalog if it does not already exist.
    Return the catalog.
    """
    from Products.ZCatalog.ZCatalog import manage_addZCatalog
    from Products.ZenUtils.Search import makeCaseSensitiveFieldIndex, \
                                            makePathIndex
    zcat = getattr(dmd, RRDTEMPLATE_CATALOG, None)
    if zcat and rebuild:
        dmd._delObject(RRDTEMPLATE_CATALOG)
        zcat = None
    if zcat is None:
        manage_addZCatalog(dmd, RRDTEMPLATE_CATALOG, RRDTEMPLATE_CATALOG)
        zcat = dmd._getOb(RRDTEMPLATE_CATALOG)
        cat = zcat._catalog
        cat.addIndex('id', makeCaseSensitiveFieldIndex('id'))
        cat.addIndex('getPhysicalPath', makePathIndex('getPhysicalPath'))
    return zcat
Пример #7
0
def CreateRRDTemplatesCatalog(dmd, rebuild=False):
    """
    Create the searchRRDTemplates catalog if it does not already exist.
    Return the catalog.
    """
    from Products.ZCatalog.ZCatalog import manage_addZCatalog
    from Products.ZenUtils.Search import makeCaseSensitiveFieldIndex, \
                                            makePathIndex
    zcat = getattr(dmd, RRDTEMPLATE_CATALOG, None)
    if zcat and rebuild:
        dmd._delObject(RRDTEMPLATE_CATALOG)
        zcat = None
    if zcat is None:
        manage_addZCatalog(dmd, RRDTEMPLATE_CATALOG, RRDTEMPLATE_CATALOG)
        zcat = dmd._getOb(RRDTEMPLATE_CATALOG)
        cat = zcat._catalog
        cat.addIndex('id', makeCaseSensitiveFieldIndex('id'))
        cat.addIndex('getPhysicalPath', makePathIndex('getPhysicalPath'))
    return zcat
Пример #8
0
    def createCatalog(self):
        """
        Make the catalog for device searching
        """
        from Products.ZCatalog.ZCatalog import manage_addZCatalog

        # Make catalog for Devices
        manage_addZCatalog(self, self.default_catalog,
            self.default_catalog)
        zcat = self._getOb(self.default_catalog)
        cat = zcat._catalog
        for idxname in ['id',
            'getDeviceIp','getDeviceClassPath','getProdState','titleOrId']:
            cat.addIndex(idxname, makeCaseInsensitiveFieldIndex(idxname))
        cat.addIndex('getPhysicalPath', makePathIndex('getPhysicalPath'))
        cat.addIndex('path', makeMultiPathIndex('path'))
        zcat.addColumn('getPrimaryId')
        zcat.addColumn('id')
        zcat.addColumn('path')
Пример #9
0
    def createCatalog(self):
        """
        Make the catalog for device searching
        """
        from Products.ZCatalog.ZCatalog import manage_addZCatalog

        # Make catalog for Devices
        manage_addZCatalog(self, self.default_catalog,
            self.default_catalog)
        zcat = self._getOb(self.default_catalog)
        cat = zcat._catalog
        for idxname in ['id',
            'getDeviceIp','getDeviceClassPath','getProdState','titleOrId']:
            cat.addIndex(idxname, makeCaseInsensitiveFieldIndex(idxname))
        cat.addIndex('getPhysicalPath', makePathIndex('getPhysicalPath'))
        cat.addIndex('path', makeMultiPathIndex('path'))
        zcat.addColumn('getPrimaryId')
        zcat.addColumn('id')
        zcat.addColumn('path')
Пример #10
0
 def cutover(self, dmd):
     idx = dmd.Devices.deviceSearch._catalog.indexes['path']
     idx_parents = getattr(idx, '_index_parents', None)
     if idx_parents is None:
         dmd.Devices.deviceSearch.delIndex('path')
         dmd.Devices.deviceSearch._catalog.addIndex('path', 
                 makeMultiPathIndex('path'))
         # grab each device and manually reindex it
         log.info( 'Reindexing devices.  This may take a while ...' )
         for device in dmd.Devices.getSubDevices_recursive():
             dmd.Devices.deviceSearch.catalog_object(device, idxs=('path',))
             
     idx = dmd.searchRRDTemplates._catalog.indexes['getPhysicalPath']
     if not idx.__class__.__name__=='ExtendedPathIndex':
         templates = dmd.searchRRDTemplates()
         dmd.searchRRDTemplates.delIndex('getPhysicalPath')
         dmd.searchRRDTemplates._catalog.addIndex('getPhysicalPath', 
                 makePathIndex('getPhysicalPath'))
         for template in templates:
             dmd.searchRRDTemplates.catalog_object(template.getObject(), idxs=('getPhysicalPath',))
 def _createNewIndex(self, mwcat ):
     log.info("Adding new columns to the dmd.maintenanceWindowSearch catalog.")
     mwcat._catalog.addIndex('getPhysicalPath', makePathIndex('getPhysicalPath'))
     mwcat.addColumn('getPhysicalPath')