Example #1
0
def create_all_shards(dry_run=True):
    """Create all needed index shards."""
    client = get_index_connection()
    shards = Configuration('global').get('elasticsearch.shards')

    for shard_id in shards:
        if not client.indices.exists(shard_id):
            log.info('Creating shard {}'.format(shard_id))
            if not dry_run:
                setup_shard_index(shard_id)
Example #2
0
def delete_all_shards(dry_run=True):
    """Delete all index shards."""
    client = get_index_connection()
    shards = Configuration('global').get('elasticsearch.shards')

    for shard in shards:
        log.info('Processing shard {}'.format(shard))
        if not shard.startswith('caliopen-'):
            log.warn('Invalid shard name, pass')
            continue
        if not client.indices.exists(shard):
            log.warn('Shard does not exist')
            continue
        if dry_run:
            log.info('Delete shard but dry run do not touch')
        else:
            client.indices.delete(shard)
            log.info('Index {} deleted'.format(shard))
Example #3
0
 def __init__(self, user, resolution='day'):
     """Instanciate a date histrogram for an user."""
     self.esclient = get_index_connection()
     self.user = user
     self.resolution = resolution
Example #4
0
 def __init__(self, user_id, resolution='day'):
     """Instanciate a date histrogram for an user."""
     self.esclient = get_index_connection()
     self.user_id = user_id
     self.resolution = resolution
Example #5
0
def recreate_all_user_aliases(dry_run=True):
    """Recreate alias for all users."""
    client = get_index_connection()
    for user in User._model_class.all():
        recreate_user_alias(client, user, dry_run)