Esempio n. 1
0
def createUtils(root_folder, connection=None, dummy_db=None):
    # search in global component registry
    sitem = root_folder.getSiteManager()
    # search for ICatalog
    utils = [ util for util in sitem.registeredUtilities()
              if util.provided.isOrExtends(ICatalog)]
    instUtilityICatalog = utils[0].component
    if not "patchpanel_oid_index" in instUtilityICatalog.keys():
        patchpanel_oid_index = KeywordIndex(interface=ISearchableText,
                                        field_name='getSearchablePatchPanelOid',
                                        field_callable=True)
        instUtilityICatalog['patchpanel_oid_index'] = patchpanel_oid_index
        # search for IAdmUtilSupervisor
        utils = [ util for util in sitem.registeredUtilities()
                  if util.provided.isOrExtends(IAdmUtilSupervisor)]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: ICatalog - create index for entry type 'patchpanel'")

    ensureComponentFolderOnBootstrap(\
         IPatchPanelFolder,
         u"PatchPanels",
         u'org.ict_ok.components.patchpanel.patchpanel.PatchPanelFolder',
         root_folder,
         sitem)

    transaction.get().commit()
    if connection is not None:
        connection.close()
Esempio n. 2
0
def createUtils(root_folder, connection=None, dummy_db=None):
    # search in global component registry
    sitem = root_folder.getSiteManager()
    # search for ICatalog
    utils = [
        util for util in sitem.registeredUtilities()
        if util.provided.isOrExtends(ICatalog)
    ]
    instUtilityICatalog = utils[0].component
    if not "interface_oid_index" in instUtilityICatalog.keys():
        interface_oid_index = KeywordIndex(
            interface=ISearchableText,
            field_name='getSearchableInterfaceOid',
            field_callable=True)
        instUtilityICatalog['interface_oid_index'] = interface_oid_index
        # search for IAdmUtilSupervisor
        utils = [
            util for util in sitem.registeredUtilities()
            if util.provided.isOrExtends(IAdmUtilSupervisor)
        ]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: ICatalog - create index for entry type 'interface'")


#    if not "interface_ip_index" in instUtilityICatalog.keys():
#        interface_ip_index = TextIndex(interface=ISearchableText,
#                                       field_name='getSearchableInterfaceIp',
#                                       field_callable=True)
#        instUtilityICatalog['interface_ip_index'] = interface_ip_index
#        # search for IAdmUtilSupervisor
#        utils = [ util for util in sitem.registeredUtilities()
#                  if util.provided.isOrExtends(IAdmUtilSupervisor)]
#        instAdmUtilSupervisor = utils[0].component
#        instAdmUtilSupervisor.appendEventHistory(\
#            u" bootstrap: ICatalog - create ip index for 'interface'")
    if not "interface_mac_index" in instUtilityICatalog.keys():
        interface_mac_index = TextIndex(interface=ISearchableText,
                                        field_name='getSearchableInterfaceMac',
                                        field_callable=True)
        instUtilityICatalog['interface_mac_index'] = interface_mac_index
        # search for IAdmUtilSupervisor
        utils = [
            util for util in sitem.registeredUtilities()
            if util.provided.isOrExtends(IAdmUtilSupervisor)
        ]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: ICatalog - create mac index for 'interface'")

    ensureComponentFolderOnBootstrap(
        IInterfaceFolder, u"Interfaces",
        u'org.ict_ok.components.interface.interface.InterfaceFolder',
        root_folder, sitem)

    transaction.get().commit()
    if connection is not None:
        connection.close()
Esempio n. 3
0
def bootStrapSubscriber(event):
    """initialisation of IntId utility on first database startup
    """
    if appsetup.getConfigContext().hasFeature('devmode'):
        logger.info(u"starting bootStrapSubscriberDatabase (org.ict_ok...)")
    dummy_db, connection, dummy_root, root_folder = \
            getInformationFromEvent(event)
    # search in global component registry
    sitem = root_folder.getSiteManager()
    # search for ICatalog
    utils = [
        util for util in sitem.registeredUtilities()
        if util.provided.isOrExtends(ICatalog)
    ]
    instUtilityICatalog = utils[0].component
    if not "script_oid_index" in instUtilityICatalog.keys():
        script_oid_index = KeywordIndex(interface=ISearchableText,
                                        field_name='getSearchableScriptOid',
                                        field_callable=True)
        instUtilityICatalog['script_oid_index'] = script_oid_index
        # search for IAdmUtilSupervisor
        utils = [
            util for util in sitem.registeredUtilities()
            if util.provided.isOrExtends(IAdmUtilSupervisor)
        ]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: ICatalog - create index for entry type 'script'")

    folderName = u"MobilePhones"
    if folderName not in root_folder.keys():
        #newFolder = TestComponentFolder()
        newFolder = createObject(
            u'org.ict_ok.components.mobilephone.mobilephone.MobilePhoneFolder')
        root_folder[folderName] = newFolder
        dcore = IZopeDublinCore(newFolder, None)
        #dcore.creators = [u'ikportscan']
        #newFolder.ikComment += u"scanner: %s" % (dateNow)
        newFolder.__setattr__("ikName", folderName)
        dcore.title = folderName

    transaction.get().commit()
    connection.close()
