コード例 #1
0
ファイル: shrink.py プロジェクト: untergeek/curator
def shrink(ctx, shrink_node, node_filters, number_of_shards, number_of_replicas, shrink_prefix,
    shrink_suffix, copy_aliases, delete_after, post_allocation, extra_settings, wait_for_active_shards,
    wait_for_rebalance, wait_for_completion, wait_interval, max_wait, ignore_empty_list, allow_ilm_indices, filter_list):
    """
    Shrink Indices to --number_of_shards
    """
    manual_options = {
        'shrink_node': shrink_node,
        'node_filters': node_filters,
        'number_of_shards': number_of_shards,
        'number_of_replicas': number_of_replicas,
        'shrink_prefix': shrink_prefix,
        'shrink_suffix': shrink_suffix,
        'copy_aliases': copy_aliases,
        'delete_after': delete_after,
        'post_allocation': post_allocation,
        'extra_settings': extra_settings,
        'wait_for_active_shards': wait_for_active_shards,
        'wait_for_rebalance': wait_for_rebalance,
        'wait_for_completion': wait_for_completion,
        'wait_interval': wait_interval,
        'max_wait': max_wait,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'], manual_options, filter_list, ignore_empty_list)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #2
0
def restore(ctx, repository, name, index, rename_pattern, rename_replacement,
            extra_settings, include_aliases, ignore_unavailable,
            include_global_state, partial, wait_for_completion, wait_interval,
            max_wait, skip_repo_fs_check, ignore_empty_list, allow_ilm_indices,
            filter_list):
    """
    Restore Indices
    """
    indices = list(index)
    manual_options = {
        'name': name,
        'indices': indices,
        'rename_pattern': rename_pattern,
        'rename_replacement': rename_replacement,
        'ignore_unavailable': ignore_unavailable,
        'include_aliases': include_aliases,
        'include_global_state': include_global_state,
        'partial': partial,
        'skip_repo_fs_check': skip_repo_fs_check,
        'wait_for_completion': wait_for_completion,
        'max_wait': max_wait,
        'wait_interval': wait_interval,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name,
                        ctx.obj['config']['client'],
                        manual_options,
                        filter_list,
                        ignore_empty_list,
                        repository=repository)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #3
0
ファイル: open_indices.py プロジェクト: zslaposa/curator
def open_indices(ctx, ignore_empty_list, allow_ilm_indices, filter_list):
    """
    Open Indices
    """
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'], {'allow_ilm_indices':allow_ilm_indices}, filter_list, ignore_empty_list)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #4
0
def shrink(ctx, shrink_node, node_filters, number_of_shards,
           number_of_replicas, shrink_prefix, shrink_suffix, copy_aliases,
           delete_after, post_allocation, extra_settings,
           wait_for_active_shards, wait_for_rebalance, wait_for_completion,
           wait_interval, max_wait, ignore_empty_list, allow_ilm_indices,
           filter_list):
    """
    Shrink Indices to --number_of_shards
    """
    manual_options = {
        'shrink_node': shrink_node,
        'node_filters': node_filters,
        'number_of_shards': number_of_shards,
        'number_of_replicas': number_of_replicas,
        'shrink_prefix': shrink_prefix,
        'shrink_suffix': shrink_suffix,
        'copy_aliases': copy_aliases,
        'delete_after': delete_after,
        'post_allocation': post_allocation,
        'extra_settings': extra_settings,
        'wait_for_active_shards': wait_for_active_shards,
        'wait_for_rebalance': wait_for_rebalance,
        'wait_for_completion': wait_for_completion,
        'wait_interval': wait_interval,
        'max_wait': max_wait,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'],
                        manual_options, filter_list, ignore_empty_list)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #5
0
ファイル: restore.py プロジェクト: untergeek/curator
def restore(ctx, repository, name, index, rename_pattern, rename_replacement, extra_settings,
    include_aliases, ignore_unavailable, include_global_state, partial, wait_for_completion, 
    wait_interval, max_wait, skip_repo_fs_check, ignore_empty_list, allow_ilm_indices, filter_list):
    """
    Restore Indices
    """
    indices = list(index)
    manual_options = {
        'name': name,
        'indices': indices,
        'rename_pattern': rename_pattern,
        'rename_replacement': rename_replacement,
        'ignore_unavailable': ignore_unavailable,
        'include_aliases': include_aliases,
        'include_global_state': include_global_state,
        'partial': partial,
        'skip_repo_fs_check': skip_repo_fs_check,
        'wait_for_completion': wait_for_completion,
        'max_wait': max_wait,
        'wait_interval': wait_interval,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'], manual_options, filter_list, ignore_empty_list, repository=repository)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #6
0
ファイル: show.py プロジェクト: zslaposa/curator
def show_snapshots(ctx, repository, ignore_empty_list, filter_list):
    """
    Show Snapshots
    """
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'], {}, filter_list, ignore_empty_list, repository=repository)
    action.get_list_object()
    action.do_filters()
    for snapshot in sorted(action.list_object.snapshots):
        click.secho('{0}'.format(snapshot))
コード例 #7
0
ファイル: show.py プロジェクト: zhanghytc/curator
def show_indices(ctx, verbose, header, epoch, ignore_empty_list,
                 allow_ilm_indices, filter_list):
    """
    Show Indices
    """
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'],
                        {'allow_ilm_indices': allow_ilm_indices}, filter_list,
                        ignore_empty_list)
    action.get_list_object()
    action.do_filters()
    indices = sorted(action.list_object.indices)
    # Do some calculations to figure out the proper column sizes
    allbytes = []
    alldocs = []
    for idx in indices:
        allbytes.append(
            byte_size(action.list_object.index_info[idx]['size_in_bytes']))
        alldocs.append(str(action.list_object.index_info[idx]['docs']))
    if epoch:
        timeformat = '{6:>13}'
        column = 'creation_date'
    else:
        timeformat = '{6:>20}'
        column = 'Creation Timestamp'
    formatting = ('{0:' + str(len(max(indices, key=len))) + '} '
                  '{1:>5} '
                  '{2:>' + str(len(max(allbytes, key=len)) + 1) + '} '
                  '{3:>' + str(len(max(alldocs, key=len)) + 1) + '} '
                  '{4:>3} {5:>3} ' + timeformat)
    # Print the header, if both verbose and header are enabled
    if header and verbose:
        click.secho(formatting.format('Index', 'State', 'Size', 'Docs', 'Pri',
                                      'Rep', column),
                    bold=True,
                    underline=True)
    # Loop through indices and print info, if verbose
    for idx in indices:
        data = action.list_object.index_info[idx]
        if verbose:
            if epoch:
                datefield = data['age'][
                    'creation_date'] if 'creation_date' in data['age'] else 0
            else:
                datefield = '{0}Z'.format(
                    datetime.utcfromtimestamp(
                        data['age']['creation_date']).isoformat()
                ) if 'creation_date' in data['age'] else 'unknown/closed'
            click.echo(
                formatting.format(idx, data['state'],
                                  byte_size(data['size_in_bytes']),
                                  data['docs'], data['number_of_shards'],
                                  data['number_of_replicas'], datefield))
        else:
            click.echo('{0}'.format(idx))
コード例 #8
0
ファイル: close.py プロジェクト: untergeek/curator
def close(ctx, delete_aliases, ignore_empty_list, allow_ilm_indices, filter_list):
    """
    Close Indices
    """
    manual_options = { 
        'delete_aliases': delete_aliases,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'], manual_options, filter_list, ignore_empty_list)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #9
0
ファイル: show.py プロジェクト: untergeek/curator
def show_indices(ctx, verbose, header, epoch, ignore_empty_list, allow_ilm_indices, filter_list):
    """
    Show Indices
    """
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'], {'allow_ilm_indices': allow_ilm_indices}, filter_list, ignore_empty_list)
    action.get_list_object()
    action.do_filters()
    indices = sorted(action.list_object.indices)
    # Do some calculations to figure out the proper column sizes
    allbytes = []
    alldocs = []
    for idx in indices:
        allbytes.append(byte_size(action.list_object.index_info[idx]['size_in_bytes']))
        alldocs.append(str(action.list_object.index_info[idx]['docs']))
    if epoch:
        timeformat = '{6:>13}'
        column = 'creation_date'
    else:
        timeformat = '{6:>20}'
        column = 'Creation Timestamp'
    formatting = (
        '{0:' + str(len(max(indices, key=len))) + '} '
        '{1:>5} '
        '{2:>' + str(len(max(allbytes, key=len)) + 1) + '} '
        '{3:>' + str(len(max(alldocs, key=len)) + 1) + '} '
        '{4:>3} {5:>3} ' + timeformat
    )
    # Print the header, if both verbose and header are enabled
    if header and verbose:
        click.secho(
            formatting.format(
                'Index', 'State', 'Size', 'Docs', 'Pri', 'Rep', column
            ), bold=True, underline=True
        )
    # Loop through indices and print info, if verbose
    for idx in indices:
        p = action.list_object.index_info[idx]
        if verbose:
            if epoch:
                datefield = p['age']['creation_date'] if 'creation_date' in p['age'] else 0
            else:
                datefield = '{0}Z'.format(
                    datetime.utcfromtimestamp(p['age']['creation_date']
                ).isoformat()) if 'creation_date' in p['age'] else 'unknown/closed'
            click.echo(
                formatting.format(
                    idx, p['state'], byte_size(p['size_in_bytes']),
                    p['docs'], p['number_of_shards'], p['number_of_replicas'],
                    datefield
                )
            )
        else:
            click.echo('{0}'.format(idx))
コード例 #10
0
ファイル: forcemerge.py プロジェクト: untergeek/curator
def forcemerge(ctx, max_num_segments, delay, ignore_empty_list, allow_ilm_indices, filter_list):
    """
    forceMerge Indices (reduce segment count)
    """
    manual_options = { 
        'max_num_segments': max_num_segments,
        'delay': delay,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'], manual_options, filter_list, ignore_empty_list)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #11
0
ファイル: replicas.py プロジェクト: untergeek/curator
def replicas(ctx, count, wait_for_completion, ignore_empty_list, allow_ilm_indices, filter_list):
    """
    Change Replica Count
    """
    manual_options = { 
        'count': count,
        'wait_for_completion': wait_for_completion,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'], manual_options, filter_list, ignore_empty_list)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #12
0
ファイル: delete.py プロジェクト: untergeek/curator
def delete_snapshots(ctx, repository, retry_count, retry_interval, ignore_empty_list, allow_ilm_indices, filter_list):
    """
    Delete Snapshots
    """
    manual_options = {
        'retry_count': retry_count, 
        'retry_interval': retry_interval,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'], manual_options, filter_list, ignore_empty_list, repository=repository)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #13
0
ファイル: replicas.py プロジェクト: zhanghytc/curator
def replicas(ctx, count, wait_for_completion, ignore_empty_list, allow_ilm_indices, filter_list):
    """
    Change Replica Count
    """
    manual_options = {
        'count': count,
        'wait_for_completion': wait_for_completion,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(
        ctx.info_name, ctx.obj['config']['client'], manual_options, filter_list, ignore_empty_list)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #14
0
ファイル: close.py プロジェクト: zslaposa/curator
def close(ctx, delete_aliases, ignore_empty_list, allow_ilm_indices,
          filter_list):
    """
    Close Indices
    """
    manual_options = {
        'delete_aliases': delete_aliases,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'],
                        manual_options, filter_list, ignore_empty_list)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #15
0
ファイル: forcemerge.py プロジェクト: zslaposa/curator
def forcemerge(ctx, max_num_segments, delay, ignore_empty_list,
               allow_ilm_indices, filter_list):
    """
    forceMerge Indices (reduce segment count)
    """
    manual_options = {
        'max_num_segments': max_num_segments,
        'delay': delay,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'],
                        manual_options, filter_list, ignore_empty_list)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #16
0
ファイル: allocation.py プロジェクト: zslaposa/curator
def allocation(ctx, key, value, allocation_type, wait_for_completion, max_wait, wait_interval, ignore_empty_list, allow_ilm_indices, filter_list):
    """
    Shard Routing Allocation
    """
    manual_options = {
        'key': key,
        'value': value,
        'allocation_type': allocation_type,
        'wait_for_completion': wait_for_completion,
        'max_wait': max_wait,
        'wait_interval': wait_interval,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'], manual_options, filter_list, ignore_empty_list)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #17
0
def delete_snapshots(ctx, repository, retry_count, retry_interval,
                     ignore_empty_list, allow_ilm_indices, filter_list):
    """
    Delete Snapshots
    """
    manual_options = {
        'retry_count': retry_count,
        'retry_interval': retry_interval,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name,
                        ctx.obj['config']['client'],
                        manual_options,
                        filter_list,
                        ignore_empty_list,
                        repository=repository)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #18
0
ファイル: snapshot.py プロジェクト: untergeek/curator
def snapshot(ctx, repository, name, ignore_unavailable, include_global_state, partial,
    skip_repo_fs_check, wait_for_completion, wait_interval, max_wait, ignore_empty_list, allow_ilm_indices, filter_list):
    """
    Snapshot Indices
    """
    manual_options = {
        'name': name,
        'repository': repository,
        'ignore_unavailable': ignore_unavailable,
        'include_global_state': include_global_state,
        'partial': partial,
        'skip_repo_fs_check': skip_repo_fs_check,
        'wait_for_completion': wait_for_completion,
        'max_wait': max_wait,
        'wait_interval': wait_interval,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'], manual_options, filter_list, ignore_empty_list)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #19
0
def alias(ctx, name, add, remove, warn_if_no_indices, extra_settings, allow_ilm_indices):
    """
    Add/Remove Indices to/from Alias
    """
    manual_options = {
        'name': name,
        'extra_settings': extra_settings,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    ignore_empty_list = warn_if_no_indices
    action = cli_action(
        ctx.info_name, 
        ctx.obj['config']['client'], 
        manual_options,
        [], # filter_list is empty in our case
        ignore_empty_list,
        add=add, remove=remove, warn_if_no_indices=warn_if_no_indices, # alias specific kwargs
    )
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #20
0
ファイル: snapshot.py プロジェクト: zslaposa/curator
def snapshot(ctx, repository, name, ignore_unavailable, include_global_state,
             partial, skip_repo_fs_check, wait_for_completion, wait_interval,
             max_wait, ignore_empty_list, allow_ilm_indices, filter_list):
    """
    Snapshot Indices
    """
    manual_options = {
        'name': name,
        'repository': repository,
        'ignore_unavailable': ignore_unavailable,
        'include_global_state': include_global_state,
        'partial': partial,
        'skip_repo_fs_check': skip_repo_fs_check,
        'wait_for_completion': wait_for_completion,
        'max_wait': max_wait,
        'wait_interval': wait_interval,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name, ctx.obj['config']['client'],
                        manual_options, filter_list, ignore_empty_list)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])
コード例 #21
0
ファイル: rollover.py プロジェクト: zslaposa/curator
def rollover(ctx, name, max_age, max_docs, max_size, extra_settings, new_index,
             wait_for_active_shards, allow_ilm_indices):
    """
    Rollover Index associated with Alias
    """
    conditions = {}
    for cond in ['max_age', 'max_docs', 'max_size']:
        if eval(cond) is not None:
            conditions[cond] = eval(cond)
    manual_options = {
        'name': name,
        'conditions': conditions,
        'allow_ilm_indices': allow_ilm_indices,
    }
    # ctx.info_name is the name of the function or name specified in @click.command decorator
    action = cli_action(ctx.info_name,
                        ctx.obj['config']['client'],
                        manual_options, [],
                        True,
                        extra_settings=extra_settings,
                        new_index=new_index,
                        wait_for_active_shards=wait_for_active_shards)
    action.do_singleton_action(dry_run=ctx.obj['dry_run'])