-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathcfy.py
More file actions
2622 lines (2234 loc) · 77.3 KB
/
Copy pathcfy.py
File metadata and controls
2622 lines (2234 loc) · 77.3 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import sys
import os
import difflib
import warnings
import traceback
import pkg_resources
import datetime
import re
import subprocess
import locale
import codecs
import unicodedata
from functools import wraps
from io import StringIO
from urllib.parse import quote as urlquote
import click
from cloudify.models_states import AgentState
from cloudify_rest_client.constants import VisibilityState
from cloudify_rest_client.exceptions import NotModifiedError
from cloudify_rest_client.exceptions import CloudifyClientError
from cloudify_rest_client.exceptions import MaintenanceModeActiveError
from cloudify_rest_client.exceptions import MaintenanceModeActivatingError
from cloudify_cli import env, logger
from cloudify_cli.cli import helptexts
from cloudify_cli.constants import DEFAULT_BLUEPRINT_PATH
from cloudify_cli.exceptions import (
LabelsValidationError,
CloudifyBootstrapError,
CloudifyValidationError,
SuppressedCloudifyCliError)
from cloudify_cli.filters_utils import (
get_filter_rules,
create_labels_filter_rules_list,
create_attributes_filter_rules_list)
from cloudify_cli.inputs import inputs_to_dict
from cloudify_cli.logger import (
get_logger,
set_global_verbosity_level,
DEFAULT_LOG_FILE,
set_global_json_output,
set_global_extended_view)
from cloudify_cli.utils import generate_random_string
CLICK_CONTEXT_SETTINGS = dict(
help_option_names=['-h', '--help'],
)
AGENT_FILTER_NODE_IDS = 'node_ids'
AGENT_FILTER_NODE_INSTANCE_IDS = 'node_instance_ids'
AGENT_FILTER_DEPLOYMENT_ID = 'deployment_id'
AGENT_FILTER_INSTALL_METHODS = 'install_methods'
class MutuallyExclusiveOption(click.Option):
"""Makes options mutually exclusive. The option must pass a `cls` argument
with this class name and a `mutually_exclusive` argument with a list of
argument names it is mutually exclusive with.
NOTE: All mutually exclusive options must use this. It's not enough to
use it in just one of the options.
"""
def __init__(self, *args, **kwargs):
self.mutually_exclusive = set(kwargs.pop('mutually_exclusive', []))
self.mutuality_string = ', '.join(self.mutually_exclusive)
if self.mutually_exclusive:
help = kwargs.get('help', '')
kwargs['help'] = (
'{0}. You cannot use this argument with arguments: [{1}]'
.format(help, self.mutuality_string)
)
super(MutuallyExclusiveOption, self).__init__(*args, **kwargs)
def handle_parse_result(self, ctx, opts, args):
if self.mutually_exclusive.intersection(opts) and self.name in opts:
raise click.UsageError(
'Illegal usage: `{0}` is mutually exclusive with '
'arguments: [{1}]'.format(self.name, self.mutuality_string)
)
return super(MutuallyExclusiveOption, self).handle_parse_result(
ctx, opts, args)
def _parse_relative_datetime(ctx, param, rel_datetime):
"""Change relative time (ago) to a valid timestamp"""
if not rel_datetime:
return None
parsed = re.findall(r"(\d+) (seconds?|minutes?|hours?|days?|weeks?"
"|months?|years?) ?(ago)?",
rel_datetime)
if not parsed or len(parsed[0]) < 2:
return None
number = int(parsed[0][0])
period = parsed[0][1]
if period[-1] != u's':
period += u's'
now = datetime.datetime.utcnow()
if period == u'years':
result = now.replace(year=now.year - number)
elif period == u'months':
if now.month > number:
result = now.replace(month=now.month - number)
else:
result = now.replace(month=now.month - number + 12,
year=now.year - 1)
else:
delta = datetime.timedelta(**{period: number})
result = now - delta
return result
def _parse_unix_timestamp(unix_time):
parsed = re.findall(r"^(\d+)(\.(\d{1,6}))?$", unix_time)
if not parsed or len(parsed[0]) < 1:
return None
return datetime.datetime.utcfromtimestamp(float(unix_time))
class Timestamp(click.DateTime):
"""Timestamp is DateTime enhanced by the ability to parse Unix time"""
def convert(self, value, param, ctx):
parsed_unix_time = _parse_unix_timestamp(value)
if parsed_unix_time:
return parsed_unix_time
return super(Timestamp, self).convert(value, param, ctx)
def get_metavar(self, param):
return '[{0}|UNIX TIME FORMAT]'.format('|'.join(self.formats))
def __repr__(self):
return "Timestamp"
def _format_version_data(version_data,
prefix=None,
suffix=None,
infix=None):
all_data = version_data.copy()
all_data['prefix'] = prefix or ''
all_data['suffix'] = suffix or ''
all_data['infix'] = infix or ''
output = StringIO()
output.write('{prefix}{version}'.format(**all_data))
output.write('{suffix}'.format(**all_data))
return output.getvalue()
def _tenant_help_message(message, message_template, resource_name):
if message is not None:
return message
if resource_name is not None:
return message_template.format(resource_name)
return helptexts.TENANT
def _get_validate_callback(validate):
if validate:
return validate_name
return None
def show_version(ctx, param, value):
if not value or ctx.resilient_parsing:
return
cli_version_output = _format_version_data(
{'version': pkg_resources.require('cloudify')[0].version},
prefix='Cloudify CLI ',
infix=' ' * 5,
suffix='\n')
try:
rest_version_data = env.get_manager_version_data() \
if env.is_manager_active() else None
except Exception as e:
get_logger().info(cli_version_output)
sys.stderr.write("Cannot get Cloudify Manager version. {}: "
"{}\n".format(type(e).__name__, str(e)))
ctx.exit(1)
output = ''
if rest_version_data:
edition = rest_version_data['edition'].title()
output += '{0} edition\n\n'.format(edition)
output += cli_version_output
if rest_version_data:
output += _format_version_data(
rest_version_data,
prefix='Cloudify Manager ',
infix=' ',
suffix=' [ip={ip}]\n'.format(**rest_version_data))
get_logger().info(output)
ctx.exit()
def inputs_callback(ctx, param, value):
"""Allow to pass any inputs we provide to a command as
processed inputs instead of having to call `inputs_to_dict`
inside the command.
`@cfy.options.inputs` already calls this callback so that
every time you use the option it returns the inputs as a
dictionary.
"""
if not value or ctx.resilient_parsing:
return {}
return inputs_to_dict(value)
def properties_callback(ctx, param, value):
"""Same as inputs_callback above,
But also allows the user to pass inputs of the format key=value where
key has a dot hierarchy - e.g. 'a.b.c=d', and parses such inputs
into correct dict format: {a: {b: {c: d}}}.
"""
if not value or ctx.resilient_parsing:
return {}
deleting = ctx.info_name == 'delete-runtime'
return inputs_to_dict(value, dot_hierarchy=True, deleting=deleting)
def parse_on_off(ctx, param, value):
if value is None or ctx.resilient_parsing:
return
if value.lower() == 'off':
return False
elif value.lower() == 'on':
return True
else:
raise CloudifyValidationError(
'Value must be on/off, but got: {0}'.format(value))
def parse_and_validate_labels(ctx, param, value):
if value is None or ctx.resilient_parsing:
return
if not value:
raise CloudifyValidationError(
'ERROR: The `{0}` argument is empty'.format(param.name))
return get_formatted_labels_list(value)
def parse_and_validate_label_to_delete(ctx, param, value):
if value is None or ctx.resilient_parsing:
return
if not value:
raise CloudifyValidationError(
'ERROR: The `{0}` argument is empty'.format(param.name))
return get_formatted_labels_list(value, allow_only_key=True)
def validate_value_not_empty(ctx, param, value):
if value is None or ctx.resilient_parsing:
return
if not value:
raise CloudifyValidationError(
'ERROR: The `{0}` argument is empty'.format(param.name))
return value
def get_formatted_labels_list(raw_labels_string, allow_only_key=False):
labels_list = []
if any(unicodedata.category(char)[0] == 'C' or char == '"'
for char in raw_labels_string):
raise CloudifyValidationError(
'Error: labels cannot contain control characters or `"`')
format_err_msg = 'Labels should be of the form <key>:<value>,<key>:<value>'
raw_labels_string = raw_labels_string.replace('\\,', '\x00').split(',')
for label in raw_labels_string:
label = label.replace('\x00', ',')
label = label.replace('\\:', '\x00')
colons_count = label.count(':')
if colons_count == 0:
if not allow_only_key:
raise LabelsValidationError(label, format_err_msg)
label_key, label_value = label, None
elif colons_count == 1:
label_key, label_value = label.split(':')
if not label_key or not label_value:
raise LabelsValidationError(label, format_err_msg)
label_value = label_value.replace('\x00', ':')
else:
if allow_only_key:
raise CloudifyValidationError(
'LABEL should be a mixed list of labels and keys. I.e. '
'<key>:<value>,<key>,<key>:<value>')
raise LabelsValidationError(label, format_err_msg)
label_key = label_key.replace('\x00', ':').strip()
try:
validate_param_value('label_key', label_key)
except CloudifyValidationError:
raise LabelsValidationError(
label, "The label's key contains illegal characters. "
"Only letters, digits and the characters `-`, `.` and "
"`_` are allowed")
labels_list.append({label_key: label_value})
return labels_list
def _validate_filter_rules_not_empty(ctx, param, value):
if value is None or value == () or ctx.resilient_parsing:
return
if not value:
raise CloudifyValidationError(
'ERROR: The `{0}` argument is empty'.format(param.name))
def parse_labels_filter_rules(ctx, param, value):
_validate_filter_rules_not_empty(ctx, param, value)
return create_labels_filter_rules_list(value)
def parse_attributes_filter_rules(ctx, param, value):
_validate_filter_rules_not_empty(ctx, param, value)
return create_attributes_filter_rules_list(value)
def validate_name(ctx, param, value):
if value is None or ctx.resilient_parsing:
return
return validate_param_value('The `{0}` argument'.format(param.name), value)
def validate_param_value(err_prefix, value):
if not value:
raise CloudifyValidationError('ERROR: {0} is empty'.format(err_prefix))
quoted_value = urlquote(value, safe='')
if value != quoted_value:
raise CloudifyValidationError(
'ERROR: {0} contains illegal characters. Only letters, digits and '
'the characters "-", "." and "_" are allowed'.format(err_prefix))
return value
def validate_password(ctx, param, value):
if value is None or ctx.resilient_parsing:
return
if not value:
raise CloudifyValidationError('ERROR: The password is empty')
return value
def validate_encryption_passphrase(ctx, param, value):
value = validate_password(ctx, param, value)
if value and len(value) < 8:
raise CloudifyValidationError('ERROR: Passphrase must contain at '
'least 8 characters.')
return value
def validate_nonnegative_integer(ctx, param, value):
if ctx.resilient_parsing:
return
try:
value = int(value)
if value < 0:
raise ValueError()
except ValueError:
raise CloudifyValidationError('ERROR: {0} is expected to be a '
'nonnegative integer'.format(param.name))
return value
def set_json(ctx, param, value):
if value is not None:
set_global_json_output(value)
return value
def set_format(ctx, param, value):
if value == 'json':
set_global_json_output(True)
elif value == 'extended':
set_global_extended_view(True)
return value
def set_extended_view(ctx, param, value):
if value is not None:
set_global_extended_view(value)
return value
def set_manager(ctx, param, value):
if value is None:
return
if env.is_cluster():
env.set_target_manager(value)
else:
get_logger().warning(
'--manager can only be used in a cluster topology and the '
'current profile is an all-in-one Cloudify Manager'
)
def json_output_deprecate(ctx, param, value):
if value:
warnings.warn("Instead of --json-output, use the global "
"`cfy --json` flag")
return value
def set_verbosity_level(ctx, param, value):
if not value or ctx.resilient_parsing:
return
if param.name == 'verbose':
set_global_verbosity_level(value)
elif value and param.name == 'quiet':
set_global_verbosity_level(logger.QUIET)
return value
def set_cli_except_hook(global_verbosity_level):
def recommend(possible_solutions):
logger = get_logger()
logger.info('Possible solutions:')
for solution in possible_solutions:
logger.info(' - {0}'.format(solution))
def new_excepthook(tpe, value, tb):
with open(DEFAULT_LOG_FILE, 'a') as log_file:
traceback.print_exception(
tpe,
value=value,
tb=tb,
file=log_file)
logger = get_logger()
prefix = None
server_traceback = None
output_message = True
if issubclass(tpe, CloudifyClientError):
server_traceback = value.server_traceback
if not issubclass(
tpe,
(MaintenanceModeActiveError,
MaintenanceModeActivatingError,
NotModifiedError)):
# this means we made a server call and it failed.
# we should include this information in the error
prefix = 'An error occurred on the server'
if issubclass(tpe, SuppressedCloudifyCliError):
output_message = False
if issubclass(tpe, CloudifyBootstrapError):
output_message = False
if global_verbosity_level:
# print traceback if verbose
s_traceback = StringIO()
traceback.print_exception(
tpe,
value=value,
tb=tb,
file=s_traceback)
logger.error(s_traceback.getvalue())
if server_traceback:
logger.error('Server Traceback (most recent call last):')
# No need for print_tb since this exception
# is already formatted by the server
logger.error(server_traceback)
if output_message and not global_verbosity_level:
# If we output the traceback
# we output the message too.
# print_exception does that.
# here we just want the message (non verbose)
if prefix:
logger.error('{0}: {1}'.format(prefix, value))
else:
logger.error(value)
if hasattr(value, 'possible_solutions'):
recommend(getattr(value, 'possible_solutions'))
sys.excepthook = new_excepthook
def assert_manager_active(require_creds=True):
"""
Wrap the command so that it can only run when a manager is active
:param require_creds: If set to True, the wrapped method will fail if no
admin password was set either in the profile, or in the env variable
"""
def decorator(func):
# Wraps here makes sure the original docstring propagates to click
@wraps(func)
def wrapper(*args, **kwargs):
env.assert_manager_active()
if require_creds:
env.assert_credentials_set()
return func(*args, **kwargs)
return wrapper
return decorator
def assert_local_active(func):
"""
Wrap the command so that it can only run when in local context
"""
@wraps(func)
def wrapper(*args, **kwargs):
env.assert_local_active()
return func(*args, **kwargs)
return wrapper
def pass_logger(func):
"""Simply passes the logger to a command.
"""
# Wraps here makes sure the original docstring propagates to click
@wraps(func)
def wrapper(*args, **kwargs):
new_logger = get_logger()
return func(logger=new_logger, *args, **kwargs)
return wrapper
def pass_client(use_tenant_in_header=True, *args, **kwargs):
"""Simply passes the rest client to a command.
"""
def add_client_inner(func):
# Wraps here makes sure the original docstring propagates to click
@wraps(func)
def wrapper(*wrapper_args, **wrapper_kwargs):
tenant = wrapper_kwargs.get('tenant_name') \
if use_tenant_in_header else None
client = env.get_rest_client(tenant_name=tenant, *args, **kwargs)
return func(client=client, *wrapper_args, **wrapper_kwargs)
return wrapper
return add_client_inner
def pass_context(func):
"""Make click context Cloudify specific
This exists purely for aesthetic reasons, otherwise
Some decorators are called `@click.something` instead of
`@cfy.something`
"""
return click.pass_context(func)
class CommandMixin(object):
"""
This class mixin helps to set the right locale for system required
by python 3 for click library where "LC_ALL" & "LANG" are not set and
in order to avoid the RuntimeError raised by click library which
prevents invoking cfy commands
"""
def main(
self,
args=None,
prog_name=None,
complete_var=None,
standalone_mode=True,
**extra
):
# Make sure to set the locale before calling the main method of
# click command/group that validate if the environment is
# good for unicode on Python 3 or not.
self.set_locale_env()
super(CommandMixin, self).main(
args=args,
prog_name=prog_name,
complete_var=complete_var,
standalone_mode=standalone_mode,
**extra
)
@staticmethod
def set_locale_env():
# inspired by how click library handle unicode for python 3 environment
# https://github.com/pallets/click/blob/7.1.2/src/click/_unicodefun.py
try:
encoding = codecs.lookup(locale.getpreferredencoding()).name
except Exception:
encoding = 'ascii'
if encoding == 'ascii':
if os.name == "posix":
try:
locales = subprocess.Popen(
["locale", "-a"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE
).communicate()[0]
except OSError:
locales = b""
if isinstance(locales, bytes):
locales = locales.decode("ascii", "replace")
local_to_set = None
for line in locales.splitlines():
locale_env = line.strip()
if locale_env.lower() in (
"en_us.utf8",
"en_us.utf-8",
"c.utf8",
"c.utf-8"
):
local_to_set = locale_env
if local_to_set:
os.environ['LC_ALL'] = local_to_set
os.environ['LANG'] = local_to_set
break
class AliasedGroup(CommandMixin, click.Group):
def __init__(self, *args, **kwargs):
self.max_suggestions = kwargs.pop("max_suggestions", 3)
self.cutoff = kwargs.pop("cutoff", 0.5)
super(AliasedGroup, self).__init__(*args, **kwargs)
def get_command(self, ctx, cmd_name):
rv = click.Group.get_command(self, ctx, cmd_name)
if rv is not None:
return rv
matches = \
[x for x in self.list_commands(ctx) if x.startswith(cmd_name)]
if not matches:
return None
elif len(matches) == 1:
return click.Group.get_command(self, ctx, matches[0])
ctx.fail('Too many matches: {0}'.format(', '.join(sorted(matches))))
def resolve_command(self, ctx, args):
"""Override clicks ``resolve_command`` method
and appends *Did you mean ...* suggestions
to the raised exception message.
"""
try:
return super(AliasedGroup, self).resolve_command(ctx, args)
except click.exceptions.UsageError as error:
error_msg = str(error)
original_cmd_name = click.utils.make_str(args[0])
matches = difflib.get_close_matches(
original_cmd_name,
self.list_commands(ctx),
self.max_suggestions,
self.cutoff)
if matches:
error_msg += '\n\nDid you mean one of these?\n {0}'.format(
'\n '.join(matches))
raise click.exceptions.UsageError(error_msg, error.ctx)
def command(self, *a, **kw):
kw.setdefault('cls', CommandWithLoggers)
return super(AliasedGroup, self).command(*a, **kw)
def group(self, *a, **kw):
kw.setdefault('cls', self.__class__)
return super(AliasedGroup, self).group(*a, **kw)
def group(name):
"""Allow to create a group with a default click context
and a cls for click's `didyoueamn` without having to repeat
it for every group.
"""
return click.group(
name=name,
context_settings=CLICK_CONTEXT_SETTINGS,
cls=AliasedGroup)
class CommandWithLoggers(CommandMixin, click.Command):
"""Like a click Command, but configure loggers first.
We want loggers to be configured after argument parsing has been
performed (ie. verbose/quiet callbacks have fired), but before the
command was actually run.
"""
def invoke(self, *a, **kw):
logger.configure_loggers()
return super(CommandWithLoggers, self).invoke(*a, **kw)
def command(*args, **kwargs):
"""Make Click commands Cloudify specific
This exists purely for aesthetical reasons, otherwise
Some decorators are called `@click.something` instead of
`@cfy.something`
"""
kwargs.setdefault('cls', CommandWithLoggers)
return click.command(*args, **kwargs)
def argument(*args, **kwargs):
"""Make Click arguments Cloudify specific
This exists purely for aesthetic reasons, otherwise
Some decorators are called `@click.something` instead of
`@cfy.something`
"""
return click.argument(*args, **kwargs)
class Options(object):
def __init__(self):
"""The options api is nicer when you use each option by calling
`@cfy.options.some_option` instead of `@cfy.some_option`.
Note that some options are attributes and some are static methods.
The reason for that is that we want to be explicit regarding how
a developer sees an option. It it can receive arguments, it's a
method - if not, it's an attribute.
"""
self.version = click.option(
'--version',
is_flag=True,
callback=show_version,
expose_value=False,
is_eager=True,
help=helptexts.VERSION)
self.format = click.option(
'--format',
type=click.Choice(['plain', 'json']),
expose_value=False,
callback=set_format
)
self.json = click.option(
'--json',
is_flag=True,
expose_value=False,
default=None,
callback=set_json)
self.inputs = click.option(
'-i',
'--inputs',
multiple=True,
callback=inputs_callback,
help=helptexts.INPUTS)
self.runtime_properties = click.option(
'-p',
'--properties',
required=True,
multiple=True,
callback=properties_callback,
help=helptexts.RUNTIME_PROPERTIES)
self.reinstall_list = click.option(
'-r',
'--reinstall-list',
multiple=True,
help=helptexts.REINSTALL_LIST)
self.parameters = click.option(
'-p',
'--parameters',
multiple=True,
callback=inputs_callback,
help=helptexts.PARAMETERS)
self.output_path = click.option(
'-o',
'--output-path',
help=helptexts.OUTPUT_PATH)
self.override_collisions = click.option(
'--override-collisions',
is_flag=True,
help=helptexts.OVERRIDE_COLLISIONS
)
self.tenant_map = click.option(
'-m',
'--tenant-map',
type=click.Path(exists=True),
help=helptexts.TENANT_MAP
)
self.all_nodes = click.option(
'--all-nodes',
is_flag=True,
help=helptexts.ALL_NODES
)
self.optional_output_path = click.option(
'-o',
'--output-path',
help=helptexts.OUTPUT_PATH)
self.allow_custom_parameters = click.option(
'--allow-custom-parameters',
is_flag=True,
help=helptexts.ALLOW_CUSTOM_PARAMETERS)
self.install_plugins = click.option(
'--install-plugins',
is_flag=True,
help=helptexts.INSTALL_PLUGINS)
self.all_tenants = click.option(
'-a',
'--all-tenants',
is_flag=True,
default=False,
help=helptexts.ALL_TENANTS,
)
self.all_executions = click.option(
'--all-executions',
is_flag=True,
default=False,
help=helptexts.ALL_EXECUTIONS,
)
self.search = click.option(
'--search',
default=None,
required=False,
help=helptexts.SEARCH,
)
self.include_logs = click.option(
'--include-logs/--no-logs',
default=True,
help=helptexts.INCLUDE_LOGS)
self.dry_run = click.option(
'--dry-run',
is_flag=True,
help=helptexts.DRY_RUN
)
self.json_output = click.option(
'--json-output',
is_flag=True,
callback=json_output_deprecate,
help=helptexts.JSON_OUTPUT)
self.tail = click.option(
'--tail',
is_flag=True,
cls=MutuallyExclusiveOption,
mutually_exclusive=['pagination_offset', 'pagination_size'],
help=helptexts.TAIL_OUTPUT)
self.validate = click.option(
'--validate',
is_flag=True,
help=helptexts.VALIDATE_BLUEPRINT)
self.skip_install = click.option(
'--skip-install',
is_flag=True,
help=helptexts.SKIP_INSTALL)
self.skip_uninstall = click.option(
'--skip-uninstall',
is_flag=True,
help=helptexts.SKIP_UNINSTALL)
self.skip_reinstall = click.option(
'--skip-reinstall',
is_flag=True,
help=helptexts.SKIP_REINSTALL)
self.skip_drift_check = click.option(
'--skip-drift-check',
is_flag=True,
help=helptexts.SKIP_DRIFT_CHECK)
self.force_reinstall = click.option(
'--force-reinstall',
is_flag=True,
help=helptexts.FORCE_REINSTALL)
self.skip_heal = click.option(
'--skip-heal',
is_flag=True,
help=helptexts.SKIP_HEAL)
self.dont_skip_reinstall = click.option(
'--dont-skip-reinstall',
is_flag=True,
help=helptexts.DONT_SKIP_REINSTALL)
self.ignore_failure = click.option(
'--ignore-failure',
is_flag=True,
help=helptexts.IGNORE_FAILURE)
self.install_first = click.option(
'--install-first',
is_flag=True,
help=helptexts.INSTALL_FIRST)
self.preview = click.option(
'--preview',
is_flag=True,
help=helptexts.PREVIEW)
self.extended_view = click.option(
'-x',
'--extended-view',
is_flag=True,
expose_value=False,
default=None,
help=helptexts.EXTENDED_VIEW,
callback=set_extended_view)
self.dont_update_plugins = click.option(
'--dont-update-plugins',
is_flag=True,
help=helptexts.DONT_UPDATE_PLUGINS)
self.backup_first = click.option(
'--backup-first',
is_flag=True,
help=helptexts.BACKUP_LOGS_FIRST)
self.ssh_user = click.option(
'-s',
'--ssh-user',
required=False,
help=helptexts.SSH_USER)
self.ssh_user_flag = click.option(
'-s',
'--ssh-user',
required=False,
is_flag=True,
default=False,
help=helptexts.SSH_USER)
self.ssh_key = click.option(
'-k',
'--ssh-key',
required=False,
cls=MutuallyExclusiveOption,
help=helptexts.SSH_KEY)
self.ssh_key_flag = click.option(
'-k',
'--ssh-key',
required=False,
is_flag=True,
default=False,
help=helptexts.SSH_KEY)
self.profile_name = click.option(
'--profile-name',
required=False,
help=helptexts.PROFILE_NAME)
self.profile_manager_ip = click.option(
'-m', '--manager-ip',
help=helptexts.PROFILE_MANAGER_IP,
)
self.manager_token = click.option(
'-T',
'--manager-token',
required=False,
help=helptexts.MANAGER_TOKEN,
)
self.manager_username = click.option(
'-u',