kaqing 2.0.184__py3-none-any.whl → 2.0.227__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.

Potentially problematic release.


This version of kaqing might be problematic. Click here for more details.

Files changed (205) hide show
  1. adam/app_session.py +1 -1
  2. adam/batch.py +15 -15
  3. adam/checks/compactionstats.py +2 -1
  4. adam/checks/cpu.py +2 -1
  5. adam/checks/disk.py +6 -5
  6. adam/checks/gossip.py +2 -1
  7. adam/checks/memory.py +2 -1
  8. adam/checks/status.py +2 -1
  9. adam/commands/app/app.py +4 -4
  10. adam/commands/app/app_ping.py +2 -2
  11. adam/commands/{login.py → app/login.py} +2 -2
  12. adam/commands/app/show_app_actions.py +3 -3
  13. adam/commands/app/show_app_id.py +2 -2
  14. adam/commands/app/show_app_queues.py +2 -2
  15. adam/commands/{show → app}/show_login.py +3 -3
  16. adam/commands/app/utils_app.py +9 -1
  17. adam/commands/audit/audit.py +8 -24
  18. adam/commands/audit/audit_repair_tables.py +3 -3
  19. adam/commands/audit/audit_run.py +3 -3
  20. adam/commands/audit/completions_l.py +15 -0
  21. adam/commands/audit/show_last10.py +2 -3
  22. adam/commands/audit/show_slow10.py +2 -2
  23. adam/commands/audit/show_top10.py +2 -2
  24. adam/commands/bash/bash.py +3 -3
  25. adam/commands/bash/utils_bash.py +1 -1
  26. adam/commands/cassandra/download_cassandra_log.py +45 -0
  27. adam/commands/cassandra/restart_cluster.py +47 -0
  28. adam/commands/cassandra/restart_node.py +51 -0
  29. adam/commands/cassandra/restart_nodes.py +47 -0
  30. adam/commands/{rollout.py → cassandra/rollout.py} +3 -3
  31. adam/commands/{show → cassandra}/show_cassandra_repairs.py +7 -5
  32. adam/commands/{show → cassandra}/show_cassandra_status.py +24 -17
  33. adam/commands/{show → cassandra}/show_cassandra_version.py +2 -2
  34. adam/commands/cassandra/show_processes.py +50 -0
  35. adam/commands/cassandra/show_storage.py +44 -0
  36. adam/commands/{watch.py → cassandra/watch.py} +2 -2
  37. adam/commands/cli/__init__.py +0 -0
  38. adam/commands/{cli_commands.py → cli/cli_commands.py} +6 -1
  39. adam/commands/{clipboard_copy.py → cli/clipboard_copy.py} +4 -4
  40. adam/commands/{show/show_commands.py → cli/show_cli_commands.py} +5 -5
  41. adam/commands/code.py +2 -2
  42. adam/commands/command.py +54 -14
  43. adam/commands/commands_utils.py +14 -6
  44. adam/commands/config/__init__.py +0 -0
  45. adam/commands/{param_get.py → config/param_get.py} +2 -2
  46. adam/commands/{param_set.py → config/param_set.py} +2 -2
  47. adam/commands/{show → config}/show_params.py +3 -3
  48. adam/commands/{alter_tables.py → cql/alter_tables.py} +3 -3
  49. adam/commands/cql/completions_c.py +29 -0
  50. adam/commands/cql/cqlsh.py +4 -8
  51. adam/commands/cql/utils_cql.py +36 -17
  52. adam/commands/debug/__init__.py +0 -0
  53. adam/commands/debug/debug.py +22 -0
  54. adam/commands/debug/debug_completes.py +35 -0
  55. adam/commands/debug/debug_timings.py +35 -0
  56. adam/commands/debug/show_offloaded_completes.py +45 -0
  57. adam/commands/deploy/code_start.py +2 -2
  58. adam/commands/deploy/code_stop.py +2 -2
  59. adam/commands/deploy/deploy_frontend.py +2 -2
  60. adam/commands/deploy/deploy_pg_agent.py +2 -2
  61. adam/commands/deploy/deploy_pod.py +2 -2
  62. adam/commands/deploy/undeploy_frontend.py +2 -2
  63. adam/commands/deploy/undeploy_pg_agent.py +2 -2
  64. adam/commands/deploy/undeploy_pod.py +2 -2
  65. adam/commands/devices/device.py +37 -11
  66. adam/commands/devices/device_app.py +7 -7
  67. adam/commands/devices/device_auit_log.py +2 -2
  68. adam/commands/devices/device_cass.py +6 -6
  69. adam/commands/devices/device_export.py +7 -4
  70. adam/commands/devices/device_postgres.py +19 -9
  71. adam/commands/devices/devices.py +1 -1
  72. adam/commands/diag/__init__.py +0 -0
  73. adam/commands/{check.py → diag/check.py} +3 -3
  74. adam/commands/diag/generate_report.py +52 -0
  75. adam/commands/{issues.py → diag/issues.py} +3 -2
  76. adam/commands/exit.py +2 -2
  77. adam/commands/export/clean_up_all_export_sessions.py +2 -2
  78. adam/commands/export/clean_up_export_sessions.py +2 -2
  79. adam/commands/export/completions_x.py +11 -0
  80. adam/commands/export/download_export_session.py +5 -5
  81. adam/commands/export/drop_export_database.py +2 -2
  82. adam/commands/export/drop_export_databases.py +2 -2
  83. adam/commands/export/export.py +3 -19
  84. adam/commands/export/export_databases.py +20 -11
  85. adam/commands/export/export_select.py +9 -34
  86. adam/commands/export/export_sessions.py +13 -11
  87. adam/commands/export/export_use.py +6 -6
  88. adam/commands/export/export_x_select.py +48 -0
  89. adam/commands/export/exporter.py +140 -53
  90. adam/commands/export/import_files.py +3 -7
  91. adam/commands/export/import_session.py +2 -6
  92. adam/commands/export/importer.py +12 -13
  93. adam/commands/export/importer_athena.py +15 -35
  94. adam/commands/export/importer_sqlite.py +19 -8
  95. adam/commands/export/show_column_counts.py +11 -12
  96. adam/commands/export/show_export_databases.py +4 -4
  97. adam/commands/export/show_export_session.py +5 -5
  98. adam/commands/export/show_export_sessions.py +4 -4
  99. adam/commands/export/utils_export.py +40 -25
  100. adam/commands/fs/__init__.py +0 -0
  101. adam/commands/{cat.py → fs/cat.py} +4 -4
  102. adam/commands/fs/cat_local.py +42 -0
  103. adam/commands/{cd.py → fs/cd.py} +4 -4
  104. adam/commands/{download_file.py → fs/download_file.py} +7 -7
  105. adam/commands/{find_files.py → fs/find_files.py} +7 -7
  106. adam/commands/{find_processes.py → fs/find_processes.py} +14 -22
  107. adam/commands/{head.py → fs/head.py} +5 -5
  108. adam/commands/fs/head_local.py +46 -0
  109. adam/commands/{ls.py → fs/ls.py} +4 -4
  110. adam/commands/fs/ls_local.py +40 -0
  111. adam/commands/{pwd.py → fs/pwd.py} +2 -2
  112. adam/commands/fs/rm.py +18 -0
  113. adam/commands/fs/rm_downloads.py +39 -0
  114. adam/commands/fs/rm_logs.py +44 -0
  115. adam/commands/fs/rm_logs_local.py +38 -0
  116. adam/commands/{shell.py → fs/shell.py} +2 -2
  117. adam/commands/{show → fs}/show_adam.py +3 -3
  118. adam/commands/{show → fs}/show_host.py +2 -2
  119. adam/commands/fs/show_last_results.py +39 -0
  120. adam/commands/fs/tail.py +36 -0
  121. adam/commands/fs/tail_local.py +46 -0
  122. adam/commands/fs/utils_fs.py +192 -0
  123. adam/commands/help.py +2 -2
  124. adam/commands/intermediate_command.py +3 -0
  125. adam/commands/kubectl.py +2 -2
  126. adam/commands/medusa/medusa_backup.py +2 -2
  127. adam/commands/medusa/medusa_restore.py +4 -18
  128. adam/commands/medusa/medusa_show_backupjobs.py +2 -2
  129. adam/commands/medusa/medusa_show_restorejobs.py +2 -2
  130. adam/commands/medusa/utils_medusa.py +15 -0
  131. adam/commands/nodetool/__init__.py +0 -0
  132. adam/commands/nodetool/nodetool.py +87 -0
  133. adam/commands/nodetool/utils_nodetool.py +44 -0
  134. adam/commands/postgres/completions_p.py +22 -0
  135. adam/commands/postgres/postgres.py +10 -20
  136. adam/commands/postgres/postgres_databases.py +3 -3
  137. adam/commands/postgres/postgres_ls.py +3 -3
  138. adam/commands/postgres/postgres_preview.py +2 -2
  139. adam/commands/postgres/utils_postgres.py +12 -2
  140. adam/commands/preview_table.py +3 -4
  141. adam/commands/reaper/reaper_forward.py +2 -2
  142. adam/commands/reaper/reaper_forward_stop.py +2 -2
  143. adam/commands/reaper/reaper_restart.py +2 -2
  144. adam/commands/reaper/reaper_run_abort.py +2 -2
  145. adam/commands/reaper/reaper_runs.py +14 -12
  146. adam/commands/reaper/reaper_runs_abort.py +2 -2
  147. adam/commands/reaper/reaper_schedule_activate.py +8 -4
  148. adam/commands/reaper/reaper_schedule_start.py +3 -4
  149. adam/commands/reaper/reaper_schedule_stop.py +3 -4
  150. adam/commands/reaper/reaper_schedules.py +2 -2
  151. adam/commands/reaper/reaper_status.py +2 -2
  152. adam/commands/reaper/utils_reaper.py +41 -6
  153. adam/commands/repair/repair_log.py +2 -2
  154. adam/commands/repair/repair_run.py +2 -2
  155. adam/commands/repair/repair_scan.py +2 -4
  156. adam/commands/repair/repair_stop.py +2 -3
  157. adam/commands/{show/show.py → show.py} +12 -11
  158. adam/config.py +4 -5
  159. adam/embedded_params.py +1 -1
  160. adam/repl.py +24 -10
  161. adam/repl_commands.py +68 -45
  162. adam/repl_session.py +16 -1
  163. adam/repl_state.py +16 -1
  164. adam/sql/async_executor.py +62 -0
  165. adam/sql/lark_completer.py +286 -0
  166. adam/sql/lark_parser.py +604 -0
  167. adam/sql/qingl.lark +1075 -0
  168. adam/sso/cred_cache.py +2 -5
  169. adam/utils.py +259 -82
  170. adam/utils_async_job.py +73 -0
  171. adam/utils_k8s/app_clusters.py +11 -4
  172. adam/utils_k8s/app_pods.py +10 -5
  173. adam/utils_k8s/cassandra_clusters.py +19 -7
  174. adam/utils_k8s/cassandra_nodes.py +16 -6
  175. adam/utils_k8s/k8s.py +9 -0
  176. adam/utils_k8s/kube_context.py +1 -4
  177. adam/{pod_exec_result.py → utils_k8s/pod_exec_result.py} +8 -2
  178. adam/utils_k8s/pods.py +189 -29
  179. adam/utils_k8s/statefulsets.py +5 -2
  180. adam/utils_local.py +78 -2
  181. adam/utils_repl/appendable_completer.py +6 -0
  182. adam/utils_repl/repl_completer.py +51 -4
  183. adam/utils_sqlite.py +3 -8
  184. adam/version.py +1 -1
  185. {kaqing-2.0.184.dist-info → kaqing-2.0.227.dist-info}/METADATA +1 -1
  186. kaqing-2.0.227.dist-info/RECORD +280 -0
  187. kaqing-2.0.227.dist-info/top_level.txt +2 -0
  188. teddy/__init__.py +0 -0
  189. teddy/lark_parser.py +436 -0
  190. teddy/lark_parser2.py +618 -0
  191. adam/commands/cql/cql_completions.py +0 -32
  192. adam/commands/export/export_select_x.py +0 -54
  193. adam/commands/logs.py +0 -37
  194. adam/commands/nodetool.py +0 -69
  195. adam/commands/postgres/psql_completions.py +0 -11
  196. adam/commands/report.py +0 -61
  197. adam/commands/restart.py +0 -60
  198. adam/commands/show/show_processes.py +0 -49
  199. adam/commands/show/show_storage.py +0 -42
  200. kaqing-2.0.184.dist-info/RECORD +0 -244
  201. kaqing-2.0.184.dist-info/top_level.txt +0 -1
  202. /adam/commands/{show → cassandra}/__init__.py +0 -0
  203. /adam/commands/{nodetool_commands.py → nodetool/nodetool_commands.py} +0 -0
  204. {kaqing-2.0.184.dist-info → kaqing-2.0.227.dist-info}/WHEEL +0 -0
  205. {kaqing-2.0.184.dist-info → kaqing-2.0.227.dist-info}/entry_points.txt +0 -0
