コード例 #1
0
ファイル: test_index.py プロジェクト: johanlundberg/eduid-am
 def test_index_setup(self):
     indexes = {
         # 'index-name': {'key': [('key', 1)], 'param1': True, 'param2': False}
         # http://docs.mongodb.org/manual/reference/method/db.collection.ensureIndex/
         'mail-index-v2': {
             'key': [('mail', 1)],
             'unique': True,
             'sparse': True
         },
         'eppn-index-v1': {
             'key': [('eduPersonPrincipalName', 1)],
             'unique': True
         },
         'norEduPersonNIN-index-v2': {
             'key': [('norEduPersonNIN', 1)],
             'unique': True,
             'sparse': True
         },
         'mobile-index-v1': {
             'key': [('mobile.mobile', 1), ('mobile.verified', 1)]
         },
         'mailAliases-index-v1': {
             'key': [('mailAliases.email', 1), ('mailAliases.verified', 1)]
         }
     }
     db = UserDB(self.settings.get('MONGO_URI'))
     print db._coll.index_information()
     db.setup_indexes(indexes)
     current_indexes = db._coll.index_information()
     print current_indexes
コード例 #2
0
ファイル: test_index.py プロジェクト: SUNET/eduid-am
 def test_index_setup(self):
     indexes = {
         # 'index-name': {'key': [('key', 1)], 'param1': True, 'param2': False}
         # http://docs.mongodb.org/manual/reference/method/db.collection.ensureIndex/
         'mail-index-v2': {'key': [('mail', 1)], 'unique': True, 'sparse': True},
         'eppn-index-v1': {'key': [('eduPersonPrincipalName', 1)], 'unique': True},
         'norEduPersonNIN-index-v2': {'key': [('norEduPersonNIN', 1)], 'unique': True, 'sparse': True},
         'mobile-index-v1': {'key': [('mobile.mobile', 1), ('mobile.verified', 1)]},
         'mailAliases-index-v1': {'key': [('mailAliases.email', 1), ('mailAliases.verified', 1)]}
     }
     db = UserDB(self.settings.get('MONGO_URI'))
     print(db._coll.index_information())
     db.setup_indexes(indexes)
     current_indexes = db._coll.index_information()
     print(current_indexes)
コード例 #3
0
ファイル: celery.py プロジェクト: johanlundberg/eduid-am
def setup_indexes(db_name, collection):
    """
    Ensure that indexes in eduid_am.attributes collection are correctly setup.
    To update an index add a new item in indexes and remove the previous version.
    """
    indexes = {
        # 'index-name': {'key': [('key', 1)], 'param1': True, 'param2': False}
        # http://docs.mongodb.org/manual/reference/method/db.collection.ensureIndex/
        'mail-index-v2': {'key': [('mail', 1)], 'unique': True, 'sparse': True},
        'eppn-index-v1': {'key': [('eduPersonPrincipalName', 1)], 'unique': True},
        'norEduPersonNIN-index-v2': {'key': [('norEduPersonNIN', 1)], 'unique': True, 'sparse': True},
        'mobile-index-v1': {'key': [('mobile.mobile', 1), ('mobile.verified', 1)]},
        'mailAliases-index-v1': {'key': [('mailAliases.email', 1), ('mailAliases.verified', 1)]}
    }
    userdb = UserDB(celery.conf.get('MONGO_URI'), db_name=db_name, collection=collection)
    userdb.setup_indexes(indexes)
コード例 #4
0
ファイル: worker.py プロジェクト: SUNET/eduid-am
def setup_indexes(db_uri, db_name, collection):
    """
    Ensure that indexes in eduid_am.attributes collection are correctly setup.
    To update an index add a new item in indexes and remove the previous version.
    """
    indexes = {
        # 'index-name': {'key': [('key', 1)], 'param1': True, 'param2': False}
        # http://docs.mongodb.org/manual/reference/method/db.collection.ensureIndex/
        'mail-index-v2': {'key': [('mail', 1)], 'unique': True, 'sparse': True},
        'eppn-index-v1': {'key': [('eduPersonPrincipalName', 1)], 'unique': True},
        'norEduPersonNIN-index-v2': {'key': [('norEduPersonNIN', 1)], 'unique': True, 'sparse': True},
        'mobile-index-v1': {'key': [('mobile.mobile', 1), ('mobile.verified', 1)]},
        'mailAliases-index-v1': {'key': [('mailAliases.email', 1), ('mailAliases.verified', 1)]}
    }
    userdb = UserDB(db_uri, db_name=db_name, collection=collection)
    userdb.setup_indexes(indexes)
    userdb.close()