kaqing 2.0.98__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 +0 -2
- adam/app_session.py +9 -7
- adam/batch.py +4 -18
- adam/checks/check_utils.py +14 -46
- adam/checks/cpu.py +7 -1
- adam/checks/cpu_metrics.py +52 -0
- adam/columns/columns.py +3 -1
- adam/columns/cpu.py +3 -1
- adam/columns/cpu_metrics.py +22 -0
- adam/commands/__init__.py +15 -0
- adam/commands/alter_tables.py +50 -61
- adam/commands/app_cmd.py +38 -0
- adam/commands/app_ping.py +8 -14
- adam/commands/audit/audit.py +43 -30
- adam/commands/audit/audit_repair_tables.py +26 -46
- 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 +15 -91
- adam/commands/check.py +23 -18
- adam/commands/cli_commands.py +2 -3
- adam/commands/code.py +57 -0
- adam/commands/command.py +96 -40
- adam/commands/commands_utils.py +9 -19
- adam/commands/cp.py +33 -39
- adam/commands/cql/cql_completions.py +30 -8
- adam/commands/cql/cqlsh.py +12 -27
- adam/commands/cql/utils_cql.py +343 -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 +67 -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/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
- 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 +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
- adam/commands/help.py +10 -6
- adam/commands/intermediate_command.py +49 -0
- adam/commands/issues.py +14 -40
- adam/commands/kubectl.py +38 -0
- adam/commands/login.py +28 -24
- adam/commands/logs.py +4 -6
- adam/commands/ls.py +11 -116
- adam/commands/medusa/medusa.py +4 -22
- adam/commands/medusa/medusa_backup.py +20 -24
- adam/commands/medusa/medusa_restore.py +30 -32
- adam/commands/medusa/medusa_show_backupjobs.py +16 -17
- adam/commands/medusa/medusa_show_restorejobs.py +12 -17
- adam/commands/nodetool.py +11 -17
- adam/commands/param_get.py +11 -12
- adam/commands/param_set.py +9 -10
- adam/commands/postgres/postgres.py +43 -36
- adam/commands/postgres/{postgres_session.py → postgres_context.py} +80 -46
- adam/commands/postgres/postgres_ls.py +4 -8
- adam/commands/postgres/postgres_preview.py +5 -9
- adam/commands/postgres/psql_completions.py +2 -2
- adam/commands/postgres/utils_postgres.py +66 -0
- adam/commands/preview_table.py +8 -61
- adam/commands/pwd.py +14 -44
- adam/commands/reaper/reaper.py +4 -24
- adam/commands/reaper/reaper_forward.py +48 -55
- 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 +11 -30
- adam/commands/reaper/reaper_runs.py +42 -57
- adam/commands/reaper/reaper_runs_abort.py +29 -49
- adam/commands/reaper/reaper_schedule_activate.py +11 -30
- adam/commands/reaper/reaper_schedule_start.py +10 -29
- adam/commands/reaper/reaper_schedule_stop.py +10 -29
- adam/commands/reaper/reaper_schedules.py +4 -14
- adam/commands/reaper/reaper_status.py +8 -16
- adam/commands/reaper/utils_reaper.py +196 -0
- adam/commands/repair/repair.py +4 -22
- adam/commands/repair/repair_log.py +4 -7
- adam/commands/repair/repair_run.py +27 -29
- adam/commands/repair/repair_scan.py +31 -34
- adam/commands/repair/repair_stop.py +4 -7
- adam/commands/report.py +25 -21
- adam/commands/restart.py +25 -26
- adam/commands/rollout.py +19 -24
- adam/commands/shell.py +5 -4
- adam/commands/show/show.py +6 -19
- adam/commands/show/show_app_actions.py +26 -22
- adam/commands/show/show_app_id.py +8 -11
- adam/commands/show/show_app_queues.py +7 -10
- adam/commands/show/{show_repairs.py → show_cassandra_repairs.py} +8 -17
- adam/commands/show/show_cassandra_status.py +29 -33
- adam/commands/show/show_cassandra_version.py +4 -14
- adam/commands/show/show_commands.py +19 -21
- adam/commands/show/show_host.py +1 -1
- adam/commands/show/show_login.py +26 -24
- adam/commands/show/show_processes.py +16 -18
- adam/commands/show/show_storage.py +10 -20
- adam/commands/watch.py +26 -29
- adam/config.py +5 -14
- adam/embedded_params.py +1 -1
- adam/pod_exec_result.py +7 -1
- adam/repl.py +95 -131
- adam/repl_commands.py +48 -20
- adam/repl_state.py +270 -61
- adam/sql/sql_completer.py +105 -63
- adam/sql/sql_state_machine.py +618 -0
- adam/sql/term_completer.py +3 -0
- adam/sso/authn_ad.py +6 -5
- adam/sso/authn_okta.py +3 -3
- adam/sso/cred_cache.py +3 -2
- adam/sso/idp.py +3 -3
- adam/utils.py +439 -3
- adam/utils_app.py +98 -0
- adam/utils_athena.py +140 -87
- adam/utils_audits.py +106 -0
- adam/utils_issues.py +32 -0
- adam/utils_k8s/app_clusters.py +28 -0
- adam/utils_k8s/app_pods.py +33 -0
- adam/utils_k8s/cassandra_clusters.py +22 -20
- adam/utils_k8s/cassandra_nodes.py +4 -4
- adam/utils_k8s/custom_resources.py +5 -0
- adam/utils_k8s/ingresses.py +2 -2
- adam/utils_k8s/k8s.py +87 -0
- adam/utils_k8s/pods.py +77 -68
- 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 +1 -12
- adam/utils_net.py +4 -4
- 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 +1 -1
- {kaqing-2.0.98.dist-info → kaqing-2.0.171.dist-info}/METADATA +1 -1
- kaqing-2.0.171.dist-info/RECORD +236 -0
- adam/commands/app.py +0 -67
- adam/commands/bash.py +0 -92
- 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/postgres/postgres_utils.py +0 -31
- adam/commands/postgres/psql_table_completer.py +0 -11
- adam/commands/reaper/reaper_session.py +0 -159
- adam/sql/state_machine.py +0 -460
- kaqing-2.0.98.dist-info/RECORD +0 -191
- /adam/commands/{describe → devices}/__init__.py +0 -0
- {kaqing-2.0.98.dist-info → kaqing-2.0.171.dist-info}/WHEEL +0 -0
- {kaqing-2.0.98.dist-info → kaqing-2.0.171.dist-info}/entry_points.txt +0 -0
- {kaqing-2.0.98.dist-info → kaqing-2.0.171.dist-info}/top_level.txt +0 -0
adam/commands/restart.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from adam.commands import extract_options
|
|
1
2
|
from adam.commands.command import Command
|
|
2
3
|
from adam.utils_k8s.pods import Pods
|
|
3
4
|
from adam.utils_k8s.statefulsets import StatefulSets
|
|
@@ -26,34 +27,32 @@ class Restart(Command):
|
|
|
26
27
|
if not(args := self.args(cmd)):
|
|
27
28
|
return super().run(cmd, state)
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Pods.delete(arg, state.namespace)
|
|
49
|
-
|
|
50
|
-
return state
|
|
30
|
+
with self.validate(args, state) as (args, state):
|
|
31
|
+
with extract_options(args, '--force') as (args, forced):
|
|
32
|
+
if not args:
|
|
33
|
+
if state.pod:
|
|
34
|
+
log2(f'Restarting {state.pod}...')
|
|
35
|
+
Pods.delete(state.pod, state.namespace)
|
|
36
|
+
else:
|
|
37
|
+
if not forced:
|
|
38
|
+
log2('Please add --force for restarting all nodes in a cluster.')
|
|
39
|
+
return 'force-needed'
|
|
40
|
+
|
|
41
|
+
log2(f'Restarting all pods from {state.sts}...')
|
|
42
|
+
for pod_name in StatefulSets.pod_names(state.sts, state.namespace):
|
|
43
|
+
Pods.delete(pod_name, state.namespace)
|
|
44
|
+
else:
|
|
45
|
+
for arg in args:
|
|
46
|
+
Pods.delete(arg, state.namespace)
|
|
47
|
+
|
|
48
|
+
return state
|
|
51
49
|
|
|
52
50
|
def completion(self, state: ReplState):
|
|
53
|
-
if state
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
if super().completion(state):
|
|
52
|
+
if state.pod:
|
|
53
|
+
return {Restart.COMMAND: None}
|
|
54
|
+
elif state.sts:
|
|
55
|
+
return {Restart.COMMAND: {p: None for p in StatefulSets.pod_names(state.sts, state.namespace)}}
|
|
57
56
|
|
|
58
57
|
return {}
|
|
59
58
|
|
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
|
@@ -18,13 +18,14 @@ class Shell(Command):
|
|
|
18
18
|
def command(self):
|
|
19
19
|
return Shell.COMMAND
|
|
20
20
|
|
|
21
|
-
def run(self, cmd: str,
|
|
21
|
+
def run(self, cmd: str, state: ReplState):
|
|
22
22
|
if not(args := self.args(cmd)):
|
|
23
|
-
return super().run(cmd,
|
|
23
|
+
return super().run(cmd, state)
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
with self.validate(args, state):
|
|
26
|
+
os.system('QING_DROPPED=true bash')
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
return state
|
|
28
29
|
|
|
29
30
|
def completion(self, state: ReplState):
|
|
30
31
|
return super().completion(state)
|
adam/commands/show/show.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
|
-
from adam.commands.
|
|
3
|
+
from adam.commands.intermediate_command import IntermediateCommand
|
|
4
4
|
from adam.commands.medusa.medusa_show_backupjobs import MedusaShowBackupJobs
|
|
5
5
|
from adam.commands.medusa.medusa_show_restorejobs import MedusaShowRestoreJobs
|
|
6
6
|
from adam.commands.show.show_app_actions import ShowAppActions
|
|
@@ -13,12 +13,11 @@ from .show_cassandra_status import ShowCassandraStatus
|
|
|
13
13
|
from .show_cassandra_version import ShowCassandraVersion
|
|
14
14
|
from .show_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)
|
|
@@ -20,31 +20,35 @@ class ShowAppActions(Command):
|
|
|
20
20
|
def command(self):
|
|
21
21
|
return ShowAppActions.COMMAND
|
|
22
22
|
|
|
23
|
+
def required(self):
|
|
24
|
+
return ReplState.A
|
|
25
|
+
|
|
23
26
|
def run(self, cmd: str, state: ReplState):
|
|
24
|
-
if not self.args(cmd):
|
|
27
|
+
if not (args := self.args(cmd)):
|
|
25
28
|
return super().run(cmd, state)
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
for
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
30
|
+
with self.validate(args, state) as (args, state):
|
|
31
|
+
lines = []
|
|
32
|
+
for typ in Apps().app_types():
|
|
33
|
+
for action in typ.actions:
|
|
34
|
+
a: AppAction = action
|
|
35
|
+
args = ','.join(a.arguments())
|
|
36
|
+
if args:
|
|
37
|
+
line = f'{typ.name}.{a.name},{args}'
|
|
38
|
+
else:
|
|
39
|
+
line = f'{typ.name}.{a.name},'
|
|
40
|
+
if a.help:
|
|
41
|
+
line = f'{line},{a.help}'
|
|
42
|
+
lines.append(line)
|
|
43
|
+
log(lines_to_tabular(lines, 'ACTION,ARGS,DESCRIPTION', separator=','))
|
|
44
|
+
log()
|
|
45
|
+
|
|
46
|
+
app_session: AppSession = AppSession.create(state.app_env or 'c3', state.app_app or 'c3')
|
|
47
|
+
endpoint = Config().get('app.console-endpoint', 'https://{host}/{env}/{app}/static/console/index.html')
|
|
48
|
+
endpoint = endpoint.replace('{host}', app_session.host).replace('{env}', app_session.env).replace('{app}', state.app_app or 'c3')
|
|
49
|
+
log(lines_to_tabular([f'CONSOLE:,{endpoint}'], separator=','))
|
|
50
|
+
|
|
51
|
+
return lines
|
|
48
52
|
|
|
49
53
|
def completion(self, state: ReplState):
|
|
50
54
|
return super().completion(state)
|
|
@@ -25,20 +25,17 @@ class ShowAppId(Command):
|
|
|
25
25
|
if not(args := self.args(cmd)):
|
|
26
26
|
return super().run(cmd, state)
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return state
|
|
28
|
+
with self.validate(args, state) as (args, state):
|
|
29
|
+
c3_app_id = 'Unknown'
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
apps = CustomResources.get_app_ids()
|
|
32
|
+
cr_name = CustomResources.get_cr_name(state.sts if state.sts else state.pod, namespace=state.namespace)
|
|
33
|
+
if cr_name in apps:
|
|
34
|
+
c3_app_id = (apps[cr_name])
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
cr_name = CustomResources.get_cr_name(state.sts if state.sts else state.pod, namespace=state.namespace)
|
|
36
|
-
if cr_name in apps:
|
|
37
|
-
c3_app_id = (apps[cr_name])
|
|
36
|
+
log(c3_app_id)
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return c3_app_id
|
|
38
|
+
return c3_app_id
|
|
42
39
|
|
|
43
40
|
def completion(self, state: ReplState):
|
|
44
41
|
return super().completion(state)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
from adam.commands import app, extract_options
|
|
1
2
|
from adam.commands.command import Command
|
|
2
3
|
from adam.repl_state import ReplState, RequiredState
|
|
3
|
-
from adam.app_session import AppSession
|
|
4
4
|
|
|
5
5
|
class ShowAppQueues(Command):
|
|
6
6
|
COMMAND = 'show app queues'
|
|
@@ -18,21 +18,18 @@ class ShowAppQueues(Command):
|
|
|
18
18
|
return ShowAppQueues.COMMAND
|
|
19
19
|
|
|
20
20
|
def required(self):
|
|
21
|
-
return RequiredState.
|
|
21
|
+
return RequiredState.APP_APP
|
|
22
22
|
|
|
23
23
|
def run(self, cmd: str, state: ReplState):
|
|
24
24
|
if not(args := self.args(cmd)):
|
|
25
25
|
return super().run(cmd, state)
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
with self.validate(args, state) as (_, state):
|
|
28
|
+
with extract_options(args, '--force') as (args, forced):
|
|
29
|
+
with app(state) as http:
|
|
30
|
+
http.post(['InvalidationQueue.countAll'], forced=forced)
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
AppSession.run(state.app_env, state.app_app, state.namespace, 'InvalidationQueue', 'countAll', forced= forced)
|
|
34
|
-
|
|
35
|
-
return state
|
|
32
|
+
return state
|
|
36
33
|
|
|
37
34
|
def completion(self, state: ReplState):
|
|
38
35
|
if state.app_app:
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
from adam.commands.command import Command
|
|
2
|
-
from adam.
|
|
3
|
-
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
2
|
+
from adam.commands.cql.utils_cql import cassandra
|
|
4
3
|
from adam.repl_state import ReplState, RequiredState
|
|
5
4
|
|
|
6
|
-
class
|
|
5
|
+
class ShowCassandraRepairs(Command):
|
|
7
6
|
COMMAND = 'show cassandra repairs'
|
|
8
7
|
|
|
9
8
|
# the singleton pattern
|
|
10
9
|
def __new__(cls, *args, **kwargs):
|
|
11
|
-
if not hasattr(cls, 'instance'): cls.instance = super(
|
|
10
|
+
if not hasattr(cls, 'instance'): cls.instance = super(ShowCassandraRepairs, cls).__new__(cls)
|
|
12
11
|
|
|
13
12
|
return cls.instance
|
|
14
13
|
|
|
@@ -16,7 +15,7 @@ class ShowRepairs(Command):
|
|
|
16
15
|
super().__init__(successor)
|
|
17
16
|
|
|
18
17
|
def command(self):
|
|
19
|
-
return
|
|
18
|
+
return ShowCassandraRepairs.COMMAND
|
|
20
19
|
|
|
21
20
|
def required(self):
|
|
22
21
|
return RequiredState.CLUSTER_OR_POD
|
|
@@ -25,17 +24,9 @@ class ShowRepairs(Command):
|
|
|
25
24
|
if not(args := self.args(cmd)):
|
|
26
25
|
return super().run(cmd, state)
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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')
|
|
27
|
+
with self.validate(args, state) as (args, state):
|
|
28
|
+
with cassandra(state) as pods:
|
|
29
|
+
return pods.nodetool('repair_admin list')
|
|
39
30
|
|
|
40
31
|
def completion(self, state: ReplState):
|
|
41
32
|
if state.sts:
|
|
@@ -44,4 +35,4 @@ class ShowRepairs(Command):
|
|
|
44
35
|
return {}
|
|
45
36
|
|
|
46
37
|
def help(self, _: ReplState):
|
|
47
|
-
return f'{
|
|
38
|
+
return f'{ShowCassandraRepairs.COMMAND}\t show Cassandra repairs'
|
|
@@ -5,11 +5,11 @@ from adam.checks.check_utils import run_checks
|
|
|
5
5
|
from adam.checks.compactionstats import CompactionStats
|
|
6
6
|
from adam.checks.gossip import Gossip
|
|
7
7
|
from adam.columns.columns import Columns
|
|
8
|
+
from adam.commands import extract_options
|
|
8
9
|
from adam.commands.command import Command
|
|
9
|
-
from adam.commands.
|
|
10
|
+
from adam.commands.cql.utils_cql import cassandra
|
|
10
11
|
from adam.config import Config
|
|
11
|
-
from adam.
|
|
12
|
-
from adam.utils_k8s.secrets import Secrets
|
|
12
|
+
from adam.utils_issues import IssuesUtils
|
|
13
13
|
from adam.utils_k8s.statefulsets import StatefulSets
|
|
14
14
|
from adam.repl_state import ReplState, RequiredState
|
|
15
15
|
from adam.utils import lines_to_tabular, log, log2
|
|
@@ -37,50 +37,46 @@ class ShowCassandraStatus(Command):
|
|
|
37
37
|
if not(args := self.args(cmd)):
|
|
38
38
|
return super().run(cmd, state)
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
with self.validate(args, state) as (args, state):
|
|
41
|
+
with extract_options(args, ['-s', '--show']) as (args, show_out):
|
|
42
|
+
if state.namespace and state.pod:
|
|
43
|
+
self.show_single_pod(state, show_out=show_out)
|
|
44
|
+
elif state.namespace and state.sts:
|
|
45
|
+
self.merge(state, Config().get('nodetool.samples', sys.maxsize), show_output=show_out)
|
|
43
46
|
|
|
44
|
-
|
|
47
|
+
return state
|
|
45
48
|
|
|
46
|
-
|
|
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)
|
|
49
|
+
def show_single_pod(self, state: ReplState, show_out = False):
|
|
57
50
|
try:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
with cassandra(state) as pods:
|
|
52
|
+
result = pods.nodetool('status', show_out=False)
|
|
53
|
+
status = parse_nodetool_status(result.stdout)
|
|
54
|
+
check_results = run_checks(cluster=state.sts, namespace=state.namespace, checks=[CompactionStats(), Gossip()], show_out=show_out)
|
|
55
|
+
self.show_table(status, check_results)
|
|
62
56
|
except Exception as e:
|
|
63
57
|
log2(e)
|
|
64
58
|
|
|
65
|
-
def merge(self,
|
|
59
|
+
def merge(self, state: ReplState, samples: int, show_output=False):
|
|
66
60
|
statuses: list[list[dict]] = []
|
|
61
|
+
|
|
62
|
+
pod_names = StatefulSets.pod_names(state.sts, state.namespace)
|
|
67
63
|
for pod_name in pod_names:
|
|
68
64
|
pod_name = pod_name.split('(')[0]
|
|
69
|
-
user, pw = Secrets.get_user_pass(pod_name, ns)
|
|
70
65
|
|
|
71
66
|
try:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
with cassandra(state, pod=pod_name) as pods:
|
|
68
|
+
result = pods.nodetool('status', show_out=False)
|
|
69
|
+
status = parse_nodetool_status(result.stdout)
|
|
70
|
+
if status:
|
|
71
|
+
statuses.append(status)
|
|
72
|
+
if samples <= len(statuses) and len(pod_names) != len(statuses):
|
|
73
|
+
break
|
|
78
74
|
except Exception as e:
|
|
79
75
|
log2(e)
|
|
80
76
|
|
|
81
77
|
combined_status = self.merge_status(statuses)
|
|
82
78
|
log2(f'Showing merged status from {len(statuses)}/{len(pod_names)} nodes...')
|
|
83
|
-
check_results = run_checks(cluster=
|
|
79
|
+
check_results = run_checks(cluster=state.sts, namespace=state.namespace, checks=[CompactionStats(), Gossip()], show_out=show_output)
|
|
84
80
|
self.show_table(combined_status, check_results)
|
|
85
81
|
|
|
86
82
|
return combined_status
|
|
@@ -116,11 +112,11 @@ class ShowCassandraStatus(Command):
|
|
|
116
112
|
|
|
117
113
|
log(lines_to_tabular(lines, header, separator=','))
|
|
118
114
|
|
|
119
|
-
|
|
115
|
+
IssuesUtils.show(check_results)
|
|
120
116
|
|
|
121
117
|
def completion(self, state: ReplState):
|
|
122
118
|
if state.sts:
|
|
123
|
-
return super().completion(state)
|
|
119
|
+
return super().completion(state, {'-s': None})
|
|
124
120
|
|
|
125
121
|
return {}
|
|
126
122
|
|
|
@@ -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,17 +24,9 @@ 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
32
|
if state.sts:
|
|
@@ -25,31 +25,29 @@ class ShowKubectlCommands(Command):
|
|
|
25
25
|
if not self.args(cmd):
|
|
26
26
|
return super().run(cmd, state)
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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"]}',
|
|
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-?"]}',
|
|
46
35
|
]
|
|
47
36
|
|
|
48
|
-
|
|
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
|
+
]
|
|
49
45
|
|
|
50
|
-
|
|
46
|
+
cmds += [f'{k},{v0}' for k, v0 in v.items() if k.startswith('pg-')]
|
|
51
47
|
|
|
52
|
-
|
|
48
|
+
log(lines_to_tabular(cmds, separator=','))
|
|
49
|
+
|
|
50
|
+
return cmds
|
|
53
51
|
|
|
54
52
|
def completion(self, state: ReplState):
|
|
55
53
|
if not state.sts:
|
adam/commands/show/show_host.py
CHANGED
adam/commands/show/show_login.py
CHANGED
|
@@ -24,34 +24,36 @@ class ShowLogin(Command):
|
|
|
24
24
|
def command(self):
|
|
25
25
|
return ShowLogin.COMMAND
|
|
26
26
|
|
|
27
|
+
def required(self):
|
|
28
|
+
return ReplState.NON_L
|
|
29
|
+
|
|
27
30
|
def run(self, cmd: str, state: ReplState):
|
|
28
31
|
if not(args := self.args(cmd)):
|
|
29
32
|
return super().run(cmd, state)
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return state
|
|
34
|
+
with self.validate(args, state) as (args, state):
|
|
35
|
+
login: IdpLogin = None
|
|
36
|
+
try:
|
|
37
|
+
if not(host := Apps.app_host('c3', 'c3', state.namespace)):
|
|
38
|
+
log2('Cannot locate ingress for app.')
|
|
39
|
+
return state
|
|
40
|
+
|
|
41
|
+
login = Idp.login(host, use_token_from_env=True)
|
|
42
|
+
if login and login.id_token_obj:
|
|
43
|
+
it = login.id_token_obj
|
|
44
|
+
lines = [
|
|
45
|
+
f'email\t{it.email}',
|
|
46
|
+
f'user\t{it.username}',
|
|
47
|
+
f'IDP expires in\t{duration(time.time(), it.exp)}',
|
|
48
|
+
f'IDP Groups\t{",".join(it.groups)}'
|
|
49
|
+
]
|
|
50
|
+
log(lines_to_tabular(lines, separator='\t'))
|
|
51
|
+
except Exception as e:
|
|
52
|
+
log2(e)
|
|
53
|
+
if Config().is_debug():
|
|
54
|
+
log2(traceback.format_exc())
|
|
55
|
+
|
|
56
|
+
return state
|
|
55
57
|
|
|
56
58
|
def completion(self, state: ReplState):
|
|
57
59
|
return super().completion(state)
|