adam/app_session.py CHANGED
@@ -8,7 +8,7 @@ from adam.log import Log
8
8
  from adam.sso.idp import Idp
9
9
  from adam.sso.idp_login import IdpLogin
10
10
  from adam.config import Config
11
- from adam.utils import debug, debug_trace, json_to_csv, tabulize, log, log2, log_exc
11
+ from adam.utils import debug, debug_trace, json_to_csv, tabulize, log2, log_exc
12
12
  from adam.apps import Apps
13
13
 
14
14
  class AppLogin:
adam/batch.py CHANGED
@@ -2,28 +2,28 @@ import click
2
2
 
3
3
  from adam.commands.audit.audit import Audit, AuditCommandHelper
4
4
  from adam.commands.bash.bash import Bash
5
- from adam.commands.check import Check, CheckCommandHelper
6
- from adam.commands.clipboard_copy import ClipboardCopy, CopyCommandHelper
5
+ from adam.commands.cassandra.restart_nodes import RestartNodes
6
+ from adam.commands.cassandra.rollout import RollOut
7
+ from adam.commands.cassandra.watch import Watch
8
+ from adam.commands.cli.clipboard_copy import ClipboardCopy, CopyCommandHelper
7
9
  from adam.commands.command import Command
8
10
  from adam.commands.command_helpers import ClusterCommandHelper, ClusterOrPodCommandHelper, PodCommandHelper
