Coverage for curator/cli_singletons/snapshot.py: 100%

1"""Snapshot Singleton"""

2 import click

3 from curator.cli_singletons.object_class import cli_action

4 from curator.cli_singletons.utils import get_width, validate_filter_json

5

6@click.command(context_settings=get_width())

7@click.option('--repository', type=str, required=True, help='Snapshot repository')

8@click.option(

9 '--name',

10 type=str,

11 help='Snapshot name',

12 show_default=True,

13 default='curator-%Y%m%d%H%M%S'

14)

15@click.option(

16 '--ignore_unavailable',

17 is_flag=True,

18 show_default=True,

19 help='Ignore unavailable shards/indices.'

20)

21@click.option(

22 '--include_global_state',

23 is_flag=True,

24 show_default=True,

25 help='Store cluster global state with snapshot.'

26)

27@click.option(

28 '--partial',

29 is_flag=True,

30 show_default=True,

31 help='Do not fail if primary shard is unavailable.'

32)

33@click.option(

34 '--wait_for_completion/--no-wait_for_completion',

35 default=True,

36 show_default=True,

37 help='Wait for the snapshot to complete'

38)

39@click.option(

40 '--wait_interval',

41 default=9,

42 type=int,

43 help='Seconds to wait between completion checks.'

44)

45@click.option(

46 '--max_wait',

47 default=-1,

48 type=int,

49 help='Maximum number of seconds to wait_for_completion'

50)

51@click.option(

52 '--skip_repo_fs_check',

53 is_flag=True,

54 show_default=True,

55 help='Skip repository filesystem access validation.'

56)

57@click.option(

58 '--ignore_empty_list',

59 is_flag=True,

60 help='Do not raise exception if there are no actionable indices'

61)

62@click.option(

63 '--allow_ilm_indices/--no-allow_ilm_indices',

64 help='Allow Curator to operate on Index Lifecycle Management monitored indices.',

65 default=False,

66 show_default=True

67)

68@click.option(

69 '--filter_list',

70 callback=validate_filter_json,

71 help='JSON array of filters selecting indices to act on.',

72 required=True

73)

74@click.pass_context

75 def snapshot(

76 ctx, repository, name, ignore_unavailable, include_global_state, partial,

77 skip_repo_fs_check, wait_for_completion, wait_interval, max_wait, ignore_empty_list,

78 allow_ilm_indices, filter_list

79 ):

80 """

81 Snapshot Indices

82 """

83 manual_options = {

84 'name': name,

85 'repository': repository,

86 'ignore_unavailable': ignore_unavailable,

87 'include_global_state': include_global_state,

88 'partial': partial,

89 'skip_repo_fs_check': skip_repo_fs_check,

90 'wait_for_completion': wait_for_completion,

91 'max_wait': max_wait,

92 'wait_interval': wait_interval,

93 'allow_ilm_indices': allow_ilm_indices,

94 }

95 # ctx.info_name is the name of the function or name specified in @click.command decorator

96 action = cli_action(

97 ctx.info_name, ctx.obj['config']['client'], manual_options, filter_list, ignore_empty_list)

98 action.do_singleton_action(dry_run=ctx.obj['dry_run'])