kaqing 1.77.0__py3-none-any.whl → 2.0.171__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- adam/__init__.py +1 -0
- adam/app_session.py +182 -0
- {walker → adam}/apps.py +8 -24
- {walker → adam}/batch.py +54 -97
- {walker → adam}/checks/check.py +3 -3
- {walker → adam}/checks/check_result.py +1 -1
- adam/checks/check_utils.py +65 -0
- {walker → adam}/checks/compactionstats.py +6 -6
- {walker → adam}/checks/cpu.py +14 -8
- adam/checks/cpu_metrics.py +52 -0
- {walker → adam}/checks/disk.py +6 -6
- {walker → adam}/checks/gossip.py +5 -5
- {walker → adam}/checks/memory.py +7 -7
- {walker → adam}/checks/status.py +5 -5
- {walker → adam}/cli.py +3 -3
- {walker → adam}/columns/column.py +1 -1
- adam/columns/columns.py +45 -0
- {walker → adam}/columns/compactions.py +5 -5
- {walker → adam}/columns/cpu.py +6 -4
- adam/columns/cpu_metrics.py +22 -0
- {walker → adam}/columns/dir_data.py +3 -3
- {walker → adam}/columns/dir_snapshots.py +3 -3
- {walker → adam}/columns/gossip.py +5 -5
- {walker → adam}/columns/host_id.py +3 -3
- {walker → adam}/columns/memory.py +3 -3
- {walker → adam}/columns/node_address.py +3 -3
- {walker → adam}/columns/node_load.py +3 -3
- {walker → adam}/columns/node_owns.py +3 -3
- {walker → adam}/columns/node_status.py +3 -3
- {walker → adam}/columns/node_tokens.py +3 -3
- {walker → adam}/columns/node_utils.py +2 -2
- {walker → adam}/columns/pod_name.py +2 -2
- {walker → adam}/columns/volume_cassandra.py +4 -4
- {walker → adam}/columns/volume_root.py +3 -3
- adam/commands/__init__.py +15 -0
- adam/commands/alter_tables.py +81 -0
- adam/commands/app_cmd.py +38 -0
- {walker → adam}/commands/app_ping.py +10 -16
- adam/commands/audit/audit.py +84 -0
- adam/commands/audit/audit_repair_tables.py +74 -0
- adam/commands/audit/audit_run.py +50 -0
- adam/commands/audit/show_last10.py +48 -0
- adam/commands/audit/show_slow10.py +47 -0
- adam/commands/audit/show_top10.py +45 -0
- adam/commands/audit/utils_show_top10.py +59 -0
- adam/commands/bash/__init__.py +5 -0
- adam/commands/bash/bash.py +36 -0
- adam/commands/bash/bash_completer.py +93 -0
- adam/commands/bash/utils_bash.py +16 -0
- adam/commands/cat.py +50 -0
- adam/commands/cd.py +43 -0
- adam/commands/check.py +73 -0
- {walker → adam}/commands/cli_commands.py +7 -8
- adam/commands/code.py +57 -0
- adam/commands/command.py +190 -0
- {walker → adam}/commands/command_helpers.py +1 -1
- {walker → adam}/commands/commands_utils.py +15 -25
- adam/commands/cp.py +89 -0
- adam/commands/cql/cql_completions.py +33 -0
- {walker/commands → adam/commands/cql}/cqlsh.py +20 -35
- adam/commands/cql/utils_cql.py +343 -0
- {walker/commands/frontend → adam/commands/deploy}/code_start.py +11 -14
- adam/commands/deploy/code_stop.py +40 -0
- {walker/commands/frontend → adam/commands/deploy}/code_utils.py +7 -9
- adam/commands/deploy/deploy.py +25 -0
- adam/commands/deploy/deploy_frontend.py +49 -0
- adam/commands/deploy/deploy_pg_agent.py +35 -0
- adam/commands/deploy/deploy_pod.py +108 -0
- adam/commands/deploy/deploy_utils.py +29 -0
- adam/commands/deploy/undeploy.py +25 -0
- adam/commands/deploy/undeploy_frontend.py +38 -0
- adam/commands/deploy/undeploy_pg_agent.py +39 -0
- adam/commands/deploy/undeploy_pod.py +48 -0
- adam/commands/devices/device.py +118 -0
- adam/commands/devices/device_app.py +173 -0
- adam/commands/devices/device_auit_log.py +49 -0
- adam/commands/devices/device_cass.py +185 -0
- adam/commands/devices/device_export.py +86 -0
- adam/commands/devices/device_postgres.py +144 -0
- adam/commands/devices/devices.py +25 -0
- {walker → adam}/commands/exit.py +3 -6
- adam/commands/export/clean_up_all_export_sessions.py +37 -0
- adam/commands/export/clean_up_export_sessions.py +51 -0
- adam/commands/export/drop_export_database.py +55 -0
- adam/commands/export/drop_export_databases.py +43 -0
- adam/commands/export/export.py +53 -0
- adam/commands/export/export_databases.py +170 -0
- adam/commands/export/export_handlers.py +71 -0
- adam/commands/export/export_select.py +81 -0
- adam/commands/export/export_select_x.py +54 -0
- adam/commands/export/export_use.py +52 -0
- adam/commands/export/exporter.py +352 -0
- adam/commands/export/import_session.py +40 -0
- adam/commands/export/importer.py +67 -0
- adam/commands/export/importer_athena.py +80 -0
- adam/commands/export/importer_sqlite.py +47 -0
- adam/commands/export/show_column_counts.py +54 -0
- adam/commands/export/show_export_databases.py +36 -0
- adam/commands/export/show_export_session.py +48 -0
- adam/commands/export/show_export_sessions.py +44 -0
- adam/commands/export/utils_export.py +314 -0
- {walker → adam}/commands/help.py +17 -12
- adam/commands/intermediate_command.py +49 -0
- adam/commands/issues.py +43 -0
- adam/commands/kubectl.py +38 -0
- adam/commands/login.py +70 -0
- {walker → adam}/commands/logs.py +8 -10
- adam/commands/ls.py +41 -0
- adam/commands/medusa/medusa.py +27 -0
- adam/commands/medusa/medusa_backup.py +57 -0
- adam/commands/medusa/medusa_restore.py +83 -0
- adam/commands/medusa/medusa_show_backupjobs.py +51 -0
- adam/commands/medusa/medusa_show_restorejobs.py +47 -0
- {walker → adam}/commands/nodetool.py +17 -21
- {walker → adam}/commands/param_get.py +15 -16
- adam/commands/param_set.py +43 -0
- adam/commands/postgres/postgres.py +104 -0
- adam/commands/postgres/postgres_context.py +274 -0
- {walker → adam}/commands/postgres/postgres_ls.py +7 -11
- {walker → adam}/commands/postgres/postgres_preview.py +8 -13
- adam/commands/postgres/psql_completions.py +10 -0
- adam/commands/postgres/utils_postgres.py +66 -0
- adam/commands/preview_table.py +37 -0
- adam/commands/pwd.py +47 -0
- adam/commands/reaper/reaper.py +35 -0
- adam/commands/reaper/reaper_forward.py +93 -0
- adam/commands/reaper/reaper_forward_session.py +6 -0
- {walker → adam}/commands/reaper/reaper_forward_stop.py +13 -19
- {walker → adam}/commands/reaper/reaper_restart.py +10 -17
- adam/commands/reaper/reaper_run_abort.py +46 -0
- adam/commands/reaper/reaper_runs.py +82 -0
- adam/commands/reaper/reaper_runs_abort.py +63 -0
- adam/commands/reaper/reaper_schedule_activate.py +45 -0
- adam/commands/reaper/reaper_schedule_start.py +45 -0
- adam/commands/reaper/reaper_schedule_stop.py +45 -0
- {walker → adam}/commands/reaper/reaper_schedules.py +6 -16
- {walker → adam}/commands/reaper/reaper_status.py +11 -19
- adam/commands/reaper/utils_reaper.py +196 -0
- adam/commands/repair/repair.py +26 -0
- {walker → adam}/commands/repair/repair_log.py +7 -10
- adam/commands/repair/repair_run.py +70 -0
- adam/commands/repair/repair_scan.py +71 -0
- {walker → adam}/commands/repair/repair_stop.py +8 -11
- adam/commands/report.py +61 -0
- adam/commands/restart.py +60 -0
- {walker → adam}/commands/rollout.py +25 -30
- adam/commands/shell.py +34 -0
- adam/commands/show/show.py +39 -0
- walker/commands/show/show_version.py → adam/commands/show/show_adam.py +14 -10
- adam/commands/show/show_app_actions.py +57 -0
- {walker → adam}/commands/show/show_app_id.py +12 -15
- {walker → adam}/commands/show/show_app_queues.py +9 -12
- adam/commands/show/show_cassandra_repairs.py +38 -0
- adam/commands/show/show_cassandra_status.py +124 -0
- {walker → adam}/commands/show/show_cassandra_version.py +6 -16
- adam/commands/show/show_commands.py +59 -0
- walker/commands/show/show_storage.py → adam/commands/show/show_host.py +11 -13
- adam/commands/show/show_login.py +62 -0
- {walker → adam}/commands/show/show_params.py +4 -4
- adam/commands/show/show_processes.py +51 -0
- adam/commands/show/show_storage.py +42 -0
- adam/commands/watch.py +82 -0
- {walker → adam}/config.py +10 -22
- {walker → adam}/embedded_apps.py +1 -1
- adam/embedded_params.py +2 -0
- adam/log.py +47 -0
- {walker → adam}/pod_exec_result.py +10 -2
- adam/repl.py +182 -0
- adam/repl_commands.py +124 -0
- adam/repl_state.py +458 -0
- adam/sql/__init__.py +0 -0
- adam/sql/sql_completer.py +120 -0
- adam/sql/sql_state_machine.py +618 -0
- adam/sql/term_completer.py +76 -0
- adam/sso/__init__.py +0 -0
- {walker → adam}/sso/authenticator.py +5 -1
- adam/sso/authn_ad.py +170 -0
- {walker → adam}/sso/authn_okta.py +39 -22
- adam/sso/cred_cache.py +60 -0
- adam/sso/id_token.py +23 -0
- adam/sso/idp.py +143 -0
- adam/sso/idp_login.py +50 -0
- adam/sso/idp_session.py +55 -0
- adam/sso/sso_config.py +63 -0
- adam/utils.py +679 -0
- adam/utils_app.py +98 -0
- adam/utils_athena.py +145 -0
- adam/utils_audits.py +106 -0
- adam/utils_issues.py +32 -0
- adam/utils_k8s/__init__.py +0 -0
- adam/utils_k8s/app_clusters.py +28 -0
- adam/utils_k8s/app_pods.py +33 -0
- adam/utils_k8s/cassandra_clusters.py +36 -0
- adam/utils_k8s/cassandra_nodes.py +33 -0
- adam/utils_k8s/config_maps.py +34 -0
- {walker/k8s_utils → adam/utils_k8s}/custom_resources.py +7 -2
- adam/utils_k8s/deployment.py +56 -0
- {walker/k8s_utils → adam/utils_k8s}/ingresses.py +3 -4
- {walker/k8s_utils → adam/utils_k8s}/jobs.py +3 -3
- adam/utils_k8s/k8s.py +87 -0
- {walker/k8s_utils → adam/utils_k8s}/kube_context.py +4 -4
- adam/utils_k8s/pods.py +290 -0
- {walker/k8s_utils → adam/utils_k8s}/secrets.py +8 -4
- adam/utils_k8s/service_accounts.py +170 -0
- {walker/k8s_utils → adam/utils_k8s}/services.py +3 -4
- {walker/k8s_utils → adam/utils_k8s}/statefulsets.py +6 -16
- {walker/k8s_utils → adam/utils_k8s}/volumes.py +10 -1
- adam/utils_net.py +24 -0
- adam/utils_repl/__init__.py +0 -0
- adam/utils_repl/automata_completer.py +48 -0
- adam/utils_repl/repl_completer.py +46 -0
- adam/utils_repl/state_machine.py +173 -0
- adam/utils_sqlite.py +109 -0
- adam/version.py +5 -0
- {kaqing-1.77.0.dist-info → kaqing-2.0.171.dist-info}/METADATA +1 -1
- kaqing-2.0.171.dist-info/RECORD +236 -0
- kaqing-2.0.171.dist-info/entry_points.txt +3 -0
- kaqing-2.0.171.dist-info/top_level.txt +1 -0
- kaqing-1.77.0.dist-info/RECORD +0 -159
- kaqing-1.77.0.dist-info/entry_points.txt +0 -3
- kaqing-1.77.0.dist-info/top_level.txt +0 -1
- walker/__init__.py +0 -3
- walker/app_session.py +0 -168
- walker/checks/check_utils.py +0 -97
- walker/columns/columns.py +0 -43
- walker/commands/add_user.py +0 -68
- walker/commands/app.py +0 -67
- walker/commands/bash.py +0 -87
- walker/commands/cd.py +0 -115
- walker/commands/check.py +0 -68
- walker/commands/command.py +0 -104
- walker/commands/cp.py +0 -95
- walker/commands/cql_utils.py +0 -53
- walker/commands/devices.py +0 -89
- walker/commands/frontend/code_stop.py +0 -57
- walker/commands/frontend/setup.py +0 -60
- walker/commands/frontend/setup_frontend.py +0 -58
- walker/commands/frontend/teardown.py +0 -61
- walker/commands/frontend/teardown_frontend.py +0 -42
- walker/commands/issues.py +0 -69
- walker/commands/login.py +0 -72
- walker/commands/ls.py +0 -145
- walker/commands/medusa/medusa.py +0 -69
- walker/commands/medusa/medusa_backup.py +0 -61
- walker/commands/medusa/medusa_restore.py +0 -86
- walker/commands/medusa/medusa_show_backupjobs.py +0 -52
- walker/commands/medusa/medusa_show_restorejobs.py +0 -52
- walker/commands/param_set.py +0 -44
- walker/commands/postgres/postgres.py +0 -113
- walker/commands/postgres/postgres_session.py +0 -225
- walker/commands/preview_table.py +0 -98
- walker/commands/processes.py +0 -53
- walker/commands/pwd.py +0 -64
- walker/commands/reaper/reaper.py +0 -78
- walker/commands/reaper/reaper_forward.py +0 -100
- walker/commands/reaper/reaper_run_abort.py +0 -65
- walker/commands/reaper/reaper_runs.py +0 -97
- walker/commands/reaper/reaper_runs_abort.py +0 -83
- walker/commands/reaper/reaper_schedule_activate.py +0 -64
- walker/commands/reaper/reaper_schedule_start.py +0 -64
- walker/commands/reaper/reaper_schedule_stop.py +0 -64
- walker/commands/reaper/reaper_session.py +0 -159
- walker/commands/repair/repair.py +0 -68
- walker/commands/repair/repair_run.py +0 -72
- walker/commands/repair/repair_scan.py +0 -79
- walker/commands/report.py +0 -57
- walker/commands/restart.py +0 -61
- walker/commands/show/show.py +0 -72
- walker/commands/show/show_app_actions.py +0 -53
- walker/commands/show/show_cassandra_status.py +0 -35
- walker/commands/show/show_commands.py +0 -58
- walker/commands/show/show_processes.py +0 -35
- walker/commands/show/show_repairs.py +0 -47
- walker/commands/status.py +0 -128
- walker/commands/storage.py +0 -52
- walker/commands/user_entry.py +0 -69
- walker/commands/watch.py +0 -85
- walker/embedded_params.py +0 -2
- walker/k8s_utils/cassandra_clusters.py +0 -48
- walker/k8s_utils/cassandra_nodes.py +0 -26
- walker/k8s_utils/pods.py +0 -211
- walker/repl.py +0 -165
- walker/repl_commands.py +0 -58
- walker/repl_state.py +0 -211
- walker/sso/authn_ad.py +0 -94
- walker/sso/idp.py +0 -150
- walker/sso/idp_login.py +0 -29
- walker/sso/sso_config.py +0 -45
- walker/utils.py +0 -194
- walker/version.py +0 -5
- {walker → adam}/checks/__init__.py +0 -0
- {walker → adam}/checks/check_context.py +0 -0
- {walker → adam}/checks/issue.py +0 -0
- {walker → adam}/cli_group.py +0 -0
- {walker → adam}/columns/__init__.py +0 -0
- {walker/commands → adam/commands/audit}/__init__.py +0 -0
- {walker/commands/frontend → adam/commands/cql}/__init__.py +0 -0
- {walker/commands/medusa → adam/commands/deploy}/__init__.py +0 -0
- {walker/commands/postgres → adam/commands/devices}/__init__.py +0 -0
- {walker/commands/reaper → adam/commands/export}/__init__.py +0 -0
- {walker/commands/repair → adam/commands/medusa}/__init__.py +0 -0
- {walker → adam}/commands/nodetool_commands.py +0 -0
- {walker/commands/show → adam/commands/postgres}/__init__.py +0 -0
- {walker/k8s_utils → adam/commands/reaper}/__init__.py +0 -0
- {walker/sso → adam/commands/repair}/__init__.py +0 -0
- /walker/medusa_show_restorejobs.py → /adam/commands/show/__init__.py +0 -0
- {walker → adam}/repl_session.py +0 -0
- {kaqing-1.77.0.dist-info → kaqing-2.0.171.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import time
|
|
2
|
+
|
|
3
|
+
from adam.commands.command import Command
|
|
4
|
+
from adam.config import Config
|
|
5
|
+
from adam.repl_state import ReplState
|
|
6
|
+
from adam.utils import log, log2
|
|
7
|
+
from adam.utils_athena import Athena
|
|
8
|
+
from adam.utils_audits import AuditMeta, Audits
|
|
9
|
+
|
|
10
|
+
class AuditRepairTables(Command):
|
|
11
|
+
COMMAND = 'audit repair'
|
|
12
|
+
|
|
13
|
+
# the singleton pattern
|
|
14
|
+
def __new__(cls, *args, **kwargs):
|
|
15
|
+
if not hasattr(cls, 'instance'): cls.instance = super(AuditRepairTables, cls).__new__(cls)
|
|
16
|
+
|
|
17
|
+
return cls.instance
|
|
18
|
+
|
|
19
|
+
def __init__(self, successor: Command=None):
|
|
20
|
+
super().__init__(successor)
|
|
21
|
+
self.auto_repaired = False
|
|
22
|
+
|
|
23
|
+
def command(self):
|
|
24
|
+
return AuditRepairTables.COMMAND
|
|
25
|
+
|
|
26
|
+
def required(self):
|
|
27
|
+
return ReplState.L
|
|
28
|
+
|
|
29
|
+
def run(self, cmd: str, state: ReplState):
|
|
30
|
+
if not(args := self.args(cmd)):
|
|
31
|
+
return super().run(cmd, state)
|
|
32
|
+
|
|
33
|
+
with self.validate(args, state) as (args, state):
|
|
34
|
+
tables = Config().get('audit.athena.repair-partition-tables', 'audit').split(',')
|
|
35
|
+
if args:
|
|
36
|
+
tables = args
|
|
37
|
+
|
|
38
|
+
meta = Audits.get_meta()
|
|
39
|
+
self.repair(tables, meta)
|
|
40
|
+
|
|
41
|
+
return state
|
|
42
|
+
|
|
43
|
+
def completion(self, state: ReplState):
|
|
44
|
+
# trigger auto repair if on l: drive
|
|
45
|
+
if state.device == ReplState.L:
|
|
46
|
+
if not self.auto_repaired:
|
|
47
|
+
if hours := Config().get('audit.athena.auto-repair.elapsed_hours', 12):
|
|
48
|
+
with Audits.offload() as exec:
|
|
49
|
+
exec.submit(lambda: self.auto_repair(hours))
|
|
50
|
+
|
|
51
|
+
return super().completion(state)
|
|
52
|
+
|
|
53
|
+
return {}
|
|
54
|
+
|
|
55
|
+
def auto_repair(self, hours: int):
|
|
56
|
+
self.auto_repaired = True
|
|
57
|
+
|
|
58
|
+
meta: AuditMeta = Audits.get_meta()
|
|
59
|
+
if meta.partitions_last_checked + hours * 60 * 60 < time.time():
|
|
60
|
+
tables = Config().get('audit.athena.repair-partition-tables', 'audit').split(',')
|
|
61
|
+
self.repair(tables, meta, show_sql=True)
|
|
62
|
+
log2(f'Audit tables have been auto-repaired.')
|
|
63
|
+
|
|
64
|
+
def repair(self, tables: list[str], meta: AuditMeta, show_sql = False):
|
|
65
|
+
with Audits.offload() as exec:
|
|
66
|
+
for table in tables:
|
|
67
|
+
if show_sql:
|
|
68
|
+
log(f'MSCK REPAIR TABLE {table}')
|
|
69
|
+
|
|
70
|
+
exec.submit(Athena.query, f'MSCK REPAIR TABLE {table}', None,)
|
|
71
|
+
exec.submit(Audits.put_meta, Audits.PARTITIONS_ADDED, meta,)
|
|
72
|
+
|
|
73
|
+
def help(self, _: ReplState):
|
|
74
|
+
return f"{AuditRepairTables.COMMAND}\t run MSCK REPAIR command for new partition discovery"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from adam.commands.command import Command
|
|
2
|
+
from adam.config import Config
|
|
3
|
+
from adam.repl_state import ReplState
|
|
4
|
+
from adam.utils import log2
|
|
5
|
+
from adam.utils_athena import Athena
|
|
6
|
+
from adam.utils_audits import AuditMeta, Audits
|
|
7
|
+
|
|
8
|
+
class AuditRun(Command):
|
|
9
|
+
COMMAND = 'audit run'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(AuditRun, cls).__new__(cls)
|
|
14
|
+
|
|
15
|
+
return cls.instance
|
|
16
|
+
|
|
17
|
+
def __init__(self, successor: Command=None):
|
|
18
|
+
super().__init__(successor)
|
|
19
|
+
self.auto_repaired = False
|
|
20
|
+
|
|
21
|
+
def command(self):
|
|
22
|
+
return AuditRun.COMMAND
|
|
23
|
+
|
|
24
|
+
def required(self):
|
|
25
|
+
return ReplState.L
|
|
26
|
+
|
|
27
|
+
def run(self, cmd: str, state: ReplState):
|
|
28
|
+
if not(args := self.args(cmd)):
|
|
29
|
+
return super().run(cmd, state)
|
|
30
|
+
|
|
31
|
+
with self.validate(args, state) as (args, state):
|
|
32
|
+
meta: AuditMeta = Audits.get_meta()
|
|
33
|
+
clusters = Audits.find_new_clusters(meta.cluster_last_checked)
|
|
34
|
+
Audits.put_meta(Audits.ADD_CLUSTERS, meta, clusters=clusters)
|
|
35
|
+
if clusters:
|
|
36
|
+
log2(f'Added {len(clusters)} new clusters.')
|
|
37
|
+
tables = Config().get('audit.athena.repair-cluster-tables', 'cluster').split(',')
|
|
38
|
+
with Audits.offload() as exec:
|
|
39
|
+
for table in tables:
|
|
40
|
+
exec.submit(Athena.query, f'MSCK REPAIR TABLE {table}', None,)
|
|
41
|
+
else:
|
|
42
|
+
log2(f'No new clusters were found.')
|
|
43
|
+
|
|
44
|
+
return state
|
|
45
|
+
|
|
46
|
+
def completion(self, state: ReplState):
|
|
47
|
+
return super().completion(state)
|
|
48
|
+
|
|
49
|
+
def help(self, _: ReplState):
|
|
50
|
+
return f"{AuditRun.COMMAND}\t run"
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from adam.commands.audit.utils_show_top10 import extract_limit_and_duration
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.repl_state import ReplState
|
|
4
|
+
from adam.utils import log2
|
|
5
|
+
from adam.utils_athena import Athena
|
|
6
|
+
from adam.utils_audits import Audits
|
|
7
|
+
|
|
8
|
+
class ShowLast10(Command):
|
|
9
|
+
COMMAND = 'show last'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(ShowLast10, cls).__new__(cls)
|
|
14
|
+
|
|
15
|
+
return cls.instance
|
|
16
|
+
|
|
17
|
+
def __init__(self, successor: Command=None):
|
|
18
|
+
super().__init__(successor)
|
|
19
|
+
|
|
20
|
+
def command(self):
|
|
21
|
+
return ShowLast10.COMMAND
|
|
22
|
+
|
|
23
|
+
def required(self):
|
|
24
|
+
return ReplState.L
|
|
25
|
+
|
|
26
|
+
def run(self, cmd: str, state: ReplState):
|
|
27
|
+
if not(args := self.args(cmd)):
|
|
28
|
+
return super().run(cmd, state)
|
|
29
|
+
|
|
30
|
+
with self.validate(args, state) as (args, state):
|
|
31
|
+
limit, date_condition = extract_limit_and_duration(args)
|
|
32
|
+
|
|
33
|
+
query = '\n '.join([
|
|
34
|
+
"SELECT * FROM audit",
|
|
35
|
+
f"WHERE drive <> 'z' and ({date_condition})",
|
|
36
|
+
f"ORDER BY ts DESC LIMIT {limit};"])
|
|
37
|
+
log2(query)
|
|
38
|
+
log2()
|
|
39
|
+
Athena.run_query(query)
|
|
40
|
+
|
|
41
|
+
return state
|
|
42
|
+
|
|
43
|
+
def completion(self, _: ReplState):
|
|
44
|
+
|
|
45
|
+
return {}
|
|
46
|
+
|
|
47
|
+
def help(self, _: ReplState):
|
|
48
|
+
return f'{ShowLast10.COMMAND} [limit]\t show last <limit> audit lines'
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from adam.commands.audit.utils_show_top10 import extract_limit_and_duration
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.repl_state import ReplState
|
|
4
|
+
from adam.utils import log2
|
|
5
|
+
from adam.utils_athena import Athena
|
|
6
|
+
from adam.utils_audits import Audits
|
|
7
|
+
|
|
8
|
+
class ShowSlow10(Command):
|
|
9
|
+
COMMAND = 'show slow'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(ShowSlow10, cls).__new__(cls)
|
|
14
|
+
|
|
15
|
+
return cls.instance
|
|
16
|
+
|
|
17
|
+
def __init__(self, successor: Command=None):
|
|
18
|
+
super().__init__(successor)
|
|
19
|
+
|
|
20
|
+
def command(self):
|
|
21
|
+
return ShowSlow10.COMMAND
|
|
22
|
+
|
|
23
|
+
def required(self):
|
|
24
|
+
return ReplState.L
|
|
25
|
+
|
|
26
|
+
def run(self, cmd: str, state: ReplState):
|
|
27
|
+
if not(args := self.args(cmd)):
|
|
28
|
+
return super().run(cmd, state)
|
|
29
|
+
|
|
30
|
+
with self.validate(args, state) as (args, state):
|
|
31
|
+
limit, date_condition = extract_limit_and_duration(args)
|
|
32
|
+
|
|
33
|
+
query = '\n '.join([
|
|
34
|
+
"SELECT * FROM audit",
|
|
35
|
+
f"WHERE drive <> 'z' and ({date_condition})",
|
|
36
|
+
f"ORDER BY CAST(duration AS REAL) DESC LIMIT {limit};"])
|
|
37
|
+
log2(query)
|
|
38
|
+
log2()
|
|
39
|
+
Athena.run_query(query)
|
|
40
|
+
|
|
41
|
+
return state
|
|
42
|
+
|
|
43
|
+
def completion(self, _: ReplState):
|
|
44
|
+
return {}
|
|
45
|
+
|
|
46
|
+
def help(self, _: ReplState):
|
|
47
|
+
return f'{ShowSlow10.COMMAND} [limit]\t show slow <limit> audit lines'
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from adam.commands.audit.utils_show_top10 import extract_limit_and_duration
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.repl_state import ReplState
|
|
4
|
+
from adam.utils import log2
|
|
5
|
+
from adam.utils_athena import Athena
|
|
6
|
+
|
|
7
|
+
class ShowTop10(Command):
|
|
8
|
+
COMMAND = 'show top'
|
|
9
|
+
|
|
10
|
+
# the singleton pattern
|
|
11
|
+
def __new__(cls, *args, **kwargs):
|
|
12
|
+
if not hasattr(cls, 'instance'): cls.instance = super(ShowTop10, cls).__new__(cls)
|
|
13
|
+
|
|
14
|
+
return cls.instance
|
|
15
|
+
|
|
16
|
+
def __init__(self, successor: Command=None):
|
|
17
|
+
super().__init__(successor)
|
|
18
|
+
|
|
19
|
+
def command(self):
|
|
20
|
+
return ShowTop10.COMMAND
|
|
21
|
+
|
|
22
|
+
def required(self):
|
|
23
|
+
return ReplState.L
|
|
24
|
+
|
|
25
|
+
def run(self, cmd: str, state: ReplState):
|
|
26
|
+
if not(args := self.args(cmd)):
|
|
27
|
+
return super().run(cmd, state)
|
|
28
|
+
|
|
29
|
+
with self.validate(args, state) as (args, state):
|
|
30
|
+
limit, date_condition = extract_limit_and_duration(args)
|
|
31
|
+
query = '\n '.join([
|
|
32
|
+
"SELECT min(c) AS cluster, line, COUNT(*) AS cnt, avg(CAST(duration AS REAL)) AS duration",
|
|
33
|
+
f"FROM audit WHERE drive <> 'z' and ({date_condition})",
|
|
34
|
+
f"GROUP BY line ORDER BY cnt DESC LIMIT {limit};"])
|
|
35
|
+
log2(query)
|
|
36
|
+
log2()
|
|
37
|
+
Athena.run_query(query)
|
|
38
|
+
|
|
39
|
+
return state
|
|
40
|
+
|
|
41
|
+
def completion(self, _: ReplState):
|
|
42
|
+
return {}
|
|
43
|
+
|
|
44
|
+
def help(self, _: ReplState):
|
|
45
|
+
return f'{ShowTop10.COMMAND} [limit]\t show top <limit> audit lines'
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from datetime import datetime, timedelta
|
|
2
|
+
|
|
3
|
+
from adam.utils_audits import Audits
|
|
4
|
+
from adam.utils_repl.automata_completer import AutomataCompleter
|
|
5
|
+
from adam.utils_repl.state_machine import StateMachine
|
|
6
|
+
|
|
7
|
+
def extract_limit_and_duration(args: list[str]) -> tuple[int, datetime]:
|
|
8
|
+
limit = 10
|
|
9
|
+
_from = datetime.now() - timedelta(days=30)
|
|
10
|
+
if args:
|
|
11
|
+
try:
|
|
12
|
+
limit = int(args[0])
|
|
13
|
+
except:
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
if len(args) > 2 and args[1] == 'over':
|
|
17
|
+
if args[2] == 'day':
|
|
18
|
+
_from = datetime.now() - timedelta(days=1)
|
|
19
|
+
|
|
20
|
+
return (limit, Audits.date_from(_from))
|
|
21
|
+
|
|
22
|
+
def limit_and_duration_completion():
|
|
23
|
+
return {'10': {'over': {
|
|
24
|
+
'day': None,
|
|
25
|
+
'month': None
|
|
26
|
+
}}}
|
|
27
|
+
|
|
28
|
+
SHOW_TOP10_SPEC = [
|
|
29
|
+
' > show > show',
|
|
30
|
+
'show > last|slow|top > show_top ^ last,slow,top',
|
|
31
|
+
'show_top > word > show_top_n ^ 10',
|
|
32
|
+
'show_top_n > over > show_top_n_over ^ over',
|
|
33
|
+
'show_top_n_over > day|month > show_top_n_over$ ^ day,month',
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
SHOW_TOP10_KEYWORDS = [
|
|
37
|
+
'show',
|
|
38
|
+
'top',
|
|
39
|
+
'last',
|
|
40
|
+
'slow',
|
|
41
|
+
'over',
|
|
42
|
+
'day',
|
|
43
|
+
'month'
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
class ShowTop10StateMachine(StateMachine[str]):
|
|
47
|
+
def spec(self) -> str:
|
|
48
|
+
return SHOW_TOP10_SPEC
|
|
49
|
+
|
|
50
|
+
def keywords(self) -> list[str]:
|
|
51
|
+
return SHOW_TOP10_KEYWORDS
|
|
52
|
+
|
|
53
|
+
def show_top10_completions_for_nesting():
|
|
54
|
+
return {
|
|
55
|
+
'show': {
|
|
56
|
+
'last': AutomataCompleter(ShowTop10StateMachine(), first_term='show last'),
|
|
57
|
+
'slow': AutomataCompleter(ShowTop10StateMachine(), first_term='show slow'),
|
|
58
|
+
'top': AutomataCompleter(ShowTop10StateMachine(), first_term='show top'),
|
|
59
|
+
}}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from adam.commands.bash import bash
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.commands.devices.devices import Devices
|
|
4
|
+
from adam.repl_state import ReplState, RequiredState
|
|
5
|
+
|
|
6
|
+
class Bash(Command):
|
|
7
|
+
COMMAND = 'bash'
|
|
8
|
+
|
|
9
|
+
# the singleton pattern
|
|
10
|
+
def __new__(cls, *args, **kwargs):
|
|
11
|
+
if not hasattr(cls, 'instance'): cls.instance = super(Bash, cls).__new__(cls)
|
|
12
|
+
|
|
13
|
+
return cls.instance
|
|
14
|
+
|
|
15
|
+
def __init__(self, successor: Command=None):
|
|
16
|
+
super().__init__(successor)
|
|
17
|
+
|
|
18
|
+
def command(self):
|
|
19
|
+
return Bash.COMMAND
|
|
20
|
+
|
|
21
|
+
def required(self):
|
|
22
|
+
return [RequiredState.CLUSTER_OR_POD, RequiredState.APP_APP, ReplState.P]
|
|
23
|
+
|
|
24
|
+
def run(self, cmd: str, s0: ReplState):
|
|
25
|
+
if not(args := self.args(cmd)):
|
|
26
|
+
return super().run(cmd, s0)
|
|
27
|
+
|
|
28
|
+
with self.validate(args, s0) as (args, s1):
|
|
29
|
+
with bash(s0, s1) as exec:
|
|
30
|
+
return exec(args)
|
|
31
|
+
|
|
32
|
+
def completion(self, state: ReplState):
|
|
33
|
+
return Devices.device(state).bash_completion(Bash.COMMAND, state, default = {})
|
|
34
|
+
|
|
35
|
+
def help(self, _: ReplState):
|
|
36
|
+
return f'{Bash.COMMAND} [pod-name] [bash-commands] [&]\t run bash on the Cassandra nodes'
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
from prompt_toolkit.completion import WordCompleter
|
|
3
|
+
|
|
4
|
+
from adam.utils_repl.automata_completer import AutomataCompleter
|
|
5
|
+
from adam.utils_repl.state_machine import State, StateMachine
|
|
6
|
+
|
|
7
|
+
BASH_SPEC = [
|
|
8
|
+
# <command> ::= <simple_command> | <pipeline> | <conditional_command>
|
|
9
|
+
# <simple_command> ::= <word> <argument>* <redirection>*
|
|
10
|
+
# <pipeline> ::= <command> '|' <command>
|
|
11
|
+
# <conditional_command> ::= <command> '&&' <command> | <command> '||' <command>
|
|
12
|
+
# <word> ::= <letter> <letter_or_digit>*
|
|
13
|
+
# <argument> ::= <word>
|
|
14
|
+
# <redirection> ::= '>' <filename> | '<' <filename>
|
|
15
|
+
# <filename> ::= <word>
|
|
16
|
+
# <letter> ::= 'a' | 'b' | ... | 'z' | 'A' | 'B' | ... | 'Z'
|
|
17
|
+
# <digit> ::= '0' | '1' | ... | '9'
|
|
18
|
+
# <letter_or_digit> ::= <letter> | <digit>
|
|
19
|
+
|
|
20
|
+
' > word > cmd ^ hosts',
|
|
21
|
+
'cmd > word > cmd ^ |,>,2>,<,&,&&,||',
|
|
22
|
+
'- > pipe > cmd_pipe',
|
|
23
|
+
'- > _rdr0_ > cmd_rdr0',
|
|
24
|
+
'- > _rdr1_ > cmd_rdr1',
|
|
25
|
+
'- > _rdr2_ > cmd_rdr2',
|
|
26
|
+
'- > & > cmd_bg ^ |,>,2>,<,&,&&,||',
|
|
27
|
+
'- > &&|_or_ > nocmd',
|
|
28
|
+
'cmd_a > word > cmd',
|
|
29
|
+
'cmd_pipe > word > cmd',
|
|
30
|
+
'cmd_rdr0 > word > cmd_rdr0_f',
|
|
31
|
+
'cmd_rdr1 > word > cmd_rdr1_f',
|
|
32
|
+
'cmd_rdr2 > word > cmd_rdr2_f',
|
|
33
|
+
'cmd_rdr1_f > pipe > cmd_pipe ^ |,2>,<,&,&&,||',
|
|
34
|
+
'- > _rdr2_ > cmd_rdr2',
|
|
35
|
+
'- > _rdr0_ > cmd_rdr0',
|
|
36
|
+
'cmd_rdr2_f > pipe > cmd_pipe ^ |,<,&,&&,||',
|
|
37
|
+
'- > _rdr0_ > cmd_rdr0',
|
|
38
|
+
'- > & > cmd_bg ^ |,>,2>,<,&,&&,||',
|
|
39
|
+
'- > &&|_or_ > nocmd',
|
|
40
|
+
'cmd_rdr0_f > pipe > cmd_pipe ^ |,&,&&,||',
|
|
41
|
+
'- > & > cmd_bg ^ |,>,2>,<,&,&&,||',
|
|
42
|
+
'- > &&|_or_ > cmd',
|
|
43
|
+
'cmd_bg > &&|_or_ > nocmd ^ &&,||',
|
|
44
|
+
'nocmd > word > cmd',
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
BASH_KEYWORDS = [
|
|
48
|
+
'&',
|
|
49
|
+
'&&',
|
|
50
|
+
'|',
|
|
51
|
+
'||',
|
|
52
|
+
'>',
|
|
53
|
+
'2>',
|
|
54
|
+
'>>',
|
|
55
|
+
'<',
|
|
56
|
+
'hosts'
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
class BashStateMachine(StateMachine[str]):
|
|
60
|
+
def spec(self) -> str:
|
|
61
|
+
return BASH_SPEC
|
|
62
|
+
|
|
63
|
+
def keywords(self) -> list[str]:
|
|
64
|
+
return BASH_KEYWORDS
|
|
65
|
+
|
|
66
|
+
class BashCompleter(AutomataCompleter[str]):
|
|
67
|
+
def __init__(self,
|
|
68
|
+
hosts: Callable[[], list[str]],
|
|
69
|
+
debug = False):
|
|
70
|
+
super().__init__(BashStateMachine(debug=debug), '', debug=debug)
|
|
71
|
+
|
|
72
|
+
self.hosts = hosts
|
|
73
|
+
self.debug = debug
|
|
74
|
+
|
|
75
|
+
def suggestions_completer(self, state: State, suggestions: str) -> list[str]:
|
|
76
|
+
if not suggestions:
|
|
77
|
+
return None
|
|
78
|
+
|
|
79
|
+
terms = []
|
|
80
|
+
for suggestion in suggestions.split(','):
|
|
81
|
+
terms.extend(self._terms(state, suggestion))
|
|
82
|
+
|
|
83
|
+
return WordCompleter(terms)
|
|
84
|
+
|
|
85
|
+
def _terms(self, _: State, word: str) -> list[str]:
|
|
86
|
+
terms = []
|
|
87
|
+
|
|
88
|
+
if word == 'hosts':
|
|
89
|
+
terms.extend(self.hosts())
|
|
90
|
+
else:
|
|
91
|
+
terms.append(word)
|
|
92
|
+
|
|
93
|
+
return terms
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from adam.commands.devices.devices import Devices
|
|
2
|
+
from adam.repl_state import ReplState
|
|
3
|
+
|
|
4
|
+
class BashHandler:
|
|
5
|
+
def __init__(self, s0: ReplState, s1: ReplState):
|
|
6
|
+
self.s0 = s0
|
|
7
|
+
self.s1 = s1
|
|
8
|
+
|
|
9
|
+
def __enter__(self):
|
|
10
|
+
return self.exec
|
|
11
|
+
|
|
12
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
13
|
+
return False
|
|
14
|
+
|
|
15
|
+
def exec(self, args: list[str]):
|
|
16
|
+
return Devices.device(self.s1).bash(self.s0, self.s1, args)
|
adam/commands/cat.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from adam.commands.command import Command
|
|
2
|
+
from adam.commands.devices.devices import Devices
|
|
3
|
+
from adam.repl_state import ReplState, RequiredState
|
|
4
|
+
from adam.utils import log2
|
|
5
|
+
from adam.utils_k8s.app_pods import AppPods
|
|
6
|
+
from adam.utils_k8s.statefulsets import StatefulSets
|
|
7
|
+
|
|
8
|
+
class Cat(Command):
|
|
9
|
+
COMMAND = 'cat'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(Cat, cls).__new__(cls)
|
|
14
|
+
|
|
15
|
+
return cls.instance
|
|
16
|
+
|
|
17
|
+
def __init__(self, successor: Command=None):
|
|
18
|
+
super().__init__(successor)
|
|
19
|
+
|
|
20
|
+
def command(self):
|
|
21
|
+
return Cat.COMMAND
|
|
22
|
+
|
|
23
|
+
def required(self):
|
|
24
|
+
return [RequiredState.CLUSTER_OR_POD, RequiredState.APP_APP, ReplState.P]
|
|
25
|
+
|
|
26
|
+
def run(self, cmd: str, state: ReplState):
|
|
27
|
+
if not(args := self.args(cmd)):
|
|
28
|
+
return super().run(cmd, state)
|
|
29
|
+
|
|
30
|
+
with self.validate(args, state) as (args, state):
|
|
31
|
+
if len(args) < 1:
|
|
32
|
+
if state.in_repl:
|
|
33
|
+
log2('File is required.')
|
|
34
|
+
log2()
|
|
35
|
+
else:
|
|
36
|
+
log2('* File is missing.')
|
|
37
|
+
Command.display_help()
|
|
38
|
+
|
|
39
|
+
return 'command-missing'
|
|
40
|
+
|
|
41
|
+
return Devices.device(state).cat(cmd, state)
|
|
42
|
+
|
|
43
|
+
def completion(self, state: ReplState):
|
|
44
|
+
if super().completion(state):
|
|
45
|
+
return Devices.device(state).cat_completion(Cat.COMMAND, state, default={})
|
|
46
|
+
|
|
47
|
+
return {}
|
|
48
|
+
|
|
49
|
+
def help(self, _: ReplState):
|
|
50
|
+
return f'{Cat.COMMAND} file [&]\t run cat command on the Cassandra nodes'
|
adam/commands/cd.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from adam.commands.command import Command
|
|
2
|
+
from adam.commands.devices.device import Device
|
|
3
|
+
from adam.commands.devices.devices import Devices
|
|
4
|
+
from adam.repl_state import ReplState
|
|
5
|
+
|
|
6
|
+
class Cd(Command):
|
|
7
|
+
COMMAND = 'cd'
|
|
8
|
+
|
|
9
|
+
# the singleton pattern
|
|
10
|
+
def __new__(cls, *args, **kwargs):
|
|
11
|
+
if not hasattr(cls, 'instance'): cls.instance = super(Cd, cls).__new__(cls)
|
|
12
|
+
|
|
13
|
+
return cls.instance
|
|
14
|
+
|
|
15
|
+
def __init__(self, successor: Command=None):
|
|
16
|
+
super().__init__(successor)
|
|
17
|
+
|
|
18
|
+
def command(self):
|
|
19
|
+
return Cd.COMMAND
|
|
20
|
+
|
|
21
|
+
def required(self):
|
|
22
|
+
return ReplState.NON_L
|
|
23
|
+
|
|
24
|
+
def run(self, cmd: str, state: ReplState):
|
|
25
|
+
if not(args := self.args(cmd)):
|
|
26
|
+
return super().run(cmd, state)
|
|
27
|
+
|
|
28
|
+
with self.validate(args, state, apply=False) as (args, state):
|
|
29
|
+
if len(args) < 2:
|
|
30
|
+
return state
|
|
31
|
+
|
|
32
|
+
device: Device = Devices.device(state)
|
|
33
|
+
arg = args[1]
|
|
34
|
+
for dir in arg.split('/'):
|
|
35
|
+
device.cd(dir, state)
|
|
36
|
+
|
|
37
|
+
return state
|
|
38
|
+
|
|
39
|
+
def completion(self, state: ReplState):
|
|
40
|
+
return Devices.device(state).cd_completion(Cd.COMMAND, state, default = {})
|
|
41
|
+
|
|
42
|
+
def help(self, _: ReplState):
|
|
43
|
+
return f'{Cd.COMMAND} <path> | .. \t move around on the operational device hierarchy'
|
adam/commands/check.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from adam.checks.check_result import CheckResult
|
|
4
|
+
from adam.checks.check_utils import all_checks, checks_from_csv, run_checks
|
|
5
|
+
from adam.commands import extract_options
|
|
6
|
+
from adam.commands.command import Command
|
|
7
|
+
from adam.commands.command_helpers import ClusterOrPodCommandHelper
|
|
8
|
+
from adam.commands.issues import Issues
|
|
9
|
+
from adam.repl_state import ReplState
|
|
10
|
+
from adam.utils import lines_to_tabular, log
|
|
11
|
+
from adam.utils_issues import IssuesUtils
|
|
12
|
+
|
|
13
|
+
class Check(Issues):
|
|
14
|
+
COMMAND = 'check'
|
|
15
|
+
|
|
16
|
+
# the singleton pattern
|
|
17
|
+
def __new__(cls, *args, **kwargs):
|
|
18
|
+
if not hasattr(cls, 'instance'): cls.instance = super(Check, cls).__new__(cls)
|
|
19
|
+
|
|
20
|
+
return cls.instance
|
|
21
|
+
|
|
22
|
+
def __init__(self, successor: Command=None):
|
|
23
|
+
super().__init__(successor)
|
|
24
|
+
|
|
25
|
+
def command(self):
|
|
26
|
+
return Check.COMMAND
|
|
27
|
+
|
|
28
|
+
def required(self):
|
|
29
|
+
return ReplState.NON_L
|
|
30
|
+
|
|
31
|
+
def run(self, cmd: str, state: ReplState):
|
|
32
|
+
if not(args := self.args(cmd)):
|
|
33
|
+
return super().run(cmd, state)
|
|
34
|
+
|
|
35
|
+
with self.validate(args, state) as (args, state):
|
|
36
|
+
with extract_options(args, ['-s', '--show']) as (args, show_out):
|
|
37
|
+
if not args:
|
|
38
|
+
if state.in_repl:
|
|
39
|
+
log(lines_to_tabular([check.help() for check in all_checks()], separator=':'))
|
|
40
|
+
else:
|
|
41
|
+
log('* Check name is missing.')
|
|
42
|
+
Command.display_help()
|
|
43
|
+
|
|
44
|
+
return 'arg missing'
|
|
45
|
+
|
|
46
|
+
checks = checks_from_csv(args[0])
|
|
47
|
+
if not checks:
|
|
48
|
+
return 'invalid check name'
|
|
49
|
+
|
|
50
|
+
results = run_checks(state.sts, state.namespace, state.pod, checks=checks, show_out=show_out)
|
|
51
|
+
|
|
52
|
+
issues = CheckResult.collect_issues(results)
|
|
53
|
+
IssuesUtils.show_issues(issues, in_repl=state.in_repl)
|
|
54
|
+
|
|
55
|
+
return issues if issues else 'no issues found'
|
|
56
|
+
|
|
57
|
+
def completion(self, _: ReplState):
|
|
58
|
+
return {Check.COMMAND: {check.name(): {'-s': None} for check in all_checks()}}
|
|
59
|
+
|
|
60
|
+
def help(self, _: ReplState):
|
|
61
|
+
return f'{Check.COMMAND} <check-name> [-s]\t run a single check'
|
|
62
|
+
|
|
63
|
+
class CheckCommandHelper(click.Command):
|
|
64
|
+
def get_help(self, ctx: click.Context):
|
|
65
|
+
log(super().get_help(ctx))
|
|
66
|
+
log()
|
|
67
|
+
log('Check-names:')
|
|
68
|
+
|
|
69
|
+
for check in all_checks():
|
|
70
|
+
log(f' {check.name()}')
|
|
71
|
+
log()
|
|
72
|
+
|
|
73
|
+
ClusterOrPodCommandHelper.cluter_or_pod_help()
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import functools
|
|
2
2
|
import re
|
|
3
3
|
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from
|
|
8
|
-
from
|
|
9
|
-
from
|
|
4
|
+
from adam.commands.reaper.utils_reaper import Reapers
|
|
5
|
+
from adam.config import Config
|
|
6
|
+
from adam.utils_k8s.kube_context import KubeContext
|
|
7
|
+
from adam.utils_k8s.secrets import Secrets
|
|
8
|
+
from adam.utils_k8s.statefulsets import StatefulSets
|
|
9
|
+
from adam.repl_state import ReplState
|
|
10
10
|
|
|
11
11
|
class CliCommands:
|
|
12
12
|
@functools.lru_cache()
|
|
@@ -66,8 +66,7 @@ class CliCommands:
|
|
|
66
66
|
return key.replace(f'{state.namespace}-', '').replace('-k8spg-cs-001', '')
|
|
67
67
|
d |= {f'pg-{reduce_key(k)}': f'PGPASSWORD={v["postgres-admin-password"]} psql -h {v["postgres-db-endpoint"]} -p {v["postgres-db-port"]} -U {v["postgres-admin-username"]} postgres' for k, v in data.items()}
|
|
68
68
|
|
|
69
|
-
if
|
|
70
|
-
reaper = r.reaper_spec(state)
|
|
69
|
+
if reaper := Reapers.reaper_spec(state):
|
|
71
70
|
d |= {
|
|
72
71
|
'reaper-exec': reaper["exec"],
|
|
73
72
|
'reaper-forward': reaper["forward"],
|