9
11
  from adam.commands.cql.cqlsh import CqlCommandHelper, Cqlsh
10
12
  from adam.commands.deploy.deploy import Deploy, DeployCommandHelper
11
13
  from adam.commands.deploy.undeploy import Undeploy, UndeployCommandHelper
12
- from adam.commands.issues import Issues
13
- from adam.commands.login import Login
14
- from adam.commands.logs import Logs
15
- from adam.commands.ls import Ls
14
+ from adam.commands.app.login import Login
15
+ from adam.commands.cassandra.download_cassandra_log import DownloadCassandraLog
16
+ from adam.commands.diag.check import Check, CheckCommandHelper
17
+ from adam.commands.diag.generate_report import GenerateReport
18
+ from adam.commands.diag.issues import Issues
19
+ from adam.commands.fs.ls import Ls
16
20
  from adam.commands.medusa.medusa import Medusa
17
- from adam.commands.nodetool import NodeTool, NodeToolCommandHelper
21
+ from adam.commands.nodetool.nodetool import NodeTool, NodeToolCommandHelper
18
22
  from adam.commands.postgres.postgres import Postgres, PostgresCommandHelper
19
23
  from adam.commands.preview_table import PreviewTable
20
24
  from adam.commands.reaper.reaper import Reaper, ReaperCommandHelper