Esempio n. 4
0
def createUtils(root_folder, connection=None, dummy_db=None):
    # search in global component registry
    sitem = root_folder.getSiteManager()
    # search for ICatalog
    utils = [ util for util in sitem.registeredUtilities()
              if util.provided.isOrExtends(ICatalog)]
    instUtilityICatalog = utils[0].component
    if not "reminder_oid_index" in instUtilityICatalog.keys():
        reminder_oid_index = KeywordIndex(interface=ISearchableText,
                                        field_name='getSearchableReminderOid',
                                        field_callable=True)
        instUtilityICatalog['reminder_oid_index'] = reminder_oid_index
        # search for IAdmUtilSupervisor
        utils = [ util for util in sitem.registeredUtilities()
                  if util.provided.isOrExtends(IAdmUtilSupervisor)]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: ICatalog - create index for entry type 'reminder'")
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: ICatalog - create index for entry type 'appsoftware'")

    transaction.get().commit()
    if connection is not None:
        connection.close()
Esempio n. 5
0
def createUtils(root_folder, connection=None, dummy_db=None):
    # search in global component registry
    sitem = root_folder.getSiteManager()
    # search for ICatalog
    utils = [
        util for util in sitem.registeredUtilities()
        if util.provided.isOrExtends(ICatalog)
    ]
    instUtilityICatalog = utils[0].component
    if not "host_oid_index" in instUtilityICatalog.keys():
        host_oid_index = FieldIndex(interface=ISearchableText,
                                    field_name='getSearchableHostOid',
                                    field_callable=True)
        instUtilityICatalog['host_oid_index'] = host_oid_index
        # search for IAdmUtilSupervisor
        utils = [
            util for util in sitem.registeredUtilities()
            if util.provided.isOrExtends(IAdmUtilSupervisor)
        ]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: ICatalog - create oid index for entry type 'host'")
    if not "host_hostname_index" in instUtilityICatalog.keys():
        host_hostname_index = FieldIndex(
            interface=ISearchableText,
            field_name='getSearchableHostHostname',
            field_callable=True)
        instUtilityICatalog['host_hostname_index'] = host_hostname_index
        # search for IAdmUtilSupervisor
        utils = [
            util for util in sitem.registeredUtilities()
            if util.provided.isOrExtends(IAdmUtilSupervisor)
        ]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: ICatalog - create hostname index for entry type 'host'")
    if not "host_room_oid_index" in instUtilityICatalog.keys():
        host_room_oid_index = KeywordIndex(
            interface=ISearchableText,
            field_name='getSearchableHostRoomOid',
            field_callable=True)
        instUtilityICatalog['host_room_oid_index'] = host_room_oid_index
        # search for IAdmUtilSupervisor
        utils = [
            util for util in sitem.registeredUtilities()
            if util.provided.isOrExtends(IAdmUtilSupervisor)
        ]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: ICatalog - create room index for entry type 'host'")

    # creates and stores the local system in ZODB
    # createLocalSystem(root_folder)

    ensureComponentFolderOnBootstrap(
        IHostFolder, u"Hosts", u'org.ict_ok.components.host.host.HostFolder',
        root_folder, sitem)

    transaction.get().commit()
    if connection is not None:
        connection.close()
