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
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import time
|
|
2
|
-
|
|
3
|
-
from walker.commands.command import Command
|
|
4
|
-
from walker.k8s_utils.pods import Pods
|
|
5
|
-
from walker.repl_state import ReplState, RequiredState
|
|
6
|
-
from walker.utils import log2
|
|
7
|
-
from walker.config import Config
|
|
8
|
-
|
|
9
|
-
class RepairScan(Command):
|
|
10
|
-
COMMAND = 'repair scan'
|
|
11
|
-
|
|
12
|
-
# the singleton pattern
|
|
13
|
-
def __new__(cls, *args, **kwargs):
|
|
14
|
-
if not hasattr(cls, 'instance'): cls.instance = super(RepairScan, cls).__new__(cls)
|
|
15
|
-
|
|
16
|
-
return cls.instance
|
|
17
|
-
|
|
18
|
-
def __init__(self, successor: Command=None):
|
|
19
|
-
super().__init__(successor)
|
|
20
|
-
|
|
21
|
-
def command(self):
|
|
22
|
-
return RepairScan.COMMAND
|
|
23
|
-
|
|
24
|
-
def required(self):
|
|
25
|
-
return RequiredState.CLUSTER
|
|
26
|
-
|
|
27
|
-
def run(self, cmd: str, state: ReplState):
|
|
28
|
-
if not(args := self.args(cmd)):
|
|
29
|
-
return super().run(cmd, state)
|
|
30
|
-
|
|
31
|
-
state, args = self.apply_state(args, state)
|
|
32
|
-
if not self.validate_state(state):
|
|
33
|
-
return state
|
|
34
|
-
|
|
35
|
-
n = "7"
|
|
36
|
-
if len(args) == 1:
|
|
37
|
-
n = str(args[0])
|
|
38
|
-
image = Config().get('repair.image', 'ci-registry.c3iot.io/cloudops/cassrepair:2.0.11')
|
|
39
|
-
secret = Config().get('repair.secret', 'ciregistryc3iotio')
|
|
40
|
-
log_path = secret = Config().get('repair.log-path', '/home/cassrepair/logs/')
|
|
41
|
-
ns = state.namespace
|
|
42
|
-
pvc_name ='cassrepair-log-' + state.sts
|
|
43
|
-
pod_name = 'repair-scan'
|
|
44
|
-
|
|
45
|
-
try:
|
|
46
|
-
Pods.create(ns, pod_name, image, ["sh", "-c", "tail -f /dev/null"],
|
|
47
|
-
secret=secret,
|
|
48
|
-
env={},
|
|
49
|
-
volume_name='cassrepair-log',
|
|
50
|
-
pvc_name=pvc_name,
|
|
51
|
-
mount_path='/home/cassrepair/logs/')
|
|
52
|
-
except Exception as e:
|
|
53
|
-
if e.status == 409:
|
|
54
|
-
log2(f"Pod {pod_name} already exists")
|
|
55
|
-
else:
|
|
56
|
-
log2("Exception when calling BatchV1Apii->create_namespaced_job: %s\n" % e)
|
|
57
|
-
|
|
58
|
-
msged = False
|
|
59
|
-
while Pods.get(ns, pod_name).status.phase != 'Running':
|
|
60
|
-
if not msged:
|
|
61
|
-
log2("Waiting for the scanner pod to start up...")
|
|
62
|
-
msged = True
|
|
63
|
-
time.sleep(5)
|
|
64
|
-
|
|
65
|
-
try:
|
|
66
|
-
Pods.exec(pod_name, pod_name, ns, f"find {log_path} -type f -mtime -{n} -print0 | xargs -0 grep failed")
|
|
67
|
-
finally:
|
|
68
|
-
Pods.delete(pod_name, ns)
|
|
69
|
-
|
|
70
|
-
return state
|
|
71
|
-
|
|
72
|
-
def completion(self, state: ReplState):
|
|
73
|
-
if state.sts:
|
|
74
|
-
return super().completion(state)
|
|
75
|
-
|
|
76
|
-
return {}
|
|
77
|
-
|
|
78
|
-
def help(self, _: ReplState):
|
|
79
|
-
return f'{RepairScan.COMMAND} [n]\t scan last n days repair log, default 7 days'
|
walker/commands/report.py
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import click
|
|
2
|
-
import json
|
|
3
|
-
|
|
4
|
-
from walker.checks.check_result import CheckResult
|
|
5
|
-
from walker.checks.check_utils import run_checks
|
|
6
|
-
from walker.commands.command import Command
|
|
7
|
-
from walker.repl_state import ReplState
|
|
8
|
-
from walker.utils import log2
|
|
9
|
-
|
|
10
|
-
class Report(Command):
|
|
11
|
-
COMMAND = 'report'
|
|
12
|
-
|
|
13
|
-
# the singleton pattern
|
|
14
|
-
def __new__(cls, *args, **kwargs):
|
|
15
|
-
if not hasattr(cls, 'instance'): cls.instance = super(Report, cls).__new__(cls)
|
|
16
|
-
|
|
17
|
-
return cls.instance
|
|
18
|
-
|
|
19
|
-
def __init__(self, successor: Command=None):
|
|
20
|
-
super().__init__(successor)
|
|
21
|
-
|
|
22
|
-
def command(self):
|
|
23
|
-
return Report.COMMAND
|
|
24
|
-
|
|
25
|
-
def run(self, cmd: str, state: ReplState):
|
|
26
|
-
if not(args := self.args(cmd)):
|
|
27
|
-
return super().run(cmd, state)
|
|
28
|
-
|
|
29
|
-
output: dict[str, any] = {}
|
|
30
|
-
state, args = self.apply_state(args, state)
|
|
31
|
-
if state.in_repl:
|
|
32
|
-
args, show = Command.extract_options(args, ['-s', '--show'])
|
|
33
|
-
|
|
34
|
-
args, redirect = Command.extract_options(args, ['>'])
|
|
35
|
-
if not redirect or not args:
|
|
36
|
-
log2('Please specify file name: e.g. report > /tmp/report.log')
|
|
37
|
-
return 'no-report-destination'
|
|
38
|
-
|
|
39
|
-
results = run_checks(state.sts, state.namespace, state.pod, show_output=show)
|
|
40
|
-
output = CheckResult.report(results)
|
|
41
|
-
with open(args[0], "w") as json_file:
|
|
42
|
-
json.dump(output, json_file, indent=2)
|
|
43
|
-
log2(f'Report stored in {args[0]}.')
|
|
44
|
-
else:
|
|
45
|
-
args, show = Command.extract_options(args, ['-s', '--show'])
|
|
46
|
-
|
|
47
|
-
results = run_checks(state.sts, state.namespace, state.pod, show_output=show)
|
|
48
|
-
output = CheckResult.report(results)
|
|
49
|
-
click.echo(json.dumps(output, indent=2))
|
|
50
|
-
|
|
51
|
-
return output
|
|
52
|
-
|
|
53
|
-
def completion(self, _: ReplState):
|
|
54
|
-
return {Report.COMMAND: {">": None}}
|
|
55
|
-
|
|
56
|
-
def help(self, _: ReplState):
|
|
57
|
-
return f"{Report.COMMAND} > <file-name>\t generate report"
|
walker/commands/restart.py
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
from walker.commands.command import Command
|
|
2
|
-
from walker.k8s_utils.pods import Pods
|
|
3
|
-
from walker.k8s_utils.statefulsets import StatefulSets
|
|
4
|
-
from walker.repl_state import ReplState, RequiredState
|
|
5
|
-
from walker.utils import log2
|
|
6
|
-
|
|
7
|
-
class Restart(Command):
|
|
8
|
-
COMMAND = 'restart'
|
|
9
|
-
|
|
10
|
-
# the singleton pattern
|
|
11
|
-
def __new__(cls, *args, **kwargs):
|
|
12
|
-
if not hasattr(cls, 'instance'): cls.instance = super(Restart, 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 Restart.COMMAND
|
|
21
|
-
|
|
22
|
-
def required(self):
|
|
23
|
-
return RequiredState.CLUSTER_OR_POD
|
|
24
|
-
|
|
25
|
-
def run(self, cmd: str, state: ReplState):
|
|
26
|
-
if not(args := self.args(cmd)):
|
|
27
|
-
return super().run(cmd, state)
|
|
28
|
-
|
|
29
|
-
state, args = self.apply_state(args, state)
|
|
30
|
-
if not self.validate_state(state):
|
|
31
|
-
return state
|
|
32
|
-
|
|
33
|
-
args, forced = Command.extract_options(args, '--force')
|
|
34
|
-
if len(args) == 0:
|
|
35
|
-
if state.pod:
|
|
36
|
-
log2(f'Restarting {state.pod}...')
|
|
37
|
-
Pods.delete(state.pod, state.namespace)
|
|
38
|
-
else:
|
|
39
|
-
if not forced:
|
|
40
|
-
log2('Please add --force for restarting all nodes in a cluster.')
|
|
41
|
-
return 'force-needed'
|
|
42
|
-
|
|
43
|
-
log2(f'Restarting all pods from {state.sts}...')
|
|
44
|
-
for pod_name in StatefulSets.pod_names(state.sts, state.namespace):
|
|
45
|
-
Pods.delete(pod_name, state.namespace)
|
|
46
|
-
else:
|
|
47
|
-
for arg in args:
|
|
48
|
-
Pods.delete(arg, state.namespace)
|
|
49
|
-
|
|
50
|
-
return state
|
|
51
|
-
|
|
52
|
-
def completion(self, state: ReplState):
|
|
53
|
-
if state.pod:
|
|
54
|
-
return {Restart.COMMAND: None}
|
|
55
|
-
elif state.sts:
|
|
56
|
-
return {Restart.COMMAND: {p: None for p in StatefulSets.pod_names(state.sts, state.namespace)}}
|
|
57
|
-
|
|
58
|
-
return {}
|
|
59
|
-
|
|
60
|
-
def help(self, _: ReplState):
|
|
61
|
-
return f"{Restart.COMMAND} [<host-id>] [--force]\t restart the node you're in or all the nodes in the cluster"
|
walker/commands/show/show.py
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import click
|
|
2
|
-
|
|
3
|
-
from walker.commands.command import Command
|
|
4
|
-
from walker.commands.command_helpers import ClusterCommandHelper
|
|
5
|
-
from .show_params import ShowParams
|
|
6
|
-
from .show_app_id import ShowAppId
|
|
7
|
-
from .show_cassandra_status import ShowCassandraStatus
|
|
8
|
-
from .show_cassandra_version import ShowCassandraVersion
|
|
9
|
-
from .show_commands import ShowKubectlCommands
|
|
10
|
-
from .show_processes import ShowProcesses
|
|
11
|
-
from .show_repairs import ShowRepairs
|
|
12
|
-
from .show_storage import ShowStorage
|
|
13
|
-
from .show_version import ShowVersion
|
|
14
|
-
from walker.repl_state import ReplState, RequiredState
|
|
15
|
-
from walker.utils import lines_to_tabular, log, log2
|
|
16
|
-
|
|
17
|
-
class Show(Command):
|
|
18
|
-
COMMAND = 'show'
|
|
19
|
-
|
|
20
|
-
# the singleton pattern
|
|
21
|
-
def __new__(cls, *args, **kwargs):
|
|
22
|
-
if not hasattr(cls, 'instance'): cls.instance = super(Show, cls).__new__(cls)
|
|
23
|
-
|
|
24
|
-
return cls.instance
|
|
25
|
-
|
|
26
|
-
def __init__(self, successor: Command=None):
|
|
27
|
-
super().__init__(successor)
|
|
28
|
-
|
|
29
|
-
def command(self):
|
|
30
|
-
return Show.COMMAND
|
|
31
|
-
|
|
32
|
-
def required(self):
|
|
33
|
-
return RequiredState.CLUSTER_OR_POD
|
|
34
|
-
|
|
35
|
-
def run(self, cmd: str, state: ReplState):
|
|
36
|
-
if not(args := self.args(cmd)):
|
|
37
|
-
return super().run(cmd, state)
|
|
38
|
-
|
|
39
|
-
state, args = self.apply_state(args, state)
|
|
40
|
-
if state.in_repl and not self.validate_state(state):
|
|
41
|
-
return state
|
|
42
|
-
|
|
43
|
-
if state.in_repl:
|
|
44
|
-
log(lines_to_tabular([c.help(ReplState()) for c in Show.cmd_list()], separator=':'))
|
|
45
|
-
|
|
46
|
-
return 'command-missing'
|
|
47
|
-
else:
|
|
48
|
-
# head with the Chain of Responsibility pattern
|
|
49
|
-
cmds = Command.chain(Show.cmd_list())
|
|
50
|
-
if not cmds.run(cmd, state):
|
|
51
|
-
log2('* Command is missing.')
|
|
52
|
-
Command.display_help()
|
|
53
|
-
|
|
54
|
-
def cmd_list():
|
|
55
|
-
return [ShowKubectlCommands(), ShowParams(), ShowProcesses(), ShowRepairs(), ShowStorage(), ShowVersion(),
|
|
56
|
-
ShowCassandraStatus(), ShowCassandraVersion()]
|
|
57
|
-
|
|
58
|
-
def completion(self, state: ReplState):
|
|
59
|
-
return super().completion(state)
|
|
60
|
-
|
|
61
|
-
def help(self, _: ReplState):
|
|
62
|
-
return f"{Show.COMMAND}\t show kubectl commands"
|
|
63
|
-
|
|
64
|
-
class ShowCommandHelper(click.Command):
|
|
65
|
-
def get_help(self, ctx: click.Context):
|
|
66
|
-
log(super().get_help(ctx))
|
|
67
|
-
log()
|
|
68
|
-
log('Catogories:')
|
|
69
|
-
|
|
70
|
-
log(lines_to_tabular([c.help(ReplState()).replace(f'{Show.COMMAND} ', ' ', 1) for c in Show.cmd_list()], separator=':'))
|
|
71
|
-
log()
|
|
72
|
-
ClusterCommandHelper.cluster_help()
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
from walker.app_session import AppSession
|
|
2
|
-
from walker.apps import AppAction, Apps
|
|
3
|
-
from walker.commands.command import Command
|
|
4
|
-
from walker.config import Config
|
|
5
|
-
from walker.repl_state import ReplState
|
|
6
|
-
from walker.utils import lines_to_tabular, log
|
|
7
|
-
|
|
8
|
-
class ShowAppActions(Command):
|
|
9
|
-
COMMAND = 'show app actions'
|
|
10
|
-
|
|
11
|
-
# the singleton pattern
|
|
12
|
-
def __new__(cls, *args, **kwargs):
|
|
13
|
-
if not hasattr(cls, 'instance'): cls.instance = super(ShowAppActions, 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 ShowAppActions.COMMAND
|
|
22
|
-
|
|
23
|
-
def run(self, cmd: str, state: ReplState):
|
|
24
|
-
if not self.args(cmd):
|
|
25
|
-
return super().run(cmd, state)
|
|
26
|
-
|
|
27
|
-
lines = []
|
|
28
|
-
for typ in Apps().app_types():
|
|
29
|
-
for action in typ.actions:
|
|
30
|
-
a: AppAction = action
|
|
31
|
-
args = ','.join(a.arguments())
|
|
32
|
-
if args:
|
|
33
|
-
line = f'{typ.name}.{a.name},{args}'
|
|
34
|
-
else:
|
|
35
|
-
line = f'{typ.name}.{a.name},'
|
|
36
|
-
if a.help:
|
|
37
|
-
line = f'{line},{a.help}'
|
|
38
|
-
lines.append(line)
|
|
39
|
-
log(lines_to_tabular(lines, 'ACTION,ARGS,DESCRIPTION', separator=','))
|
|
40
|
-
log()
|
|
41
|
-
|
|
42
|
-
app_session: AppSession = AppSession.create(state.app_env or 'c3', state.app_app or 'c3')
|
|
43
|
-
endpoint = Config().get('app.console-endpoint', 'https://{host}/{env}/{app}/static/console/index.html')
|
|
44
|
-
endpoint = endpoint.replace('{host}', app_session.host).replace('{env}', app_session.env).replace('{app}', state.app_app or 'c3')
|
|
45
|
-
log(lines_to_tabular([f'CONSOLE:,{endpoint}'], separator=','))
|
|
46
|
-
|
|
47
|
-
return lines
|
|
48
|
-
|
|
49
|
-
def completion(self, state: ReplState):
|
|
50
|
-
return super().completion(state)
|
|
51
|
-
|
|
52
|
-
def help(self, _: ReplState):
|
|
53
|
-
return f"{ShowAppActions.COMMAND}\t show app actions"
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
from walker.commands.status import Status
|
|
2
|
-
from walker.commands.command import Command
|
|
3
|
-
from walker.repl_state import ReplState
|
|
4
|
-
|
|
5
|
-
class ShowCassandraStatus(Command):
|
|
6
|
-
COMMAND = 'show cassandra status'
|
|
7
|
-
|
|
8
|
-
# the singleton pattern
|
|
9
|
-
def __new__(cls, *args, **kwargs):
|
|
10
|
-
if not hasattr(cls, 'instance'): cls.instance = super(ShowCassandraStatus, cls).__new__(cls)
|
|
11
|
-
|
|
12
|
-
return cls.instance
|
|
13
|
-
|
|
14
|
-
def __init__(self, successor: Command=None):
|
|
15
|
-
super().__init__(successor)
|
|
16
|
-
|
|
17
|
-
def command(self):
|
|
18
|
-
return ShowCassandraStatus.COMMAND
|
|
19
|
-
|
|
20
|
-
def run(self, cmd: str, state: ReplState):
|
|
21
|
-
if not self.args(cmd):
|
|
22
|
-
return super().run(cmd, state)
|
|
23
|
-
|
|
24
|
-
Status().run(Status.COMMAND, state)
|
|
25
|
-
|
|
26
|
-
return state
|
|
27
|
-
|
|
28
|
-
def completion(self, state: ReplState):
|
|
29
|
-
if state.sts:
|
|
30
|
-
return super().completion(state)
|
|
31
|
-
|
|
32
|
-
return {}
|
|
33
|
-
|
|
34
|
-
def help(self, _: ReplState):
|
|
35
|
-
return f'{ShowCassandraStatus.COMMAND} [-s]\t show merged nodetool status -s show commands on nodes'
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
from walker.commands.command import Command
|
|
2
|
-
from walker.commands.cli_commands import CliCommands
|
|
3
|
-
from walker.repl_state import ReplState, RequiredState
|
|
4
|
-
from walker.utils import lines_to_tabular, log
|
|
5
|
-
|
|
6
|
-
class ShowKubectlCommands(Command):
|
|
7
|
-
COMMAND = 'show kubectl-commands'
|
|
8
|
-
|
|
9
|
-
# the singleton pattern
|
|
10
|
-
def __new__(cls, *args, **kwargs):
|
|
11
|
-
if not hasattr(cls, 'instance'): cls.instance = super(ShowKubectlCommands, 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 ShowKubectlCommands.COMMAND
|
|
20
|
-
|
|
21
|
-
def required(self):
|
|
22
|
-
return RequiredState.CLUSTER_OR_POD
|
|
23
|
-
|
|
24
|
-
def run(self, cmd: str, state: ReplState):
|
|
25
|
-
if not self.args(cmd):
|
|
26
|
-
return super().run(cmd, state)
|
|
27
|
-
|
|
28
|
-
if not self.validate_state(state):
|
|
29
|
-
return state
|
|
30
|
-
|
|
31
|
-
v = CliCommands.values(state, collapse=True)
|
|
32
|
-
# node-exec-?, nodetool-?, cql-?, reaper-exec, reaper-forward, reaper-ui, reaper-username, reaper-password
|
|
33
|
-
cmds = [
|
|
34
|
-
f'bash,{v["node-exec-?"]}',
|
|
35
|
-
f'nodetool,{v["nodetool-?"]}',
|
|
36
|
-
f'cql,{v["cql-?"]}',
|
|
37
|
-
]
|
|
38
|
-
|
|
39
|
-
if 'reaper-exec' in v:
|
|
40
|
-
cmds += [
|
|
41
|
-
f'reaper,{v["reaper-exec"]}',
|
|
42
|
-
f',{v["reaper-forward"]} * should be run from your laptop',
|
|
43
|
-
f',{v["reaper-ui"]}',
|
|
44
|
-
f',{v["reaper-username"]}',
|
|
45
|
-
f',{v["reaper-password"]}',
|
|
46
|
-
]
|
|
47
|
-
|
|
48
|
-
cmds += [f'{k},{v0}' for k, v0 in v.items() if k.startswith('pg-')]
|
|
49
|
-
|
|
50
|
-
log(lines_to_tabular(cmds, separator=','))
|
|
51
|
-
|
|
52
|
-
return cmds
|
|
53
|
-
|
|
54
|
-
def completion(self, state: ReplState):
|
|
55
|
-
return super().completion(state)
|
|
56
|
-
|
|
57
|
-
def help(self, _: ReplState):
|
|
58
|
-
return f"{ShowKubectlCommands.COMMAND}\t show kubectl commands"
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
from walker.commands.processes import Processes
|
|
2
|
-
from walker.commands.command import Command
|
|
3
|
-
from walker.repl_state import ReplState
|
|
4
|
-
|
|
5
|
-
class ShowProcesses(Command):
|
|
6
|
-
COMMAND = 'show processes'
|
|
7
|
-
|
|
8
|
-
# the singleton pattern
|
|
9
|
-
def __new__(cls, *args, **kwargs):
|
|
10
|
-
if not hasattr(cls, 'instance'): cls.instance = super(ShowProcesses, cls).__new__(cls)
|
|
11
|
-
|
|
12
|
-
return cls.instance
|
|
13
|
-
|
|
14
|
-
def __init__(self, successor: Command=None):
|
|
15
|
-
super().__init__(successor)
|
|
16
|
-
|
|
17
|
-
def command(self):
|
|
18
|
-
return ShowProcesses.COMMAND
|
|
19
|
-
|
|
20
|
-
def run(self, cmd: str, state: ReplState):
|
|
21
|
-
if not self.args(cmd):
|
|
22
|
-
return super().run(cmd, state)
|
|
23
|
-
|
|
24
|
-
Processes().run(Processes.COMMAND, state)
|
|
25
|
-
|
|
26
|
-
return state
|
|
27
|
-
|
|
28
|
-
def completion(self, state: ReplState):
|
|
29
|
-
if state.sts:
|
|
30
|
-
return super().completion(state)
|
|
31
|
-
|
|
32
|
-
return {}
|
|
33
|
-
|
|
34
|
-
def help(self, _: ReplState):
|
|
35
|
-
return f'{ShowProcesses.COMMAND} [-s]\t show process overview -s show commands on nodes'
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
from walker.commands.command import Command
|
|
2
|
-
from walker.k8s_utils.cassandra_clusters import CassandraClusters
|
|
3
|
-
from walker.k8s_utils.cassandra_nodes import CassandraNodes
|
|
4
|
-
from walker.repl_state import ReplState, RequiredState
|
|
5
|
-
|
|
6
|
-
class ShowRepairs(Command):
|
|
7
|
-
COMMAND = 'show cassandra repairs'
|
|
8
|
-
|
|
9
|
-
# the singleton pattern
|
|
10
|
-
def __new__(cls, *args, **kwargs):
|
|
11
|
-
if not hasattr(cls, 'instance'): cls.instance = super(ShowRepairs, 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 ShowRepairs.COMMAND
|
|
20
|
-
|
|
21
|
-
def required(self):
|
|
22
|
-
return RequiredState.CLUSTER_OR_POD
|
|
23
|
-
|
|
24
|
-
def run(self, cmd: str, state: ReplState):
|
|
25
|
-
if not(args := self.args(cmd)):
|
|
26
|
-
return super().run(cmd, state)
|
|
27
|
-
|
|
28
|
-
state, _ = state.apply_args(args)
|
|
29
|
-
if not self.validate_state(state):
|
|
30
|
-
return state
|
|
31
|
-
|
|
32
|
-
user, pw = state.user_pass()
|
|
33
|
-
command = f"nodetool -u {user} -pw {pw} repair_admin list"
|
|
34
|
-
|
|
35
|
-
if state.pod:
|
|
36
|
-
return CassandraNodes.exec(state.pod, state.namespace, command)
|
|
37
|
-
else:
|
|
38
|
-
return CassandraClusters.exec(state.sts, state.namespace, command, action='nodetool')
|
|
39
|
-
|
|
40
|
-
def completion(self, state: ReplState):
|
|
41
|
-
if state.sts:
|
|
42
|
-
return super().completion(state)
|
|
43
|
-
|
|
44
|
-
return {}
|
|
45
|
-
|
|
46
|
-
def help(self, _: ReplState):
|
|
47
|
-
return f'{ShowRepairs.COMMAND}\t show Cassandra repairs'
|
walker/commands/status.py
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
|
|
3
|
-
from walker.checks.check_result import CheckResult
|
|
4
|
-
from walker.checks.check_utils import run_checks
|
|
5
|
-
from walker.checks.compactionstats import CompactionStats
|
|
6
|
-
from walker.checks.gossip import Gossip
|
|
7
|
-
from walker.columns.columns import Columns
|
|
8
|
-
from walker.commands.command import Command
|
|
9
|
-
from walker.commands.issues import Issues
|
|
10
|
-
from walker.config import Config
|
|
11
|
-
from walker.k8s_utils.cassandra_nodes import CassandraNodes
|
|
12
|
-
from walker.k8s_utils.secrets import Secrets
|
|
13
|
-
from walker.k8s_utils.statefulsets import StatefulSets
|
|
14
|
-
from walker.repl_state import ReplState, RequiredState
|
|
15
|
-
from walker.utils import lines_to_tabular, log, log2
|
|
16
|
-
from walker.checks.status import parse_nodetool_status
|
|
17
|
-
|
|
18
|
-
class Status(Command):
|
|
19
|
-
COMMAND = 'status'
|
|
20
|
-
|
|
21
|
-
# the singleton pattern
|
|
22
|
-
def __new__(cls, *args, **kwargs):
|
|
23
|
-
if not hasattr(cls, 'instance'): cls.instance = super(Status, cls).__new__(cls)
|
|
24
|
-
|
|
25
|
-
return cls.instance
|
|
26
|
-
|
|
27
|
-
def __init__(self, successor: Command=None):
|
|
28
|
-
super().__init__(successor)
|
|
29
|
-
|
|
30
|
-
def command(self):
|
|
31
|
-
return Status.COMMAND
|
|
32
|
-
|
|
33
|
-
def required(self):
|
|
34
|
-
return RequiredState.CLUSTER_OR_POD
|
|
35
|
-
|
|
36
|
-
def run(self, cmd: str, state: ReplState):
|
|
37
|
-
if not(args := self.args(cmd)):
|
|
38
|
-
return super().run(cmd, state)
|
|
39
|
-
|
|
40
|
-
state, args = self.apply_state(args, state)
|
|
41
|
-
if not self.validate_state(state):
|
|
42
|
-
return state
|
|
43
|
-
|
|
44
|
-
args, show_output = Command.extract_options(args, ['-s', '--show'])
|
|
45
|
-
|
|
46
|
-
if state.namespace and state.pod:
|
|
47
|
-
# self.show_table(state, [state.pod], state.namespace, show_output=show_output)
|
|
48
|
-
self.show_single_pod(state.sts, state.pod, state.namespace, show_output=show_output)
|
|
49
|
-
elif state.namespace and state.sts:
|
|
50
|
-
self.merge(state.sts, StatefulSets.pod_names(state.sts, state.namespace), state.namespace, Config().get('nodetool.samples', sys.maxsize), show_output=show_output)
|
|
51
|
-
|
|
52
|
-
return state
|
|
53
|
-
|
|
54
|
-
def show_single_pod(self, statefulset: str, pod_name: str, ns: str, show_output = False):
|
|
55
|
-
pod_name = pod_name.split('(')[0]
|
|
56
|
-
user, pw = Secrets.get_user_pass(pod_name, ns)
|
|
57
|
-
try:
|
|
58
|
-
result = CassandraNodes.exec(pod_name, ns, f"nodetool -u {user} -pw {pw} status", show_out=False)
|
|
59
|
-
status = parse_nodetool_status(result.stdout)
|
|
60
|
-
check_results = run_checks(cluster=statefulset, namespace=ns, checks=[CompactionStats(), Gossip()], show_output=show_output)
|
|
61
|
-
self.show_table(status, check_results)
|
|
62
|
-
except Exception as e:
|
|
63
|
-
log2(e)
|
|
64
|
-
|
|
65
|
-
def merge(self, statefulset: str, pod_names: list[str], ns: str, samples: int, show_output=False):
|
|
66
|
-
statuses: list[list[dict]] = []
|
|
67
|
-
for pod_name in pod_names:
|
|
68
|
-
pod_name = pod_name.split('(')[0]
|
|
69
|
-
user, pw = Secrets.get_user_pass(pod_name, ns)
|
|
70
|
-
|
|
71
|
-
try:
|
|
72
|
-
result = CassandraNodes.exec(pod_name, ns, f"nodetool -u {user} -pw {pw} status", show_out=False)
|
|
73
|
-
status = parse_nodetool_status(result.stdout)
|
|
74
|
-
if status:
|
|
75
|
-
statuses.append(status)
|
|
76
|
-
if samples <= len(statuses) and len(pod_names) != len(statuses):
|
|
77
|
-
break
|
|
78
|
-
except Exception as e:
|
|
79
|
-
log2(e)
|
|
80
|
-
|
|
81
|
-
combined_status = self.merge_status(statuses)
|
|
82
|
-
log2(f'Showing merged status from {len(statuses)}/{len(pod_names)} nodes...')
|
|
83
|
-
check_results = run_checks(cluster=statefulset, namespace=ns, checks=[CompactionStats(), Gossip()], show_output=show_output)
|
|
84
|
-
self.show_table(combined_status, check_results)
|
|
85
|
-
|
|
86
|
-
return combined_status
|
|
87
|
-
|
|
88
|
-
def merge_status(self, statuses: list[list[dict]]):
|
|
89
|
-
combined = statuses[0]
|
|
90
|
-
|
|
91
|
-
status_by_host = {}
|
|
92
|
-
for status in statuses[0]:
|
|
93
|
-
status_by_host[status['host_id']] = status
|
|
94
|
-
for status in statuses[1:]:
|
|
95
|
-
for s in status:
|
|
96
|
-
if s['host_id'] in status_by_host:
|
|
97
|
-
c = status_by_host[s['host_id']]
|
|
98
|
-
if c['status'] == 'UN' and s['status'] == 'DN':
|
|
99
|
-
c['status'] = 'DN*'
|
|
100
|
-
else:
|
|
101
|
-
combined.append(s)
|
|
102
|
-
|
|
103
|
-
return combined
|
|
104
|
-
|
|
105
|
-
def show_table(self, status: list[dict[str, any]], check_results: list[CheckResult]):
|
|
106
|
-
cols = Config().get('status.columns', 'status,address,load,tokens,owns,host_id,gossip,compactions')
|
|
107
|
-
header = Config().get('status.header', '--,Address,Load,Tokens,Owns,Host ID,GOSSIP,COMPACTIONS')
|
|
108
|
-
columns = Columns.create_columns(cols)
|
|
109
|
-
|
|
110
|
-
def line(status: dict):
|
|
111
|
-
cells = [c.host_value(check_results, status) for c in columns]
|
|
112
|
-
return ','.join(cells)
|
|
113
|
-
|
|
114
|
-
lines = [line(d) for d in status]
|
|
115
|
-
lines.sort()
|
|
116
|
-
|
|
117
|
-
log(lines_to_tabular(lines, header, separator=','))
|
|
118
|
-
|
|
119
|
-
Issues.show(check_results)
|
|
120
|
-
|
|
121
|
-
def completion(self, state: ReplState):
|
|
122
|
-
if not state.pod and state.sts:
|
|
123
|
-
return {Status.COMMAND: None}
|
|
124
|
-
|
|
125
|
-
return {}
|
|
126
|
-
|
|
127
|
-
def help(self, _: ReplState):
|
|
128
|
-
return f'{Status.COMMAND} [-s]\t show merged nodetool status -s show commands on nodes'
|
walker/commands/storage.py
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
from walker.commands.command import Command
|
|
2
|
-
from walker.commands.commands_utils import show_table
|
|
3
|
-
from walker.config import Config
|
|
4
|
-
from walker.k8s_utils.statefulsets import StatefulSets
|
|
5
|
-
from walker.repl_state import ReplState, RequiredState
|
|
6
|
-
|
|
7
|
-
class Storage(Command):
|
|
8
|
-
COMMAND = 'storage'
|
|
9
|
-
|
|
10
|
-
# the singleton pattern
|
|
11
|
-
def __new__(cls, *args, **kwargs):
|
|
12
|
-
if not hasattr(cls, 'instance'): cls.instance = super(Storage, 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 Storage.COMMAND
|
|
21
|
-
|
|
22
|
-
def required(self):
|
|
23
|
-
return RequiredState.CLUSTER_OR_POD
|
|
24
|
-
|
|
25
|
-
def run(self, cmd: str, state: ReplState):
|
|
26
|
-
if not(args := self.args(cmd)):
|
|
27
|
-
return super().run(cmd, state)
|
|
28
|
-
|
|
29
|
-
state, args = self.apply_state(args, state)
|
|
30
|
-
if not self.validate_state(state):
|
|
31
|
-
return state
|
|
32
|
-
|
|
33
|
-
args, show_output = Command.extract_options(args, ['-s', '--show'])
|
|
34
|
-
|
|
35
|
-
cols = Config().get('storage.columns', 'pod,volume_root,volume_cassandra,snapshots,data,compactions')
|
|
36
|
-
header = Config().get('storage.header', 'POD_NAME,VOLUME /,VOLUME CASS,SNAPSHOTS,DATA,COMPACTIONS')
|
|
37
|
-
if state.pod:
|
|
38
|
-
show_table(state, [state.pod], cols, header, show_output=show_output)
|
|
39
|
-
elif state.sts:
|
|
40
|
-
pod_names = [pod.metadata.name for pod in StatefulSets.pods(state.sts, state.namespace)]
|
|
41
|
-
show_table(state, pod_names, cols, header, show_output=show_output)
|
|
42
|
-
|
|
43
|
-
return state
|
|
44
|
-
|
|
45
|
-
def completion(self, state: ReplState):
|
|
46
|
-
if not state.sts:
|
|
47
|
-
return {}
|
|
48
|
-
|
|
49
|
-
return {Storage.COMMAND: None}
|
|
50
|
-
|
|
51
|
-
def help(self, _: ReplState):
|
|
52
|
-
return f'{Storage.COMMAND} [-s]\t show storage overview -s show commands on nodes'
|