21
25
  from adam.commands.repair.repair import Repair, RepairCommandHelper
22
- from adam.commands.report import Report
23
- from adam.commands.restart import Restart
24
- from adam.commands.rollout import RollOut
25
- from adam.commands.show.show import Show, ShowCommandHelper
26
- from adam.commands.watch import Watch
26
+ from adam.commands.show import Show, ShowCommandHelper
27
27
  from adam.utils_k8s.kube_context import KubeContext
28
28
  from adam.repl import enter_repl
29
29
  from adam.repl_state import ReplState
@@ -128,7 +128,7 @@ def login(kubeconfig: str, config: str, param: list[str], namespace: str, pod: s
128
128
  @click.option('--pod', '-p', required=False, metavar='pod', help='Kubernetes pod name')
129
129
  @click.argument('extra_args', nargs=-1, metavar='<pod>', type=click.UNPROCESSED)
130
130
  def logs(kubeconfig: str, config: str, param: list[str], namespace: str, pod: str, extra_args):
131
- run_command(Logs(), kubeconfig, config, param, None, namespace, pod, extra_args)
131
+ run_command(DownloadCassandraLog(), kubeconfig, config, param, None, namespace, pod, extra_args)
132
132
 
133
133
 
134
134
  @cli.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True), cls=ClusterCommandHelper, help='List statefulset or pods.')
@@ -221,7 +221,7 @@ def repair(kubeconfig: str, config: str, param: list[str], cluster: str, namespa
221
221
  @click.option('--show', '-s', is_flag=True, help='show output from Cassandra nodes')
222
222
  @click.argument('extra_args', nargs=-1, metavar='[cluster|pod]', type=click.UNPROCESSED)
223
223
  def report(kubeconfig: str, config: str, param: list[str], cluster: str, namespace: str, pod: str, show: bool, extra_args):
224
- run_command(Report(), kubeconfig, config, param, cluster, namespace, pod, ('-s',) + extra_args if show else extra_args)
224
+ run_command(GenerateReport(), kubeconfig, config, param, cluster, namespace, pod, ('-s',) + extra_args if show else extra_args)
225
225
 
226
226
 
227
227
  @cli.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True), cls=ClusterOrPodCommandHelper, help='Restart Cassandra Cluster or Node')
@@ -234,7 +234,7 @@ def report(kubeconfig: str, config: str, param: list[str], cluster: str, namespa
234
234
  @click.option('--force', is_flag=True, help='need for restarting the whole cluster')
235
235
  @click.argument('extra_args', nargs=-1, metavar='<cluster|pod>', type=click.UNPROCESSED)
236
236
  def restart(kubeconfig: str, config: str, param: list[str], cluster: str, namespace: str, pod: str, force: bool, extra_args):
237
- run_command(Restart(), kubeconfig, config, param, cluster, namespace, pod, ('--force',) + extra_args if force else extra_args)
237
+ run_command(RestartNodes(), kubeconfig, config, param, cluster, namespace, pod, ('--force',) + extra_args if force else extra_args)
238
238
 
239
239
 
240
240
  @cli.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True), cls=ClusterOrPodCommandHelper, help='Rolling restart Cassandra Cluster.')
@@ -5,6 +5,7 @@ from adam.checks.check_context import CheckContext
5
5
  from adam.checks.check_result import CheckResult
6
6
  from adam.checks.issue import Issue
7
7
  from adam.config import Config
8
+ from adam.utils import Color
8
9
  from adam.utils_k8s.cassandra_nodes import CassandraNodes
9
10
 
10
11
  class CompactionStats(Check):
@@ -15,7 +16,7 @@ class CompactionStats(Check):
15
16
  issues: list[Issue] = []
16
17
 
17
18
  try:
18
- result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"nodetool -u {ctx.user} -pw {ctx.pw} compactionstats", show_out=ctx.show_output)
19
+ result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"nodetool -u {ctx.user} -pw {ctx.pw} compactionstats", show_out=ctx.show_output, text_color=Color.gray)
19
20
  compactions = parse_nodetool_compactionstats(result.stdout)