Esempio n. 6
0
def createUtils(root_folder, connection=None, dummy_db=None):
    madeAdmUtilSupervisor = ensureUtility(root_folder, 
                                          IAdmUtilSupervisor,
                                          'AdmUtilSupervisor', 
                                          AdmUtilSupervisor,
                                          name='AdmUtilSupervisor',
                                          copy_to_zlog=False)

    if isinstance(madeAdmUtilSupervisor, AdmUtilSupervisor):
        logger.info(u"bootstrap: Ensure named AdmUtilSupervisor")
    
        instAdmUtilSupervisor = madeAdmUtilSupervisor
        # attribute is defined readonly, so first toggle this
        IAdmUtilSupervisor['nbrStarts'].readonly = False
        instAdmUtilSupervisor.nbrStarts += 1
        IAdmUtilSupervisor['nbrStarts'].readonly = True
        instAdmUtilSupervisor.appendEventHistory(u"'web service' started (Vers. %s)" \
                                                 % getIkVersion())
        dcore = IWriteZopeDublinCore(madeAdmUtilSupervisor)
        dcore.title = u"Supervisor"
        dcore.created = datetime.utcnow()
        madeAdmUtilSupervisor.ikName = dcore.title
        madeAdmUtilSupervisor.__post_init__()
    else:
        # search in global component registry
        sitem = root_folder.getSiteManager()
        utils = [ util for util in sitem.registeredUtilities()
                  if util.provided.isOrExtends(IAdmUtilSupervisor)]
        instAdmUtilSupervisor = utils[0].component
        # attribute is defined readonly, so first toggle this
        IAdmUtilSupervisor['nbrStarts'].readonly = False
        instAdmUtilSupervisor.nbrStarts += 1
        IAdmUtilSupervisor['nbrStarts'].readonly = True
        if dummy_db is not None:
            instAdmUtilSupervisor.appendEventHistory(\
                u"'web service' started (Vers. %s) (%d bytes) (%d objects)" \
                % (getIkVersion(), dummy_db.getSize(), dummy_db.objectCount()))
        dcore = IWriteZopeDublinCore(instAdmUtilSupervisor)
        dcore.title = u"Supervisor"
        dcore.modified = datetime.utcnow()
        
    madeUtilityIIntIds = ensureUtility(root_folder, 
                                       IIntIds, 
                                       '', 
                                       IntIds, 
                                       name='', 
                                       copy_to_zlog=False)

    if isinstance(madeUtilityIIntIds, IntIds):
        logger.info(u"bootstrap: made IIntIds-Utility")
        dcore = IWriteZopeDublinCore(madeUtilityIIntIds)
        dcore.title = u"ICT_Ok Object Id Manager"
        dcore.created = datetime.utcnow()
        sitem = root_folder.getSiteManager()
        utils = [ util for util in sitem.registeredUtilities()
                    if util.provided.isOrExtends(IAdmUtilSupervisor)]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: made IIntIds-Utility")
        
    madeUtilityO2ORels = ensureUtility(root_folder, 
                                       IO2OStringTypeRelationships, 
                                       '', 
                                       O2OStringTypeRelationships, 
                                       name='',
                                       copy_to_zlog=False)

    if isinstance(madeUtilityO2ORels, O2OStringTypeRelationships):
        logger.info(u"bootstrap: made O2ORels-Utility")
        #dcore = IWriteZopeDublinCore(madeUtilityO2ORels)
        #dcore.title = u"ICT_Ok Object Relation Manager"
        #dcore.created = datetime.utcnow()
        sitem = root_folder.getSiteManager()
        utils = [ util for util in sitem.registeredUtilities()
                    if util.provided.isOrExtends(IAdmUtilSupervisor)]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: made O2ORels-Utility")
    else:
        sitem = root_folder.getSiteManager()
        utils = [ util for util in sitem.registeredUtilities()
                  if util.provided.isOrExtends(IO2OStringTypeRelationships)]
        instUtilityO2ORels = utils[0].component

#    import pdb
#    pdb.set_trace()

    madeUtilityICatalog = ensureUtility(root_folder, 
                                        ICatalog, 
                                        '', 
                                        Catalog, 
                                        name='',
                                        copy_to_zlog=False)

    if isinstance(madeUtilityICatalog, Catalog):
        logger.info(u"bootstrap: made ICatalog-Utility")
        dcore = IWriteZopeDublinCore(madeUtilityICatalog)
        dcore.title = u"ICT_Ok Search Manager"
        dcore.created = datetime.utcnow()
