kaqing 2.0.98__py3-none-any.whl → 2.0.203__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 +0 -2
- adam/app_session.py +9 -12
- adam/apps.py +18 -4
- adam/batch.py +11 -25
- adam/checks/check_utils.py +16 -46
- adam/checks/cpu.py +7 -1
- adam/checks/cpu_metrics.py +52 -0
- adam/checks/disk.py +2 -3
- adam/columns/columns.py +3 -1
- adam/columns/cpu.py +3 -1
- adam/columns/cpu_metrics.py +22 -0
- adam/columns/memory.py +3 -4
- adam/commands/__init__.py +24 -0
- adam/commands/alter_tables.py +37 -63
- adam/commands/app/app.py +38 -0
- adam/commands/{app_ping.py → app/app_ping.py} +8 -14
- adam/commands/app/show_app_actions.py +49 -0
- adam/commands/{show → app}/show_app_id.py +8 -11
- adam/commands/{show → app}/show_app_queues.py +8 -14
- adam/commands/app/utils_app.py +106 -0
- adam/commands/audit/audit.py +31 -35
- adam/commands/audit/audit_repair_tables.py +26 -48
- adam/commands/audit/audit_run.py +50 -0
- adam/commands/audit/completions_l.py +15 -0
- adam/commands/audit/show_last10.py +36 -0
- adam/commands/audit/show_slow10.py +36 -0
- adam/commands/audit/show_top10.py +36 -0
- adam/commands/audit/utils_show_top10.py +71 -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/cassandra/__init__.py +0 -0
- adam/commands/cassandra/download_cassandra_log.py +45 -0
- adam/commands/cassandra/nodetool.py +64 -0
- adam/commands/cassandra/nodetool_commands.py +120 -0
- adam/commands/{restart.py → cassandra/restart_cluster.py} +12 -26
- adam/commands/cassandra/restart_node.py +51 -0
- adam/commands/cassandra/restart_nodes.py +47 -0
- adam/commands/cassandra/rollout.py +88 -0
- adam/commands/cat.py +36 -0
- adam/commands/cd.py +14 -92
- adam/commands/check.py +18 -21
- adam/commands/cli_commands.py +8 -4
- adam/commands/clipboard_copy.py +87 -0
- adam/commands/code.py +57 -0
- adam/commands/command.py +212 -39
- adam/commands/commands_utils.py +20 -28
- adam/commands/cql/alter_tables.py +66 -0
- adam/commands/cql/completions_c.py +29 -0
- adam/commands/cql/cqlsh.py +10 -29
- adam/commands/cql/utils_cql.py +305 -0
- adam/commands/debug/__init__.py +0 -0
- adam/commands/debug/debug.py +22 -0
- adam/commands/debug/debug_completes.py +35 -0
- adam/commands/debug/debug_timings.py +35 -0
- adam/commands/deploy/code_start.py +7 -10
- adam/commands/deploy/code_stop.py +4 -21
- adam/commands/deploy/code_utils.py +3 -3
- adam/commands/deploy/deploy.py +4 -21
- adam/commands/deploy/deploy_frontend.py +14 -17
- adam/commands/deploy/deploy_pg_agent.py +3 -6
- adam/commands/deploy/deploy_pod.py +65 -73
- adam/commands/deploy/deploy_utils.py +14 -24
- adam/commands/deploy/undeploy.py +4 -21
- adam/commands/deploy/undeploy_frontend.py +4 -7
- adam/commands/deploy/undeploy_pg_agent.py +6 -8
- adam/commands/deploy/undeploy_pod.py +11 -12
- adam/commands/devices/__init__.py +0 -0
- adam/commands/devices/device.py +149 -0
- adam/commands/devices/device_app.py +163 -0
- adam/commands/devices/device_auit_log.py +49 -0
- adam/commands/devices/device_cass.py +179 -0
- adam/commands/devices/device_export.py +87 -0
- adam/commands/devices/device_postgres.py +160 -0
- adam/commands/devices/devices.py +25 -0
- adam/commands/download_cassandra_log.py +45 -0
- adam/commands/download_file.py +47 -0
- adam/commands/exit.py +1 -4
- adam/commands/export/__init__.py +0 -0
- adam/commands/export/clean_up_all_export_sessions.py +37 -0
- adam/commands/export/clean_up_export_sessions.py +39 -0
- adam/commands/export/completions_x.py +11 -0
- adam/commands/export/download_export_session.py +40 -0
- adam/commands/export/drop_export_database.py +39 -0
- adam/commands/export/drop_export_databases.py +37 -0
- adam/commands/export/export.py +37 -0
- adam/commands/export/export_databases.py +247 -0
- adam/commands/export/export_select.py +34 -0
- adam/commands/export/export_sessions.py +211 -0
- adam/commands/export/export_use.py +49 -0
- adam/commands/export/export_x_select.py +48 -0
- adam/commands/export/exporter.py +361 -0
- adam/commands/export/import_files.py +44 -0
- adam/commands/export/import_session.py +44 -0
- adam/commands/export/importer.py +82 -0
- adam/commands/export/importer_athena.py +150 -0
- adam/commands/export/importer_sqlite.py +69 -0
- adam/commands/export/show_column_counts.py +45 -0
- adam/commands/export/show_export_databases.py +39 -0
- adam/commands/export/show_export_session.py +39 -0
- adam/commands/export/show_export_sessions.py +37 -0
- adam/commands/export/utils_export.py +366 -0
- adam/commands/find_files.py +51 -0
- adam/commands/find_processes.py +76 -0
- adam/commands/generate_report.py +52 -0
- adam/commands/head.py +36 -0
- adam/commands/help.py +12 -8
- adam/commands/intermediate_command.py +52 -0
- adam/commands/issues.py +14 -40
- adam/commands/kubectl.py +38 -0
- adam/commands/login.py +26 -25
- adam/commands/ls.py +11 -116
- adam/commands/medusa/medusa.py +4 -22
- adam/commands/medusa/medusa_backup.py +20 -27
- adam/commands/medusa/medusa_restore.py +35 -48
- adam/commands/medusa/medusa_show_backupjobs.py +17 -18
- adam/commands/medusa/medusa_show_restorejobs.py +13 -18
- adam/commands/medusa/utils_medusa.py +15 -0
- adam/commands/nodetool.py +8 -19
- adam/commands/os/__init__.py +0 -0
- adam/commands/os/cat.py +36 -0
- adam/commands/os/download_file.py +47 -0
- adam/commands/os/find_files.py +51 -0
- adam/commands/os/find_processes.py +76 -0
- adam/commands/os/head.py +36 -0
- adam/commands/os/shell.py +41 -0
- adam/commands/param_get.py +11 -14
- adam/commands/param_set.py +8 -12
- adam/commands/postgres/completions_p.py +22 -0
- adam/commands/postgres/postgres.py +47 -55
- adam/commands/postgres/postgres_databases.py +269 -0
- adam/commands/postgres/postgres_ls.py +4 -8
- adam/commands/postgres/postgres_preview.py +5 -9
- adam/commands/postgres/utils_postgres.py +79 -0
- adam/commands/preview_table.py +10 -61
- adam/commands/pwd.py +14 -46
- adam/commands/reaper/reaper.py +4 -24
- adam/commands/reaper/reaper_forward.py +49 -56
- adam/commands/reaper/reaper_forward_session.py +6 -0
- adam/commands/reaper/reaper_forward_stop.py +10 -16
- adam/commands/reaper/reaper_restart.py +7 -14
- adam/commands/reaper/reaper_run_abort.py +8 -33
- adam/commands/reaper/reaper_runs.py +43 -58
- adam/commands/reaper/reaper_runs_abort.py +29 -49
- adam/commands/reaper/reaper_schedule_activate.py +14 -33
- adam/commands/reaper/reaper_schedule_start.py +9 -33
- adam/commands/reaper/reaper_schedule_stop.py +9 -33
- adam/commands/reaper/reaper_schedules.py +4 -14
- adam/commands/reaper/reaper_status.py +8 -16
- adam/commands/reaper/utils_reaper.py +203 -0
- adam/commands/repair/repair.py +4 -22
- adam/commands/repair/repair_log.py +5 -11
- adam/commands/repair/repair_run.py +27 -34
- adam/commands/repair/repair_scan.py +32 -40
- adam/commands/repair/repair_stop.py +5 -12
- adam/commands/restart_cluster.py +47 -0
- adam/commands/restart_node.py +51 -0
- adam/commands/restart_nodes.py +47 -0
- adam/commands/rollout.py +19 -24
- adam/commands/shell.py +12 -4
- adam/commands/show/show.py +10 -23
- adam/commands/show/show_adam.py +3 -3
- adam/commands/show/show_cassandra_repairs.py +37 -0
- adam/commands/show/show_cassandra_status.py +47 -51
- adam/commands/show/show_cassandra_version.py +5 -18
- adam/commands/show/show_cli_commands.py +56 -0
- adam/commands/show/show_host.py +1 -1
- adam/commands/show/show_login.py +23 -27
- adam/commands/show/show_params.py +2 -5
- adam/commands/show/show_processes.py +18 -21
- adam/commands/show/show_storage.py +11 -20
- adam/commands/watch.py +26 -29
- adam/config.py +5 -15
- adam/embedded_params.py +1 -1
- adam/log.py +4 -4
- adam/repl.py +105 -133
- adam/repl_commands.py +68 -28
- adam/repl_session.py +9 -1
- adam/repl_state.py +300 -62
- adam/sql/async_executor.py +44 -0
- adam/sql/lark_completer.py +286 -0
- adam/sql/lark_parser.py +604 -0
- adam/sql/qingl.lark +1076 -0
- adam/sql/sql_completer.py +104 -64
- adam/sql/sql_state_machine.py +630 -0
- adam/sql/term_completer.py +3 -0
- adam/sso/authn_ad.py +6 -8
- adam/sso/authn_okta.py +4 -6
- adam/sso/cred_cache.py +3 -5
- adam/sso/idp.py +9 -12
- adam/utils.py +640 -10
- adam/utils_athena.py +140 -87
- adam/utils_audits.py +102 -0
- adam/utils_issues.py +32 -0
- adam/utils_k8s/app_clusters.py +28 -0
- adam/utils_k8s/app_pods.py +35 -0
- adam/utils_k8s/cassandra_clusters.py +34 -21
- adam/utils_k8s/cassandra_nodes.py +9 -6
- adam/utils_k8s/custom_resources.py +16 -17
- adam/utils_k8s/ingresses.py +2 -2
- adam/utils_k8s/jobs.py +7 -11
- adam/utils_k8s/k8s.py +96 -0
- adam/utils_k8s/kube_context.py +3 -6
- adam/{pod_exec_result.py → utils_k8s/pod_exec_result.py} +11 -5
- adam/utils_k8s/pods.py +146 -75
- adam/utils_k8s/secrets.py +4 -4
- adam/utils_k8s/service_accounts.py +5 -4
- adam/utils_k8s/services.py +2 -2
- adam/utils_k8s/statefulsets.py +6 -14
- adam/utils_local.py +42 -0
- adam/utils_net.py +4 -4
- adam/utils_repl/__init__.py +0 -0
- adam/utils_repl/appendable_completer.py +6 -0
- adam/utils_repl/automata_completer.py +48 -0
- adam/utils_repl/repl_completer.py +89 -0
- adam/utils_repl/state_machine.py +173 -0
- adam/utils_sqlite.py +137 -0
- adam/version.py +1 -1
- {kaqing-2.0.98.dist-info → kaqing-2.0.203.dist-info}/METADATA +1 -1
- kaqing-2.0.203.dist-info/RECORD +277 -0
- kaqing-2.0.203.dist-info/top_level.txt +2 -0
- teddy/__init__.py +0 -0
- teddy/lark_parser.py +436 -0
- teddy/lark_parser2.py +618 -0
- adam/commands/app.py +0 -67
- adam/commands/bash.py +0 -92
- adam/commands/cp.py +0 -95
- adam/commands/cql/cql_completions.py +0 -11
- adam/commands/cql/cql_table_completer.py +0 -8
- adam/commands/cql/cql_utils.py +0 -115
- adam/commands/describe/describe.py +0 -47
- adam/commands/describe/describe_keyspace.py +0 -60
- adam/commands/describe/describe_keyspaces.py +0 -49
- adam/commands/describe/describe_schema.py +0 -49
- adam/commands/describe/describe_table.py +0 -60
- adam/commands/describe/describe_tables.py +0 -49
- adam/commands/devices.py +0 -118
- adam/commands/logs.py +0 -39
- adam/commands/postgres/postgres_session.py +0 -240
- adam/commands/postgres/postgres_utils.py +0 -31
- adam/commands/postgres/psql_completions.py +0 -10
- adam/commands/postgres/psql_table_completer.py +0 -11
- adam/commands/reaper/reaper_session.py +0 -159
- adam/commands/report.py +0 -57
- adam/commands/show/show_app_actions.py +0 -53
- adam/commands/show/show_commands.py +0 -61
- adam/commands/show/show_repairs.py +0 -47
- adam/sql/state_machine.py +0 -460
- kaqing-2.0.98.dist-info/RECORD +0 -191
- kaqing-2.0.98.dist-info/top_level.txt +0 -1
- /adam/commands/{describe → app}/__init__.py +0 -0
- {kaqing-2.0.98.dist-info → kaqing-2.0.203.dist-info}/WHEEL +0 -0
- {kaqing-2.0.98.dist-info → kaqing-2.0.203.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from adam.commands import extract_options
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.utils_k8s.pods import Pods
|
|
4
|
+
from adam.utils_k8s.statefulsets import StatefulSets
|
|
5
|
+
from adam.repl_state import ReplState, RequiredState
|
|
6
|
+
from adam.utils import log2
|
|
7
|
+
|
|
8
|
+
class RestartCluster(Command):
|
|
9
|
+
COMMAND = 'restart cluster'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(RestartCluster, 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 RestartCluster.COMMAND
|
|
22
|
+
|
|
23
|
+
def required(self):
|
|
24
|
+
return RequiredState.CLUSTER
|
|
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
|
+
with extract_options(args, '--force') as (args, forced):
|
|
32
|
+
if not forced:
|
|
33
|
+
log2('Please add --force for restarting all nodes in a cluster.')
|
|
34
|
+
|
|
35
|
+
return 'force-needed'
|
|
36
|
+
|
|
37
|
+
log2(f'Restarting all pods from {state.sts}...')
|
|
38
|
+
for pod_name in StatefulSets.pod_names(state.sts, state.namespace):
|
|
39
|
+
Pods.delete(pod_name, state.namespace)
|
|
40
|
+
|
|
41
|
+
return state
|
|
42
|
+
|
|
43
|
+
def completion(self, state: ReplState):
|
|
44
|
+
return super().completion(state, {'--force': None})
|
|
45
|
+
|
|
46
|
+
def help(self, _: ReplState):
|
|
47
|
+
return f"{RestartCluster.COMMAND} --force\t restart all the nodes in the cluster"
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from adam.commands import extract_options
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.commands.devices.devices import Devices
|
|
4
|
+
from adam.utils_k8s.pods import Pods
|
|
5
|
+
from adam.repl_state import ReplState, RequiredState
|
|
6
|
+
from adam.utils import log2
|
|
7
|
+
|
|
8
|
+
class RestartNode(Command):
|
|
9
|
+
COMMAND = 'restart node'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(RestartNode, 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 RestartNode.COMMAND
|
|
22
|
+
|
|
23
|
+
def required(self):
|
|
24
|
+
return RequiredState.POD
|
|
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 not state.pod:
|
|
32
|
+
log2("'pod' is required")
|
|
33
|
+
|
|
34
|
+
return 'pod-needed'
|
|
35
|
+
|
|
36
|
+
with extract_options(args, '--force') as (args, forced):
|
|
37
|
+
if not forced:
|
|
38
|
+
log2('Please add --force for restarting pod.')
|
|
39
|
+
|
|
40
|
+
return 'force-needed'
|
|
41
|
+
|
|
42
|
+
log2(f'Restarting {state.pod}...')
|
|
43
|
+
Pods.delete(state.pod, state.namespace)
|
|
44
|
+
|
|
45
|
+
return state
|
|
46
|
+
|
|
47
|
+
def completion(self, state: ReplState):
|
|
48
|
+
return super().completion(state, {'--force': None}, pods=Devices.of(state).pods(state, '-'))
|
|
49
|
+
|
|
50
|
+
def help(self, _: ReplState):
|
|
51
|
+
return f"{RestartNode.COMMAND} --force\t restart the node"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from adam.commands import extract_options, validate_args
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.utils_k8s.pods import Pods
|
|
4
|
+
from adam.utils_k8s.statefulsets import StatefulSets
|
|
5
|
+
from adam.repl_state import ReplState, RequiredState
|
|
6
|
+
from adam.utils import log2
|
|
7
|
+
|
|
8
|
+
class RestartNodes(Command):
|
|
9
|
+
COMMAND = 'restart nodes'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(RestartNodes, 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 RestartNodes.COMMAND
|
|
22
|
+
|
|
23
|
+
def required(self):
|
|
24
|
+
return RequiredState.CLUSTER
|
|
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, apply=False) as (args, state):
|
|
31
|
+
with extract_options(args, '--force') as (args, forced):
|
|
32
|
+
with validate_args(args, state, name='pod name'):
|
|
33
|
+
if not forced:
|
|
34
|
+
log2('Please add --force for restarting nodes.')
|
|
35
|
+
|
|
36
|
+
return 'force-needed'
|
|
37
|
+
|
|
38
|
+
for arg in args:
|
|
39
|
+
Pods.delete(arg, state.namespace)
|
|
40
|
+
|
|
41
|
+
return state
|
|
42
|
+
|
|
43
|
+
def completion(self, state: ReplState):
|
|
44
|
+
return super().completion(state, lambda: {p: {'--force': None} for p in StatefulSets.pod_names(state.sts, state.namespace)})
|
|
45
|
+
|
|
46
|
+
def help(self, _: ReplState):
|
|
47
|
+
return f"{RestartNodes.COMMAND} <pod-name>... --force\t restart Cassandra nodes"
|
adam/commands/rollout.py
CHANGED
|
@@ -2,6 +2,7 @@ import datetime
|
|
|
2
2
|
from kubernetes import client
|
|
3
3
|
from kubernetes.client.rest import ApiException
|
|
4
4
|
|
|
5
|
+
from adam.commands import extract_options
|
|
5
6
|
from adam.commands.command import Command
|
|
6
7
|
from adam.commands.watch import Watch
|
|
7
8
|
from adam.utils_k8s.statefulsets import StatefulSets
|
|
@@ -31,32 +32,28 @@ class RollOut(Command):
|
|
|
31
32
|
if not(args := self.args(cmd)):
|
|
32
33
|
return super().run(cmd, state)
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
with self.validate(args, state) as (args, state):
|
|
36
|
+
with extract_options(args, '--force') as (args, forced):
|
|
37
|
+
restarted, rollingout = StatefulSets.restarted_at(state.sts, state.namespace)
|
|
38
|
+
if rollingout and not forced:
|
|
39
|
+
log2(f"* Cluster is being rolled out for {duration(restarted)}. Please wait until it's done or use --force.")
|
|
37
40
|
|
|
38
|
-
|
|
41
|
+
return state
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
if rollingout and not forced:
|
|
42
|
-
log2(f"* Cluster is being rolled out for {duration(restarted)}. Please wait until it's done or use --force.")
|
|
43
|
+
self.rolling_restart(state.sts, state.namespace)
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
auto_watch = False
|
|
46
|
+
if (auto_watch_cmds := Config().get('watch.auto', 'rollout')):
|
|
47
|
+
cmds = [c.strip(' ') for c in auto_watch_cmds.split(',')]
|
|
48
|
+
if self.command() in cmds:
|
|
49
|
+
auto_watch = True
|
|
50
|
+
log2('Rolling out cluster with auto watch...')
|
|
51
|
+
Watch().run('watch', state)
|
|
45
52
|
|
|
46
|
-
|
|
53
|
+
if not auto_watch:
|
|
54
|
+
log2('Rolling out cluster...')
|
|
47
55
|
|
|
48
|
-
|
|
49
|
-
if (auto_watch_cmds := Config().get('watch.auto', 'rollout')):
|
|
50
|
-
cmds = [c.strip(' ') for c in auto_watch_cmds.split(',')]
|
|
51
|
-
if self.command() in cmds:
|
|
52
|
-
auto_watch = True
|
|
53
|
-
log2('Rolling out cluster with auto watch...')
|
|
54
|
-
Watch().run('watch', state)
|
|
55
|
-
|
|
56
|
-
if not auto_watch:
|
|
57
|
-
log2('Rolling out cluster...')
|
|
58
|
-
|
|
59
|
-
return state
|
|
56
|
+
return state
|
|
60
57
|
|
|
61
58
|
def rolling_restart(self, statefulset, namespace):
|
|
62
59
|
# kubectl rollout restart statefulset <statefulset-name>
|
|
@@ -82,9 +79,7 @@ class RollOut(Command):
|
|
|
82
79
|
log2("Exception when calling AppsV1Api->read_namespaced_statefulset_status: %s\n" % e)
|
|
83
80
|
|
|
84
81
|
def completion(self, state: ReplState):
|
|
85
|
-
if state
|
|
86
|
-
return {}
|
|
87
|
-
elif state.sts:
|
|
82
|
+
if super().completion(state):
|
|
88
83
|
return {RollOut.COMMAND: None}
|
|
89
84
|
|
|
90
85
|
return {}
|
adam/commands/shell.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import os
|
|
2
2
|
|
|
3
|
+
from adam.commands import validate_args
|
|
3
4
|
from adam.commands.command import Command
|
|
4
5
|
from adam.repl_state import ReplState
|
|
6
|
+
from adam.utils import log2
|
|
5
7
|
|
|
6
8
|
class Shell(Command):
|
|
7
9
|
COMMAND = ':sh'
|
|
@@ -18,13 +20,19 @@ class Shell(Command):
|
|
|
18
20
|
def command(self):
|
|
19
21
|
return Shell.COMMAND
|
|
20
22
|
|
|
21
|
-
def run(self, cmd: str,
|
|
23
|
+
def run(self, cmd: str, state: ReplState):
|
|
22
24
|
if not(args := self.args(cmd)):
|
|
23
|
-
return super().run(cmd,
|
|
25
|
+
return super().run(cmd, state)
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
with self.validate(args, state) as (args, _):
|
|
28
|
+
with validate_args(args, state, at_least=0) as args_str:
|
|
29
|
+
if args_str:
|
|
30
|
+
os.system(args_str)
|
|
31
|
+
log2()
|
|
32
|
+
else:
|
|
33
|
+
os.system('QING_DROPPED=true bash')
|
|
26
34
|
|
|
27
|
-
|
|
35
|
+
return state
|
|
28
36
|
|
|
29
37
|
def completion(self, state: ReplState):
|
|
30
38
|
return super().completion(state)
|
adam/commands/show/show.py
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
|
-
from adam.commands.
|
|
3
|
+
from adam.commands.app.show_app_actions import ShowAppActions
|
|
4
|
+
from adam.commands.app.show_app_id import ShowAppId
|
|
5
|
+
from adam.commands.app.show_app_queues import ShowAppQueues
|
|
6
|
+
from adam.commands.intermediate_command import IntermediateCommand
|
|
4
7
|
from adam.commands.medusa.medusa_show_backupjobs import MedusaShowBackupJobs
|
|
5
8
|
from adam.commands.medusa.medusa_show_restorejobs import MedusaShowRestoreJobs
|
|
6
|
-
from adam.commands.show.show_app_actions import ShowAppActions
|
|
7
|
-
from adam.commands.show.show_app_queues import ShowAppQueues
|
|
8
9
|
from adam.commands.show.show_host import ShowHost
|
|
9
10
|
from adam.commands.show.show_login import ShowLogin
|
|
10
11
|
from .show_params import ShowParams
|
|
11
|
-
from .show_app_id import ShowAppId
|
|
12
12
|
from .show_cassandra_status import ShowCassandraStatus
|
|
13
13
|
from .show_cassandra_version import ShowCassandraVersion
|
|
14
|
-
from .
|
|
14
|
+
from .show_cli_commands import ShowKubectlCommands
|
|
15
15
|
from .show_processes import ShowProcesses
|
|
16
|
-
from .
|
|
16
|
+
from .show_cassandra_repairs import ShowCassandraRepairs
|
|
17
17
|
from .show_storage import ShowStorage
|
|
18
18
|
from .show_adam import ShowAdam
|
|
19
|
-
from adam.repl_state import ReplState
|
|
20
19
|
|
|
21
|
-
class Show(
|
|
20
|
+
class Show(IntermediateCommand):
|
|
22
21
|
COMMAND = 'show'
|
|
23
22
|
|
|
24
23
|
# the singleton pattern
|
|
@@ -27,26 +26,14 @@ class Show(Command):
|
|
|
27
26
|
|
|
28
27
|
return cls.instance
|
|
29
28
|
|
|
30
|
-
def __init__(self, successor: Command=None):
|
|
31
|
-
super().__init__(successor)
|
|
32
|
-
|
|
33
29
|
def command(self):
|
|
34
30
|
return Show.COMMAND
|
|
35
31
|
|
|
36
|
-
def
|
|
37
|
-
if not(args := self.args(cmd)):
|
|
38
|
-
return super().run(cmd, state)
|
|
39
|
-
|
|
40
|
-
return super().intermediate_run(cmd, state, args, Show.cmd_list())
|
|
41
|
-
|
|
42
|
-
def cmd_list():
|
|
32
|
+
def cmd_list(self):
|
|
43
33
|
return [ShowAppActions(), ShowAppId(), ShowAppQueues(), ShowHost(), ShowLogin(), ShowKubectlCommands(),
|
|
44
|
-
ShowParams(), ShowProcesses(),
|
|
34
|
+
ShowParams(), ShowProcesses(), ShowCassandraRepairs(), ShowStorage(), ShowAdam(),
|
|
45
35
|
ShowCassandraStatus(), ShowCassandraVersion(), MedusaShowRestoreJobs(), MedusaShowBackupJobs()]
|
|
46
36
|
|
|
47
|
-
def completion(self, state: ReplState):
|
|
48
|
-
return super().completion(state)
|
|
49
|
-
|
|
50
37
|
class ShowCommandHelper(click.Command):
|
|
51
38
|
def get_help(self, ctx: click.Context):
|
|
52
|
-
|
|
39
|
+
IntermediateCommand.intermediate_help(super().get_help(ctx), Show.COMMAND, Show().cmd_list(), show_cluster_help=True)
|
adam/commands/show/show_adam.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import sys
|
|
2
2
|
import os
|
|
3
3
|
|
|
4
|
-
from adam.utils import
|
|
4
|
+
from adam.utils import tabulize, log2
|
|
5
5
|
|
|
6
6
|
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
7
7
|
|
|
@@ -34,10 +34,10 @@ class ShowAdam(Command):
|
|
|
34
34
|
|
|
35
35
|
package = os.path.dirname(os.path.abspath(__file__))
|
|
36
36
|
package = package.split('/adam/')[0] + '/adam'
|
|
37
|
-
|
|
37
|
+
tabulize([
|
|
38
38
|
f'version\t{__version__}',
|
|
39
39
|
f'source\t{package}'
|
|
40
|
-
], separator='\t')
|
|
40
|
+
], separator='\t', to=2)
|
|
41
41
|
|
|
42
42
|
return state
|
|
43
43
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from adam.commands import extract_trailing_options
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.commands.cql.utils_cql import cassandra
|
|
4
|
+
from adam.repl_state import ReplState, RequiredState
|
|
5
|
+
|
|
6
|
+
class ShowCassandraRepairs(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(ShowCassandraRepairs, 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 ShowCassandraRepairs.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
|
+
with self.validate(args, state) as (args, state):
|
|
29
|
+
with extract_trailing_options(args, '&') as (args, backgrounded):
|
|
30
|
+
with cassandra(state) as pods:
|
|
31
|
+
return pods.nodetool('repair_admin list', backgrounded=backgrounded)
|
|
32
|
+
|
|
33
|
+
def completion(self, state: ReplState):
|
|
34
|
+
return super().completion(state, {'&': None})
|
|
35
|
+
|
|
36
|
+
def help(self, _: ReplState):
|
|
37
|
+
return f'{ShowCassandraRepairs.COMMAND}\t show Cassandra repairs'
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from datetime import datetime
|
|
1
2
|
import sys
|
|
2
3
|
|
|
3
4
|
from adam.checks.check_result import CheckResult
|
|
@@ -5,14 +6,15 @@ from adam.checks.check_utils import run_checks
|
|
|
5
6
|
from adam.checks.compactionstats import CompactionStats
|
|
6
7
|
from adam.checks.gossip import Gossip
|
|
7
8
|
from adam.columns.columns import Columns
|
|
9
|
+
from adam.commands import extract_options, extract_trailing_options
|
|
8
10
|
from adam.commands.command import Command
|
|
9
|
-
from adam.commands.
|
|
11
|
+
from adam.commands.cql.utils_cql import cassandra
|
|
10
12
|
from adam.config import Config
|
|
11
|
-
from adam.
|
|
12
|
-
from adam.
|
|
13
|
+
from adam.repl_session import ReplSession
|
|
14
|
+
from adam.utils_issues import IssuesUtils
|
|
13
15
|
from adam.utils_k8s.statefulsets import StatefulSets
|
|
14
16
|
from adam.repl_state import ReplState, RequiredState
|
|
15
|
-
from adam.utils import
|
|
17
|
+
from adam.utils import SORT, tabulize, log2, log_exc
|
|
16
18
|
from adam.checks.status import parse_nodetool_status
|
|
17
19
|
|
|
18
20
|
class ShowCassandraStatus(Command):
|
|
@@ -37,51 +39,44 @@ class ShowCassandraStatus(Command):
|
|
|
37
39
|
if not(args := self.args(cmd)):
|
|
38
40
|
return super().run(cmd, state)
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
with self.validate(args, state) as (args, state):
|
|
43
|
+
with extract_trailing_options(args, '&') as (args, backgrounded):
|
|
44
|
+
with extract_options(args, ['-s', '--show']) as (args, show_out):
|
|
45
|
+
if state.namespace and state.pod:
|
|
46
|
+
self.show_single_pod(state, show_out=show_out, backgrounded=backgrounded)
|
|
47
|
+
elif state.namespace and state.sts:
|
|
48
|
+
self.merge(state, Config().get('nodetool.samples', sys.maxsize), show_output=show_out, backgrounded=backgrounded)
|
|
43
49
|
|
|
44
|
-
|
|
50
|
+
return state
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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)
|
|
52
|
+
def show_single_pod(self, state: ReplState, show_out = False, backgrounded = False):
|
|
53
|
+
with log_exc(True):
|
|
54
|
+
with cassandra(state) as pods:
|
|
55
|
+
result = pods.nodetool('status', show_out=False)
|
|
56
|
+
status = parse_nodetool_status(result.stdout)
|
|
57
|
+
check_results = run_checks(cluster=state.sts, namespace=state.namespace, checks=[CompactionStats(), Gossip()], show_out=show_out)
|
|
58
|
+
self.show_table(status, check_results, backgrounded=backgrounded)
|
|
64
59
|
|
|
65
|
-
def merge(self,
|
|
60
|
+
def merge(self, state: ReplState, samples: int, show_output=False, backgrounded = False):
|
|
66
61
|
statuses: list[list[dict]] = []
|
|
62
|
+
|
|
63
|
+
pod_names = StatefulSets.pod_names(state.sts, state.namespace)
|
|
67
64
|
for pod_name in pod_names:
|
|
68
65
|
pod_name = pod_name.split('(')[0]
|
|
69
|
-
user, pw = Secrets.get_user_pass(pod_name, ns)
|
|
70
66
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
log2(e)
|
|
67
|
+
with log_exc(True):
|
|
68
|
+
with cassandra(state, pod=pod_name) as pods:
|
|
69
|
+
result = pods.nodetool('status', show_out=False)
|
|
70
|
+
status = parse_nodetool_status(result.stdout)
|
|
71
|
+
if status:
|
|
72
|
+
statuses.append(status)
|
|
73
|
+
if samples <= len(statuses) and len(pod_names) != len(statuses):
|
|
74
|
+
break
|
|
80
75
|
|
|
81
76
|
combined_status = self.merge_status(statuses)
|
|
82
77
|
log2(f'Showing merged status from {len(statuses)}/{len(pod_names)} nodes...')
|
|
83
|
-
check_results = run_checks(cluster=
|
|
84
|
-
self.show_table(combined_status, check_results)
|
|
78
|
+
check_results = run_checks(cluster=state.sts, namespace=state.namespace, checks=[CompactionStats(), Gossip()], show_out=show_output)
|
|
79
|
+
self.show_table(combined_status, check_results, backgrounded=backgrounded)
|
|
85
80
|
|
|
86
81
|
return combined_status
|
|
87
82
|
|
|
@@ -102,27 +97,28 @@ class ShowCassandraStatus(Command):
|
|
|
102
97
|
|
|
103
98
|
return combined
|
|
104
99
|
|
|
105
|
-
def show_table(self, status: list[dict[str, any]], check_results: list[CheckResult]):
|
|
100
|
+
def show_table(self, status: list[dict[str, any]], check_results: list[CheckResult], backgrounded=False):
|
|
106
101
|
cols = Config().get('status.columns', 'status,address,load,tokens,owns,host_id,gossip,compactions')
|
|
107
102
|
header = Config().get('status.header', '--,Address,Load,Tokens,Owns,Host ID,GOSSIP,COMPACTIONS')
|
|
108
103
|
columns = Columns.create_columns(cols)
|
|
109
104
|
|
|
110
|
-
|
|
111
|
-
cells = [c.host_value(check_results, status) for c in columns]
|
|
112
|
-
return ','.join(cells)
|
|
105
|
+
r = tabulize(status, lambda s: ','.join([c.host_value(check_results, s) for c in columns]), header=header, separator=',', sorted=SORT, to = 0 if backgrounded else 1)
|
|
113
106
|
|
|
114
|
-
|
|
115
|
-
|
|
107
|
+
if backgrounded:
|
|
108
|
+
log_prefix = Config().get('log-prefix', '/tmp/qing')
|
|
109
|
+
log_file = f'{log_prefix}-{datetime.now().strftime("%d%H%M%S")}.log'
|
|
116
110
|
|
|
117
|
-
|
|
111
|
+
with open(log_file, 'w') as f:
|
|
112
|
+
f.write(r)
|
|
118
113
|
|
|
119
|
-
|
|
114
|
+
ReplSession().append_history(f':sh cat {log_file}')
|
|
120
115
|
|
|
121
|
-
|
|
122
|
-
if state.sts:
|
|
123
|
-
return super().completion(state)
|
|
116
|
+
r = log_file
|
|
124
117
|
|
|
125
|
-
|
|
118
|
+
IssuesUtils.show(check_results)
|
|
119
|
+
|
|
120
|
+
def completion(self, state: ReplState):
|
|
121
|
+
return super().completion(state, {'-s': {'&': None}, '&': None})
|
|
126
122
|
|
|
127
123
|
def help(self, _: ReplState):
|
|
128
124
|
return f'{ShowCassandraStatus.COMMAND} [-s]\t show merged nodetool status -s show commands on nodes'
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
from adam.commands.command import Command
|
|
2
|
-
from adam.
|
|
3
|
-
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
4
|
-
from adam.utils_k8s.secrets import Secrets
|
|
2
|
+
from adam.commands.cql.utils_cql import cassandra
|
|
5
3
|
from adam.repl_state import ReplState, RequiredState
|
|
6
4
|
|
|
7
5
|
class ShowCassandraVersion(Command):
|
|
@@ -26,23 +24,12 @@ class ShowCassandraVersion(Command):
|
|
|
26
24
|
if not(args := self.args(cmd)):
|
|
27
25
|
return super().run(cmd, state)
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
user, pw = Secrets.get_user_pass(state.sts if state.sts else state.pod, state.namespace, secret_path='cql.secret')
|
|
34
|
-
command = f'cqlsh -u {user} -p {pw} -e "show version"'
|
|
35
|
-
|
|
36
|
-
if state.pod:
|
|
37
|
-
return CassandraNodes.exec(state.pod, state.namespace, command)
|
|
38
|
-
else:
|
|
39
|
-
return CassandraClusters.exec(state.sts, state.namespace, command, action='cql')
|
|
27
|
+
with self.validate(args, state) as (_, state):
|
|
28
|
+
with cassandra(state) as pods:
|
|
29
|
+
return pods.cql('show version', show_out=True, on_any=True)
|
|
40
30
|
|
|
41
31
|
def completion(self, state: ReplState):
|
|
42
|
-
|
|
43
|
-
return super().completion(state)
|
|
44
|
-
|
|
45
|
-
return {}
|
|
32
|
+
return super().completion(state)
|
|
46
33
|
|
|
47
34
|
def help(self, _: ReplState):
|
|
48
35
|
return f'{ShowCassandraVersion.COMMAND}\t show Cassandra version'
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from adam.commands.command import Command
|
|
2
|
+
from adam.commands.cli_commands import CliCommands
|
|
3
|
+
from adam.repl_state import ReplState, RequiredState
|
|
4
|
+
from adam.utils import tabulize, log
|
|
5
|
+
|
|
6
|
+
class ShowKubectlCommands(Command):
|
|
7
|
+
COMMAND = 'show cli-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 (args := self.args(cmd)):
|
|
26
|
+
return super().run(cmd, state)
|
|
27
|
+
|
|
28
|
+
with self.validate(args, state) as (args, state):
|
|
29
|
+
v = CliCommands.values(state, collapse=True)
|
|
30
|
+
# node-exec-?, nodetool-?, cql-?, reaper-exec, reaper-forward, reaper-ui, reaper-username, reaper-password
|
|
31
|
+
cmds = [
|
|
32
|
+
f'bash,{v["node-exec-?"]}',
|
|
33
|
+
f'nodetool,{v["nodetool-?"]}',
|
|
34
|
+
f'cql,{v["cql-?"]}',
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
if 'reaper-exec' in v:
|
|
38
|
+
cmds += [
|
|
39
|
+
f'reaper,{v["reaper-exec"]}',
|
|
40
|
+
f',{v["reaper-forward"]} * should be run from your laptop',
|
|
41
|
+
f',{v["reaper-ui"]}',
|
|
42
|
+
f',{v["reaper-username"]}',
|
|
43
|
+
f',{v["reaper-password"]}',
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
cmds += [f'{k},{v0}' for k, v0 in v.items() if k.startswith('pg-')]
|
|
47
|
+
|
|
48
|
+
tabulize(cmds, separator=',')
|
|
49
|
+
|
|
50
|
+
return cmds
|
|
51
|
+
|
|
52
|
+
def completion(self, state: ReplState):
|
|
53
|
+
return super().completion(state)
|
|
54
|
+
|
|
55
|
+
def help(self, _: ReplState):
|
|
56
|
+
return f"{ShowKubectlCommands.COMMAND}\t show kubectl commands"
|
adam/commands/show/show_host.py
CHANGED