20
21
  pod_details = {
21
22
  'name': ctx.pod,
adam/checks/cpu.py CHANGED
@@ -5,6 +5,7 @@ from adam.checks.check_context import CheckContext
5
5
  from adam.checks.check_result import CheckResult
6
6
  from adam.checks.issue import Issue
7
7
  from adam.config import Config
8
+ from adam.utils import Color
8
9
  from adam.utils_k8s.cassandra_nodes import CassandraNodes
9
10
  from adam.utils_k8s.custom_resources import CustomResources
10
11
  from adam.utils_k8s.pods import Pods
@@ -31,7 +32,7 @@ class Cpu(Check):
31
32
  details['limit'] = container.resources.limits["cpu"]
32
33
 
33
34
  idle = 'Unknown'
34
- result = CassandraNodes.exec(ctx.pod, ctx.namespace, "mpstat 5 2 | grep Average | awk '{print $NF}'", show_out=ctx.show_output)
35
+ result = CassandraNodes.exec(ctx.pod, ctx.namespace, "mpstat 5 2 | grep Average | awk '{print $NF}'", show_out=ctx.show_output, text_color=Color.gray)
35
36
  lines = result.stdout.strip(' \r\n').split('\n')
36
37
  line = lines[len(lines) - 1].strip(' \r')
37
38
  idle = details['idle'] = line
adam/checks/disk.py CHANGED
@@ -1,12 +1,13 @@
1
1
  import re
2
2
  from pathlib import Path
3
+ import traceback
3
4
 
4
5
  from adam.checks.check import Check
5
6
  from adam.checks.check_context import CheckContext
6
7
  from adam.checks.check_result import CheckResult
7
8
  from adam.checks.issue import Issue
8
9
  from adam.config import Config
9
- from adam.utils import log_exc
10
+ from adam.utils import Color, log_exc
10
11
  from adam.utils_k8s.cassandra_nodes import CassandraNodes
11
12
 
12
13
  class Disk(Check):
@@ -19,16 +20,16 @@ class Disk(Check):
19
20
 
20
21
  try:
21
22
  cass_data_path = Config().get('checks.cassandra-data-path', '/c3/cassandra')
22
- df_result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"df -h | grep -e '{cass_data_path}' -e 'overlay'", show_out=ctx.show_output)
23
+ df_result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"df -h | grep -e '{cass_data_path}' -e 'overlay'", show_out=ctx.show_output, text_color=Color.gray)
23
24
 
24
25
  snapshot_size = Config().get('checks.snapshot-size-cmd', "ls /c3/cassandra/data/data/*/*/snapshots | grep snapshots | sed 's/:$//g' | xargs -I {} du -sk {} | awk '{print $1}' | awk '{s+=$1} END {print s}'")
25
- ss_result = CassandraNodes.exec(ctx.pod, ctx.namespace, snapshot_size, show_out=ctx.show_output)
26
+ ss_result = CassandraNodes.exec(ctx.pod, ctx.namespace, snapshot_size, show_out=ctx.show_output, text_color=Color.gray)
26
27
 
27
28
  data_sizes = Config().get('checks.data-size-cmd', "du -sh /c3/cassandra/data/data")
28
- ds_result = CassandraNodes.exec(ctx.pod, ctx.namespace, data_sizes, show_out=ctx.show_output)
29
+ ds_result = CassandraNodes.exec(ctx.pod, ctx.namespace, data_sizes, show_out=ctx.show_output, text_color=Color.gray)
29
30
 
30
31
  table_sizes = Config().get('checks.table-sizes-cmd', "ls -Al /c3/cassandra/data/data/ | awk '{print $9}' | sed 's/\^r//g' | xargs -I {} du -sk /c3/cassandra/data/data/{}")
31
- ts_result = CassandraNodes.exec(ctx.pod, ctx.namespace, table_sizes, show_out=ctx.show_output)
32
+ ts_result = CassandraNodes.exec(ctx.pod, ctx.namespace, table_sizes, show_out=ctx.show_output, text_color=Color.gray)
32
33
 
33
34
  result = self.build_details(ctx, df_result.stdout, ss_result.stdout, ds_result.stdout, ts_result.stdout)
34
35
 
adam/checks/gossip.py CHANGED
@@ -4,6 +4,7 @@ from adam.checks.check import Check
4
4
  from adam.checks.check_context import CheckContext
5
5
  from adam.checks.check_result import CheckResult
6
6
  from adam.checks.issue import Issue
7
+ from adam.utils import Color
7
8
  from adam.utils_k8s.cassandra_nodes import CassandraNodes
8
9
 
9
10
  class Gossip(Check):
@@ -32,7 +33,7 @@ class Gossip(Check):
32
33
  # TOKENS:21:<hidden>
33
34
  # STATUS line missing -> NORMAL
34
35
  # user, pw = get_user_pass(pod_name, ns)
35
- result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"nodetool -u {ctx.user} -pw {ctx.pw} gossipinfo", show_out=ctx.show_output)
36
+ result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"nodetool -u {ctx.user} -pw {ctx.pw} gossipinfo", show_out=ctx.show_output, text_color=Color.gray)
36
37
 
37
38
  nodes = self.parse_gossipinfo(result.stdout)