#        oid_index = TextIndex(interface=ISearchableText,
#                              field_name='getSearchableOid',
#                              field_callable=True)
#        madeUtilityICatalog['oid_index'] = oid_index
        sitem = root_folder.getSiteManager()
        utils = [ util for util in sitem.registeredUtilities()
                    if util.provided.isOrExtends(IAdmUtilSupervisor)]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: made ICatalog-Utility")

    # search in global component registry
    sitem = root_folder.getSiteManager()
    # search for ICatalog
    utils = [ util for util in sitem.registeredUtilities()
              if util.provided.isOrExtends(ICatalog)]
    instUtilityICatalog = utils[0].component
    if not "oid_index" in instUtilityICatalog.keys():
        oid_index = KeywordIndex(interface=ISearchableText,
                                 field_name='getSearchableOid',
                                 field_callable=True)
        instUtilityICatalog['oid_index'] = oid_index
        # search for IAdmUtilSupervisor
        utils = [ util for util in sitem.registeredUtilities()
                  if util.provided.isOrExtends(IAdmUtilSupervisor)]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: ICatalog - create index for all comments")
    if not "all_comments_index" in instUtilityICatalog.keys():
        all_comments_index = TextIndex(interface=ISearchableText,
                                        field_name='getSearchableComments',
                                        field_callable=True)
        instUtilityICatalog['all_comments_index'] = all_comments_index
        # search for IAdmUtilSupervisor
        utils = [ util for util in sitem.registeredUtilities()
                  if util.provided.isOrExtends(IAdmUtilSupervisor)]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: ICatalog - create index for all comments")
    if not "all_notes_index" in instUtilityICatalog.keys():
        all_notes_index = TextIndex(interface=ISearchableText,
                                        field_name='getSearchableNotes',
                                        field_callable=True)
        instUtilityICatalog['all_notes_index'] = all_notes_index
        # search for IAdmUtilSupervisor
        utils = [ util for util in sitem.registeredUtilities()
                  if util.provided.isOrExtends(IAdmUtilSupervisor)]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: ICatalog - create index for all notes")
    if not "all_fulltext_index" in instUtilityICatalog.keys():
        all_fulltext_index = TextIndex(interface=ISearchableText,
                                        field_name='getSearchableFullText',
                                        field_callable=True)
        instUtilityICatalog['all_fulltext_index'] = all_fulltext_index
        # search for IAdmUtilSupervisor
        utils = [ util for util in sitem.registeredUtilities()
                  if util.provided.isOrExtends(IAdmUtilSupervisor)]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: ICatalog - create index for all fulltext")
    if not "all_interfaces_index" in instUtilityICatalog.keys():
        all_interfaces_index = KeywordIndex(interface=IKeywordQuerying,
                                            field_name='getSearchableInterfaces',
                                            field_callable=True)
        instUtilityICatalog['all_interfaces_index'] = all_interfaces_index
        # search for IAdmUtilSupervisor
        utils = [ util for util in sitem.registeredUtilities()
                  if util.provided.isOrExtends(IAdmUtilSupervisor)]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: ICatalog - create index for all interfaces")
    transaction.get().commit()
    if connection is not None:
        connection.close()
Esempio n. 7
0
def createUtils(root_folder, connection=None, dummy_db=None):
    sitem = root_folder.getSiteManager()
    # search for ICatalog
    utils = [
        util for util in sitem.registeredUtilities()
        if util.provided.isOrExtends(ICatalog)
    ]
    instUtilityICatalog = utils[0].component
    if not "category_oid_index" in instUtilityICatalog.keys():
        category_oid_index = KeywordIndex(
            interface=ISearchableText,
            field_name='getSearchableCategoryOid',
            field_callable=True)
        instUtilityICatalog['category_oid_index'] = category_oid_index
        # search for IAdmUtilSupervisor
        utils = [
            util for util in sitem.registeredUtilities()
            if util.provided.isOrExtends(IAdmUtilSupervisor)
        ]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: ICatalog - create index for entry type 'category'")

    madeAdmUtilCategories = ensureUtility(root_folder,
                                          IAdmUtilCategories,
                                          'AdmUtilCategories',
                                          AdmUtilCategories,
                                          name='AdmUtilCategories',
                                          copy_to_zlog=False)
    if isinstance(madeAdmUtilCategories, AdmUtilCategories):
        logger.info(u"bootstrap: Ensure named AdmUtilCategories")
        dcore = IWriteZopeDublinCore(madeAdmUtilCategories)
        dcore.title = u"Categories Utility"
        dcore.created = datetime.utcnow()
        madeAdmUtilCategories.ikName = dcore.title
        #        for strHostGroup in [
        #            u'DNS-Server',
        #            u'File-Server',
        #            u'Miscellaneous-Server',
        #            u'SMTP-Server',
        #            u'Terminal-Server',
        #            u'Utility-Server',
        #            u'Workstation',
        #            ]:
        #            newHostGroup = AdmUtilCatHostGroup()
        #            newHostGroup.__setattr__("ikName", strHostGroup)
        #            dcore = IWriteZopeDublinCore(newHostGroup)
        #            dcore.created = datetime.utcnow()
        #            dcore.title = strHostGroup
        #            madeAdmUtilCategories[newHostGroup.objectID] = newHostGroup
        madeAdmUtilCategories.__post_init__()
        sitem = root_folder.getSiteManager()
        utils = [
            util for util in sitem.registeredUtilities()
            if util.provided.isOrExtends(IAdmUtilSupervisor)
        ]
        instAdmUtilSupervisor = utils[0].component
        instAdmUtilSupervisor.appendEventHistory(\
            u" bootstrap: made IAdmUtilCategories-Utility")

    transaction.get().commit()
    if connection is not None:
        connection.close()