1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
"""Snapshot Restore Singleton"""
import click
from curator.cli_singletons.object_class import CLIAction
from curator.cli_singletons.utils import json_to_dict, validate_filter_json
# pylint: disable=line-too-long
@click.command()
@click.option('--repository', type=str, required=True, help='Snapshot repository')
@click.option('--name', type=str, help='Snapshot name', required=False, default=None)
@click.option(
'--index',
multiple=True,
help='Index name to restore. (Can invoke repeatedly for multiple indices)',
)
@click.option(
'--rename_pattern', type=str, help='Rename pattern', required=False, default=None
)
@click.option(
'--rename_replacement',
type=str,
help='Rename replacement',
required=False,
default=None,
)
@click.option(
'--extra_settings',
type=str,
help='JSON version of extra_settings (see documentation)',
callback=json_to_dict,
)
@click.option(
'--include_aliases',
is_flag=True,
show_default=True,
help='Include aliases with restored indices.',
)
@click.option(
'--ignore_unavailable',
is_flag=True,
show_default=True,
help='Ignore unavailable shards/indices.',
)
@click.option(
'--include_global_state',
is_flag=True,
show_default=True,
help='Restore cluster global state with snapshot.',
)
@click.option(
'--partial',
is_flag=True,
show_default=True,
help='Restore partial data (from snapshot taken with --partial).',
)
@click.option(
'--wait_for_completion/--no-wait_for_completion',
default=True,
show_default=True,
help='Wait for the snapshot to complete',
)
@click.option(
'--wait_interval',
default=9,
type=int,
help='Seconds to wait between completion checks.',
)
@click.option(
'--max_wait',
default=-1,
type=int,
help='Maximum number of seconds to wait_for_completion',
)
@click.option(
'--skip_repo_fs_check',
is_flag=True,
show_default=True,
help='Skip repository filesystem access validation.',
)
@click.option(
'--ignore_empty_list',
is_flag=True,
help='Do not raise exception if there are no actionable indices',
)
@click.option(
'--allow_ilm_indices/--no-allow_ilm_indices',
help='Allow Curator to operate on Index Lifecycle Management monitored indices.',
default=False,
show_default=True,
)
@click.option(
'--include_hidden/--no-include_hidden',
help='Allow Curator to operate on hidden indices (and data_streams).',
default=False,
show_default=True,
)
@click.option(
'--filter_list',
callback=validate_filter_json,
help='JSON array of filters selecting snapshots to act on.',
required=True,
)
@click.pass_context
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,
include_hidden,
filter_list,
):
"""
Restore Indices
"""
indices = list(index)
manual_options = {
'name': name,
'extra_settings': extra_settings,
'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,
'include_hidden': include_hidden,
}
# ctx.info_name is the name of the function or name specified in
# @click.command decorator
action = CLIAction(
ctx.info_name,
ctx.obj['configdict'],
manual_options,
filter_list,
ignore_empty_list,
repository=repository,
)
action.do_singleton_action(dry_run=ctx.obj['dry_run'])
|