38
39
  details = {
adam/checks/memory.py CHANGED
@@ -2,6 +2,7 @@ from adam.checks.check import Check
2
2
  from adam.checks.check_context import CheckContext
3
3
  from adam.checks.check_result import CheckResult
4
4
  from adam.checks.issue import Issue
5
+ from adam.utils import Color
5
6
  from adam.utils_k8s.cassandra_nodes import CassandraNodes
6
7
  from adam.utils_k8s.custom_resources import CustomResources
7
8
  from adam.utils_k8s.pods import Pods
@@ -47,7 +48,7 @@ class Memory(Check):
47
48
 
48
49
  def find_error(self, ctx: CheckContext, pattern: str, issue_desc: str):
49
50
  escaped = pattern.replace('"', '\"')
50
- result = CassandraNodes.exec(ctx.pod, ctx.namespace, f'tac /c3/cassandra/logs/system.log | grep "{escaped}" | head -1', show_out=ctx.show_output)
51
+ result = CassandraNodes.exec(ctx.pod, ctx.namespace, f'tac /c3/cassandra/logs/system.log | grep "{escaped}" | head -1', show_out=ctx.show_output, text_color=Color.gray)
51
52
  if result.stdout.find(pattern) > 0:
52
53
  return Issue(
53
54
  statefulset=ctx.statefulset,
adam/checks/status.py CHANGED
@@ -4,6 +4,7 @@ from adam.checks.check import Check
4
4
  from adam.checks.check_context import CheckContext
5
5
  from adam.checks.check_result import CheckResult
6
6
  from adam.checks.issue import Issue
7
+ from adam.utils import Color
7
8
  from adam.utils_k8s.cassandra_nodes import CassandraNodes
8
9
 
9
10
  class Status(Check):
@@ -14,7 +15,7 @@ class Status(Check):
14
15
  issues: list[Issue] = []
15
16
 
16
17
  try:
17
- result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"nodetool -u {ctx.user} -pw {ctx.pw} status", show_out=ctx.show_output)
18
+ result = CassandraNodes.exec(ctx.pod, ctx.namespace, f"nodetool -u {ctx.user} -pw {ctx.pw} status", show_out=ctx.show_output, text_color=Color.gray)
18
19
  status = parse_nodetool_status(result.stdout)
19
20
  pod_details = {
20
21
  'name': ctx.pod,
adam/commands/app/app.py CHANGED
@@ -31,8 +31,8 @@ class App(Command):
31
31
 
32
32
  return state
33
33
 
34
- def completion(self, state: ReplState):
35
- return super().completion(state, {'--force': None})
34
+ def completion(self, _: ReplState):
35
+ return {}
36
36
 
37
- def help(self, _: ReplState):
38
- return f"<AppType>.<AppAction> <args> [--force]\t post app action; check with 'show app actions' command"
37
+ def help(self, state: ReplState):
38
+ return super().help(state, "post app action use 'show app actions' for registered actions --force refresh session", command='<AppType>.<AppAction>', args='<args> [--force]')
@@ -34,5 +34,5 @@ class AppPing(Command):
34
34
  def completion(self, state: ReplState):
35
35
  return super().completion(state, {'--force': None})
36
36
 
37
- def help(self, _: ReplState):
38
- return f"{AppPing.COMMAND} [--force]\t ping app server with Echo.echoStatic()"
37
+ def help(self, state: ReplState):
38
+ return super().help(state, 'ping app server with Echo.echoStatic() --force refresh session', args='[--force]')
@@ -63,5 +63,5 @@ class Login(Command):
63
63
  def completion(self, state: ReplState):
64
64
  return super().completion(state)
65
65
 
66
- def help(self, _: ReplState):
67
- return f'{Login.COMMAND}\t SSO login'
66
+ def help(self, state: ReplState):
67
+ return super().help(state, 'SSO login')
@@ -1,5 +1,5 @@
1
1
  from adam.app_session import AppSession
2
- from adam.apps import AppAction, Apps
2
+ from adam.apps import Apps
3
3
  from adam.commands.command import Command
4
4
  from adam.config import Config
5
5
  from adam.repl_state import ReplState
@@ -45,5 +45,5 @@ class ShowAppActions(Command):
45
45
  def completion(self, state: ReplState):
46
46
  return super().completion(state)
47
47
 
48
- def help(self, _: ReplState):
49
- return f"{ShowAppActions.COMMAND}\t show app actions"
48
+ def help(self, state: ReplState):
49
+ return super().help(state, 'show registered app actions')
@@ -40,5 +40,5 @@ class ShowAppId(Command):
40
40
  def completion(self, state: ReplState):
41
41
  return super().completion(state)
42
42
 
43
- def help(self, _: ReplState):
44
- return f'{ShowAppId.COMMAND}\t show app id for the Cassandra cluster'
43
+ def help(self, state: ReplState):
44
+ return super().help(state, 'show app id for the Cassandra cluster')
@@ -34,5 +34,5 @@ class ShowAppQueues(Command):
34
34
  def completion(self, state: ReplState):
35
35
  return super().completion(state, {'--force': None})
36
36
 
37
- def help(self, _: ReplState):
38
- return f"{ShowAppQueues.COMMAND} [--force]\t show invalidation queue counts"
37
+ def help(self, state: ReplState):
38
+ return super().help(state, 'show invalidation queue counts --force refresh session', args='[--force]')
@@ -5,7 +5,7 @@ from adam.sso.idp import Idp
5
5
  from adam.sso.idp_login import IdpLogin
6
6
  from adam.commands.command import Command
7
7
  from adam.repl_state import ReplState
8
- from adam.utils import duration, tabulize, log, log2, log_exc
8
+ from adam.utils import duration, tabulize, log2, log_exc
9
9
 
10
10
  class ShowLogin(Command):
11
11
  COMMAND = 'show login'
@@ -52,5 +52,5 @@ class ShowLogin(Command):
52
52
  def completion(self, state: ReplState):
53
53
  return super().completion(state)
54
54
 
55
- def help(self, _: ReplState):
56
- return f'{ShowLogin.COMMAND}\t show login details'
55
+ def help(self, state: ReplState):
56
+ return super().help(state, 'show SSO login details')
@@ -3,12 +3,20 @@ from typing import Union
3
3
 
4
4
  from adam.app_session import AppSession
5
5
  from adam.apps import Apps
6
- from adam.pod_exec_result import PodExecResult
6
+ from adam.utils_k8s.pod_exec_result import PodExecResult
7
7
  from adam.repl_state import ReplState
8
8
  from adam.utils import log2
9
9
  from adam.utils_k8s.app_clusters import AppClusters
10
10
  from adam.utils_k8s.app_pods import AppPods
11
11
 
12
+ def app_cd_dirs(state: ReplState):
13
+ if state.app_app:
14
+ return ['..'] + AppPods.pod_names(state.namespace, state.app_env, state.app_app)
15
+ elif state.app_env:
16
+ return ['..'] + [app[0].split('-')[1] for app in Apps.apps(state.app_env)]
17
+ else:
18
+ return [env[0] for env in Apps.envs()]
19
+
12
20
  class AppRestHandler:
13
21
  def __init__(self, state: ReplState, forced = False):
14
22
  self.state = state
@@ -1,17 +1,16 @@
1
1
  import click
2
2
 
3
3
  from adam.commands import validate_args
4
+ from adam.commands.audit.completions_l import completions_l
4
5
  from adam.commands.audit.audit_repair_tables import AuditRepairTables
5
6
  from adam.commands.audit.audit_run import AuditRun
6
7
  from adam.commands.audit.show_last10 import ShowLast10
7
8
  from adam.commands.audit.show_slow10 import ShowSlow10
8
9
  from adam.commands.audit.show_top10 import ShowTop10
9
- from adam.commands.audit.utils_show_top10 import show_top10_completions_for_nesting
10
10
  from adam.commands.command import Command
11
11
  from adam.commands.intermediate_command import IntermediateCommand
12
12
  from adam.repl_state import ReplState
13
- from adam.sql.sql_completer import SqlCompleter, SqlVariant
14
- from adam.utils import log2, wait_log
13
+ from adam.utils import log2
15
14
  from adam.utils_athena import Athena
16
15
 
17
16
  class Audit(IntermediateCommand):
@@ -50,31 +49,16 @@ class Audit(IntermediateCommand):
50
49
  return state
51
50
 
52
51
  def completion(self, state: ReplState):
53
- if state.device == ReplState.L:
54
- if not self.schema_read:
55
- wait_log(f'Inspecting audit database schema...')
56
- self.schema_read = True
57
- # warm up the caches first time when l: drive is accessed
58
- Athena.table_names()
59
- Athena.column_names()
60
- Athena.column_names(partition_cols_only=True)
61
-
62
- return super().completion(state) | show_top10_completions_for_nesting() | SqlCompleter(
63
- lambda: Athena.table_names(),
64
- expandables={
65
- 'columns': lambda table: Athena.column_names(),
66
- 'partition_columns': lambda table: Athena.column_names(partition_cols_only=True)
67
- },
68
- variant=SqlVariant.ATHENA
69
- ).completions_for_nesting()
70
-
71
- return {}
52
+ if state.device != ReplState.L:
53
+ return {}
54
+
55
+ return completions_l()
72
56
 
73
57
  def cmd_list(self):
74
58
  return [AuditRepairTables(), AuditRun(), ShowLast10(), ShowSlow10(), ShowTop10()]
75
59
 
76
- def help(self, _: ReplState):
77
- return f'[{Audit.COMMAND}] [<sql-statements>]\t run SQL queries on Authena audit database'
60
+ def help(self, state: ReplState):
61
+ return super().help(state, 'run SQL queries on Athena audit database', command='[audit] [<sql-statements>]')
78
62
 
79
63
  class AuditCommandHelper(click.Command):
80
64
  def get_help(self, ctx: click.Context):
@@ -46,7 +46,7 @@ class AuditRepairTables(Command):
46
46
  with Audits.offload() as exec:
47
47
  exec.submit(lambda: self.auto_repair(hours))
48
48
 
49
- return super().completion(state)
49
+ # return super().completion(state)
50
50
 
51
51
  return {}
52
52
 
@@ -68,5 +68,5 @@ class AuditRepairTables(Command):
68
68
  exec.submit(Athena.query, f'MSCK REPAIR TABLE {table}', None,)
69
69
  exec.submit(Audits.put_meta, Audits.PARTITIONS_ADDED, meta,)
70
70
 
71
- def help(self, _: ReplState):
72
- return f"{AuditRepairTables.COMMAND}\t run MSCK REPAIR command for new partition discovery"
71
+ def help(self, state: ReplState):
72
+ return super().help(state, 'run MSCK REPAIR to discover new partitions')
@@ -44,7 +44,7 @@ class AuditRun(Command):
44
44
  return state
45
45
 
46
46
  def completion(self, state: ReplState):
47
- return super().completion(state)
47
+ return {}
48
48
 
49
- def help(self, _: ReplState):
50
- return f"{AuditRun.COMMAND}\t run"
49
+ def help(self, state: ReplState):
50
+ return super().help(state, 'run audit')
@@ -0,0 +1,15 @@
1
+ from adam.repl_state import ReplState
2
+ from adam.sql.lark_completer import LarkCompleter
3
+ from adam.utils_athena import Athena
4
+
5
+ def completions_l():
6
+ return LarkCompleter(
7
+ expandables={
8
+ 'tables': lambda x: Athena.table_names(),
9
+ 'columns': lambda table: Athena.column_names(),
10
+ 'partition-columns': lambda table: Athena.column_names(partition_cols_only=True),
11
+ 'topn-counts': lambda x: ['10'],
12
+ 'topn-types': lambda x: ['last', 'slow', 'top'],
13
+ 'topn-windows': lambda x: ['day', 'month'],
14
+ }, variant=ReplState.L
15
+ ).completions_for_nesting()
@@ -30,8 +30,7 @@ class ShowLast10(Command):
30
30
  return state
31
31
 
32
32
  def completion(self, _: ReplState):
33
-
34
33
  return {}
35
34
 
36
- def help(self, _: ReplState):
37
- return f'{ShowLast10.COMMAND} [limit]\t show last <limit> audit lines'
35
+ def help(self, state: ReplState):
36
+ return super().help(state, 'show last <limit> audit lines <limit> defaults to 10', args='[limit]')
@@ -32,5 +32,5 @@ class ShowSlow10(Command):
32
32
  def completion(self, _: ReplState):
33
33
  return {}
34
34
 
35
- def help(self, _: ReplState):
36
- return f'{ShowSlow10.COMMAND} [limit]\t show slow <limit> audit lines'
35
+ def help(self, state: ReplState):
36
+ return super().help(state, 'show slow <limit> audit lines <limit> default to 10', args='[limit]')
@@ -32,5 +32,5 @@ class ShowTop10(Command):
32
32
  def completion(self, _: ReplState):
33
33
  return {}
34
34
 
35
- def help(self, _: ReplState):
36
- return f'{ShowTop10.COMMAND} [limit]\t show top <limit> audit lines'
35
+ def help(self, state: ReplState):
36
+ return super().help(state, 'show top <limit> audit lines <limit> default to 10', args='[limit]')
@@ -30,7 +30,7 @@ class Bash(Command):
30
30
  return exec(args)
31
31
 
32
32
  def completion(self, state: ReplState):
33
- return Devices.device(state).bash_completion(Bash.COMMAND, state, default = {})
33
+ return super().completion(state, {c : {'&': None} for c in ['ls', 'cat', 'head']}, pods=Devices.of(state).pods(state, '-'))
34
34
 
35
- def help(self, _: ReplState):
36
- return f'{Bash.COMMAND} [pod-name] [bash-commands] [&]\t run bash on the Cassandra nodes'
35
+ def help(self, state: ReplState):
36
+ return super().help(state, 'run bash on Cassandra nodes', args='[bash-commands] [&]')
@@ -13,4 +13,4 @@ class BashHandler:
13
13
  return False
14
14
 
15
15
  def exec(self, args: list[str]):
16
- return Devices.device(self.s1).bash(self.s0, self.s1, args)
16
+ return Devices.of(self.s1).bash(self.s0, self.s1, args)
@@ -0,0 +1,45 @@
1
+ from adam.commands.command import Command
2
+ from adam.commands.devices.devices import Devices
3
+ from adam.config import Config
4
+ from adam.utils_k8s.pod_exec_result import PodExecResult
5
+ from adam.utils import log2
6
+ from adam.utils_k8s.cassandra_nodes import CassandraNodes
7
+ from adam.repl_state import ReplState, RequiredState
8
+ from adam.utils_k8s.pods import Pods
9
+
10
+ class DownloadCassandraLog(Command):
11
+ COMMAND = 'download cassandra log'
12
+
13
+ # the singleton pattern
14
+ def __new__(cls, *args, **kwargs):
15
+ if not hasattr(cls, 'instance'): cls.instance = super(DownloadCassandraLog, 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 DownloadCassandraLog.COMMAND
24
+
25
+ def required(self):
26
+ return RequiredState.POD
27
+
28
+ def run(self, cmd: str, state: ReplState):
29
+ if not(args := self.args(cmd)):
30
+ return super().run(cmd, state)
31
+
32
+ with self.validate(args, state) as (args, state):
33
+ path = Config().get('logs.path', '/c3/cassandra/logs/system.log')
34
+ r: PodExecResult = CassandraNodes.exec(state.pod, state.namespace, f'cat {path}', backgrounded=True, history=False)
35
+
36
+ to_file = Pods.download_file(state.pod, 'cassandra', state.namespace, path)
37
+ log2(f'Downloaded to {to_file}.')
38
+
39
+ return r
40
+
41
+ def completion(self, state: ReplState):
42
+ return super().completion(state, pods=Devices.of(state).pods(state, '-'), auto='jit')
43
+
44
+ def help(self, state: ReplState):
45
+ return super().help(state, 'download cassandra system log')
@@ -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, state: ReplState):
47
+ return super().help(state, 'restart all the nodes in the cluster', args='--force')
@@ -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, state: ReplState):
51
+ return super().help(state, 'restart the node', args='--force')