Coverage for curator/cli_singletons/allocation.py: 100%
18 statements
« prev ^ index » next coverage.py v7.3.0, created at 2023-08-16 15:27 -0600
« prev ^ index » next coverage.py v7.3.0, created at 2023-08-16 15:27 -0600
1"""Allocation Singleton"""
2import click
3from curator.cli_singletons.object_class import cli_action
4from curator.cli_singletons.utils import get_width, validate_filter_json
6@click.command(context_settings=get_width())
7@click.option('--key', type=str, required=True, help='Node identification tag')
8@click.option('--value', type=str, default=None, help='Value associated with --key')
9@click.option('--allocation_type', type=click.Choice(['require', 'include', 'exclude']))
10@click.option(
11 '--wait_for_completion/--no-wait_for_completion',
12 default=False,
13 help='Wait for the allocation to complete',
14 show_default=True
15)
16@click.option(
17 '--max_wait',
18 default=-1,
19 type=int,
20 help='Maximum number of seconds to wait_for_completion',
21 show_default=True
22)
23@click.option(
24 '--wait_interval',
25 default=9,
26 type=int,
27 help='Seconds to wait between completion checks.',
28 show_default=True
29)
30@click.option(
31 '--ignore_empty_list',
32 is_flag=True,
33 help='Do not raise exception if there are no actionable indices'
34)
35@click.option(
36 '--allow_ilm_indices/--no-allow_ilm_indices',
37 help='Allow Curator to operate on Index Lifecycle Management monitored indices.',
38 default=False,
39 show_default=True
40)
41@click.option(
42 '--filter_list',
43 callback=validate_filter_json,
44 help='JSON array of filters selecting indices to act on.',
45 required=True
46)
47@click.pass_context
48def allocation(
49 ctx,
50 key,
51 value,
52 allocation_type,
53 wait_for_completion,
54 max_wait,
55 wait_interval,
56 ignore_empty_list,
57 allow_ilm_indices,
58 filter_list
59 ):
60 """
61 Shard Routing Allocation
62 """
63 manual_options = {
64 'key': key,
65 'value': value,
66 'allocation_type': allocation_type,
67 'wait_for_completion': wait_for_completion,
68 'max_wait': max_wait,
69 'wait_interval': wait_interval,
70 'allow_ilm_indices': allow_ilm_indices,
71 }
72 # ctx.info_name is the name of the function or name specified in @click.command decorator
73 action = cli_action(
74 ctx.info_name, ctx.obj['config']['client'], manual_options, filter_list, ignore_empty_list)
75 action.do_singleton_action(dry_run=ctx.obj['dry_run'])