kaqing 2.0.14__py3-none-any.whl → 2.0.145__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 (163) hide show
  1. adam/apps.py +2 -2
  2. adam/batch.py +13 -3
  3. adam/checks/check_utils.py +4 -4
  4. adam/checks/compactionstats.py +1 -1
  5. adam/checks/cpu.py +2 -2
  6. adam/checks/disk.py +1 -1
  7. adam/checks/gossip.py +1 -1
  8. adam/checks/memory.py +3 -3
  9. adam/checks/status.py +1 -1
  10. adam/commands/alter_tables.py +81 -0
  11. adam/commands/app.py +3 -3
  12. adam/commands/app_ping.py +2 -2
  13. adam/commands/audit/audit.py +86 -0
  14. adam/commands/audit/audit_repair_tables.py +77 -0
  15. adam/commands/audit/audit_run.py +58 -0
  16. adam/commands/audit/show_last10.py +51 -0
  17. adam/commands/audit/show_slow10.py +50 -0
  18. adam/commands/audit/show_top10.py +48 -0
  19. adam/commands/audit/utils_show_top10.py +59 -0
  20. adam/commands/bash/__init__.py +0 -0
  21. adam/commands/bash/bash.py +133 -0
  22. adam/commands/bash/bash_completer.py +93 -0
  23. adam/commands/cat.py +56 -0
  24. adam/commands/cd.py +12 -82
  25. adam/commands/check.py +6 -0
  26. adam/commands/cli_commands.py +3 -3
  27. adam/commands/code.py +60 -0
  28. adam/commands/command.py +48 -12
  29. adam/commands/commands_utils.py +4 -5
  30. adam/commands/cql/__init__.py +0 -0
  31. adam/commands/cql/cql_completions.py +28 -0
  32. adam/commands/cql/cql_utils.py +209 -0
  33. adam/commands/{cqlsh.py → cql/cqlsh.py} +15 -10
  34. adam/commands/deploy/code_utils.py +2 -2
  35. adam/commands/deploy/deploy.py +8 -21
  36. adam/commands/deploy/deploy_frontend.py +1 -1
  37. adam/commands/deploy/deploy_pg_agent.py +3 -3
  38. adam/commands/deploy/deploy_pod.py +28 -27
  39. adam/commands/deploy/deploy_utils.py +16 -26
  40. adam/commands/deploy/undeploy.py +8 -21
  41. adam/commands/deploy/undeploy_frontend.py +1 -1
  42. adam/commands/deploy/undeploy_pg_agent.py +5 -3
  43. adam/commands/deploy/undeploy_pod.py +12 -10
  44. adam/commands/devices/__init__.py +0 -0
  45. adam/commands/devices/device.py +27 -0
  46. adam/commands/devices/device_app.py +146 -0
  47. adam/commands/devices/device_auit_log.py +43 -0
  48. adam/commands/devices/device_cass.py +145 -0
  49. adam/commands/devices/device_export.py +86 -0
  50. adam/commands/devices/device_postgres.py +109 -0
  51. adam/commands/devices/devices.py +25 -0
  52. adam/commands/export/__init__.py +0 -0
  53. adam/commands/export/clean_up_export_session.py +53 -0
  54. adam/commands/export/clean_up_export_sessions.py +40 -0
  55. adam/commands/export/drop_export_database.py +58 -0
  56. adam/commands/export/drop_export_databases.py +46 -0
  57. adam/commands/export/export.py +83 -0
  58. adam/commands/export/export_databases.py +170 -0
  59. adam/commands/export/export_select.py +85 -0
  60. adam/commands/export/export_select_x.py +54 -0
  61. adam/commands/export/export_use.py +55 -0
  62. adam/commands/export/exporter.py +364 -0
  63. adam/commands/export/import_session.py +68 -0
  64. adam/commands/export/importer.py +67 -0
  65. adam/commands/export/importer_athena.py +80 -0
  66. adam/commands/export/importer_sqlite.py +47 -0
  67. adam/commands/export/show_column_counts.py +63 -0
  68. adam/commands/export/show_export_databases.py +39 -0
  69. adam/commands/export/show_export_session.py +51 -0
  70. adam/commands/export/show_export_sessions.py +47 -0
  71. adam/commands/export/utils_export.py +291 -0
  72. adam/commands/help.py +12 -7
  73. adam/commands/issues.py +6 -0
  74. adam/commands/kubectl.py +41 -0
  75. adam/commands/login.py +7 -4
  76. adam/commands/logs.py +2 -1
  77. adam/commands/ls.py +4 -107
  78. adam/commands/medusa/medusa.py +2 -26
  79. adam/commands/medusa/medusa_backup.py +2 -2
  80. adam/commands/medusa/medusa_restore.py +3 -4
  81. adam/commands/medusa/medusa_show_backupjobs.py +4 -3
  82. adam/commands/medusa/medusa_show_restorejobs.py +3 -3
  83. adam/commands/nodetool.py +9 -4
  84. adam/commands/param_set.py +1 -1
  85. adam/commands/postgres/postgres.py +42 -43
  86. adam/commands/postgres/{postgres_session.py → postgres_context.py} +43 -42
  87. adam/commands/postgres/postgres_utils.py +31 -0
  88. adam/commands/postgres/psql_completions.py +10 -0
  89. adam/commands/preview_table.py +18 -40
  90. adam/commands/pwd.py +2 -28
  91. adam/commands/reaper/reaper.py +4 -24
  92. adam/commands/reaper/reaper_restart.py +1 -1
  93. adam/commands/reaper/reaper_session.py +2 -2
  94. adam/commands/repair/repair.py +3 -27
  95. adam/commands/repair/repair_log.py +1 -1
  96. adam/commands/repair/repair_run.py +2 -2
  97. adam/commands/repair/repair_scan.py +1 -1
  98. adam/commands/repair/repair_stop.py +1 -1
  99. adam/commands/report.py +6 -0
  100. adam/commands/restart.py +2 -2
  101. adam/commands/rollout.py +1 -1
  102. adam/commands/show/show.py +11 -26
  103. adam/commands/show/show_app_actions.py +3 -0
  104. adam/commands/show/show_app_id.py +1 -1
  105. adam/commands/show/show_app_queues.py +3 -2
  106. adam/commands/show/show_cassandra_status.py +3 -3
  107. adam/commands/show/show_cassandra_version.py +3 -3
  108. adam/commands/show/show_host.py +33 -0
  109. adam/commands/show/show_login.py +3 -0
  110. adam/commands/show/show_processes.py +1 -1
  111. adam/commands/show/show_repairs.py +2 -2
  112. adam/commands/show/show_storage.py +1 -1
  113. adam/commands/watch.py +1 -1
  114. adam/config.py +16 -3
  115. adam/embedded_params.py +1 -1
  116. adam/pod_exec_result.py +10 -2
  117. adam/repl.py +127 -117
  118. adam/repl_commands.py +51 -16
  119. adam/repl_state.py +276 -55
  120. adam/sql/__init__.py +0 -0
  121. adam/sql/sql_completer.py +120 -0
  122. adam/sql/sql_state_machine.py +617 -0
  123. adam/sql/term_completer.py +76 -0
  124. adam/sso/authn_ad.py +1 -1
  125. adam/sso/cred_cache.py +1 -1
  126. adam/sso/idp.py +1 -1
  127. adam/utils.py +83 -2
  128. adam/utils_athena.py +145 -0
  129. adam/utils_audits.py +102 -0
  130. adam/utils_k8s/__init__.py +0 -0
  131. adam/utils_k8s/app_clusters.py +33 -0
  132. adam/utils_k8s/app_pods.py +31 -0
  133. adam/{k8s_utils → utils_k8s}/cassandra_clusters.py +6 -21
  134. adam/{k8s_utils → utils_k8s}/cassandra_nodes.py +12 -5
  135. adam/{k8s_utils → utils_k8s}/deployment.py +2 -2
  136. adam/{k8s_utils → utils_k8s}/kube_context.py +1 -1
  137. adam/{k8s_utils → utils_k8s}/pods.py +119 -26
  138. adam/{k8s_utils → utils_k8s}/secrets.py +4 -0
  139. adam/{k8s_utils → utils_k8s}/statefulsets.py +5 -4
  140. adam/utils_net.py +24 -0
  141. adam/utils_repl/__init__.py +0 -0
  142. adam/utils_repl/automata_completer.py +48 -0
  143. adam/utils_repl/repl_completer.py +46 -0
  144. adam/utils_repl/state_machine.py +173 -0
  145. adam/utils_sqlite.py +101 -0
  146. adam/version.py +1 -1
  147. {kaqing-2.0.14.dist-info → kaqing-2.0.145.dist-info}/METADATA +1 -1
  148. kaqing-2.0.145.dist-info/RECORD +227 -0
  149. adam/commands/bash.py +0 -87
  150. adam/commands/cql_utils.py +0 -53
  151. adam/commands/devices.py +0 -89
  152. kaqing-2.0.14.dist-info/RECORD +0 -167
  153. /adam/{k8s_utils → commands/audit}/__init__.py +0 -0
  154. /adam/{k8s_utils → utils_k8s}/config_maps.py +0 -0
  155. /adam/{k8s_utils → utils_k8s}/custom_resources.py +0 -0
  156. /adam/{k8s_utils → utils_k8s}/ingresses.py +0 -0
  157. /adam/{k8s_utils → utils_k8s}/jobs.py +0 -0
  158. /adam/{k8s_utils → utils_k8s}/service_accounts.py +0 -0
  159. /adam/{k8s_utils → utils_k8s}/services.py +0 -0
  160. /adam/{k8s_utils → utils_k8s}/volumes.py +0 -0
  161. {kaqing-2.0.14.dist-info → kaqing-2.0.145.dist-info}/WHEEL +0 -0
  162. {kaqing-2.0.14.dist-info → kaqing-2.0.145.dist-info}/entry_points.txt +0 -0
  163. {kaqing-2.0.14.dist-info → kaqing-2.0.145.dist-info}/top_level.txt +0 -0
@@ -1,12 +1,11 @@
1
- import functools
2
-
3
1
  from adam.commands.command import Command
4
- from adam.commands.cql_utils import parse_cql_desc_tables, run_cql
5
- from adam.commands.postgres.postgres_session import PostgresSession
2
+ from adam.commands.cql.cql_utils import cassandra_table_names, run_cql
3
+ from adam.commands.postgres.postgres_context import PostgresContext
6
4
  from adam.config import Config
7
- from adam.pod_exec_result import PodExecResult
8
5
  from adam.repl_state import ReplState, RequiredState
9
6
  from adam.utils import lines_to_tabular, log, log2
7
+ from adam.utils_athena import Athena
8
+ from adam.utils_audits import Audits
10
9
 
11
10
  class PreviewTable(Command):
12
11
  COMMAND = 'preview'
@@ -24,28 +23,26 @@ class PreviewTable(Command):
24
23
  return PreviewTable.COMMAND
25
24
 
26
25
  def required(self):
27
- return RequiredState.CLUSTER_OR_POD
26
+ return [RequiredState.CLUSTER_OR_POD, RequiredState.PG_DATABASE, ReplState.L]
28
27
 
29
28
  def run(self, cmd: str, state: ReplState):
30
29
  if not(args := self.args(cmd)):
31
30
  return super().run(cmd, state)
32
31
 
33
32
  state, args = self.apply_state(args, state)
34
- if state.device == ReplState.P:
35
- if not self.validate_state(state, RequiredState.PG_DATABASE):
36
- return state
37
- else:
38
- if not self.validate_state(state):
39
- return state
33
+ if not self.validate_state(state):
34
+ return state
40
35
 
41
36
  if not args:
42
37
  def show_tables():
43
38
  if state.device == ReplState.P:
44
- pg = PostgresSession(state.namespace, state.pg_path)
45
- lines = [db["name"] for db in pg.tables() if db["schema"] == PostgresSession.default_schema()]
39
+ pg = PostgresContext.apply(state.namespace, state.pg_path)
40
+ lines = [db["name"] for db in pg.tables() if db["schema"] == PostgresContext.default_schema()]
46
41
  log(lines_to_tabular(lines, separator=','))
42
+ elif state.device == ReplState.L:
43
+ log(lines_to_tabular(Athena.table_names(), separator=','))
47
44
  else:
48
- run_cql(state, f'describe tables', show_out=True)
45
+ log(lines_to_tabular(cassandra_table_names(state), separator=','))
49
46
 
50
47
  if state.in_repl:
51
48
  log2('Table is required.')
@@ -64,35 +61,16 @@ class PreviewTable(Command):
64
61
 
65
62
  rows = Config().get('preview.rows', 10)
66
63
  if state.device == ReplState.P:
67
- PostgresSession(state.namespace, state.pg_path).run_sql(f'select * from {table} limit {rows}')
64
+ PostgresContext.apply(state.namespace, state.pg_path).run_sql(f'select * from {table} limit {rows}')
65
+ elif state.device == ReplState.L:
66
+ Athena.run_query(f'select * from {table} limit {rows}')
68
67
  else:
69
- run_cql(state, f'select * from {table} limit {rows}', show_out=True, use_single_quotes=True)
68
+ run_cql(state, f'select * from {table} limit {rows}', show_out=True, use_single_quotes=True, on_any=True)
70
69
 
71
70
  return state
72
71
 
73
- def completion(self, state: ReplState):
74
- if state.device == ReplState.P:
75
- if tables := PreviewTable.pg_tables(state.namespace, state.pg_path):
76
- return {PreviewTable.COMMAND: {db["name"]: None for db in tables if db["schema"] == PostgresSession.default_schema()}}
77
- else:
78
- if state.pod:
79
- tables = PreviewTable.cql_tables(state)
80
- return {PreviewTable.COMMAND: {f'{k}.{t}': None for k, ts in tables.items() for t in ts}}
81
-
72
+ def completion(self, _: ReplState):
82
73
  return {}
83
74
 
84
75
  def help(self, _: ReplState):
85
- return f'{PreviewTable.COMMAND} TABLE\t preview table'
86
-
87
- @functools.lru_cache()
88
- def cql_tables(state: ReplState):
89
- r: PodExecResult = run_cql(state, 'describe tables', show_out=False)
90
- return parse_cql_desc_tables(r.stdout)
91
-
92
- @functools.lru_cache()
93
- def pg_tables(ns: str, pg_path: str):
94
- pg = PostgresSession(ns, pg_path)
95
- if pg.db:
96
- return pg.tables()
97
-
98
- return None
76
+ return f'{PreviewTable.COMMAND} TABLE\t preview table'
adam/commands/pwd.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from adam.app_session import AppSession
2
2
  from adam.commands.command import Command
3
- from adam.commands.postgres.postgres_session import PostgresSession
3
+ from adam.commands.devices.devices import Devices
4
4
  from adam.repl_state import ReplState
5
5
  from adam.utils import lines_to_tabular, log
6
6
 
@@ -25,29 +25,6 @@ class Pwd(Command):
25
25
 
26
26
  state, _ = self.apply_state(args, state)
27
27
 
28
- def device_line(state: ReplState, device: str):
29
- words = []
30
-
31
- if device == ReplState.P:
32
- pg = PostgresSession(state.namespace, state.pg_path)
33
-
34
- if pg.host:
35
- words.append(f'host/{pg.host}')
36
- if pg.db:
37
- words.append(f'database/{pg.db}')
38
- elif device == ReplState.A:
39
- if state.app_env:
40
- words.append(f'env/{state.app_env}')
41
- if state.app_app:
42
- words.append(f'app/{state.app_app}')
43
- else:
44
- if state.sts:
45
- words.append(f'sts/{state.sts}')
46
- if state.pod:
47
- words.append(f'pod/{state.pod}')
48
-
49
- return '\t'.join([f'{device}:>'] + (words if words else ['/']))
50
-
51
28
  host = "unknown"
52
29
  try:
53
30
  app_session: AppSession = AppSession.create('c3', 'c3')
@@ -55,10 +32,7 @@ class Pwd(Command):
55
32
  except:
56
33
  pass
57
34
 
58
- log(lines_to_tabular([
59
- device_line(state, ReplState.A),
60
- device_line(state, ReplState.C),
61
- device_line(state, ReplState.P),
35
+ log(lines_to_tabular([device.pwd(state) for device in Devices.all()] + [
62
36
  f'',
63
37
  f'HOST\t{host}',
64
38
  f'NAMESPACE\t{state.namespace if state.namespace else "/"}',
@@ -1,7 +1,6 @@
1
1
  import click
2
2
 
3
3
  from adam.commands.command import Command
4
- from adam.commands.command_helpers import ClusterCommandHelper
5
4
  from .reaper_forward import ReaperForward
6
5
  from .reaper_forward_stop import ReaperForwardStop
7
6
  from .reaper_restart import ReaperRestart
@@ -14,7 +13,6 @@ from .reaper_schedule_stop import ReaperScheduleStop
14
13
  from .reaper_schedules import ReaperSchedules
15
14
  from .reaper_status import ReaperStatus
16
15
  from adam.repl_state import ReplState, RequiredState
17
- from adam.utils import lines_to_tabular, log, log2
18
16
 
19
17
  class Reaper(Command):
20
18
  COMMAND = 'reaper'
@@ -39,24 +37,15 @@ class Reaper(Command):
39
37
  if not(args := self.args(cmd)):
40
38
  return super().run(cmd, state)
41
39
 
42
- state, args = self.apply_state(args, state)
43
40
  if not self.validate_state(state):
44
41
  return state
45
42
 
46
- if state.in_repl:
47
- log(lines_to_tabular([c.help(ReplState()) for c in Reaper.cmd_list()], separator='\t'))
48
-
49
- return 'command-missing'
50
- else:
51
- # head with the Chain of Responsibility pattern
52
- cmds = Command.chain(Reaper.cmd_list())
53
- if not cmds.run(cmd, state):
54
- log2('* Command is missing.')
55
- Command.display_help()
43
+ return super().intermediate_run(cmd, state, args, Reaper.cmd_list())
56
44
 
57
45
  def cmd_list():
58
46
  return [ReaperSchedules(), ReaperScheduleStop(), ReaperScheduleActivate(), ReaperScheduleStart(),
59
- ReaperForwardStop(), ReaperForward(), ReaperRunAbort(), ReaperRunsAbort(), ReaperRestart(), ReaperRuns(), ReaperStatus()]
47
+ ReaperForwardStop(), ReaperForward(), ReaperRunAbort(), ReaperRunsAbort(), ReaperRestart(),
48
+ ReaperRuns(), ReaperStatus()]
60
49
 
61
50
  def completion(self, state: ReplState):
62
51
  if state.sts:
@@ -64,15 +53,6 @@ class Reaper(Command):
64
53
 
65
54
  return {}
66
55
 
67
- def help(self, _: ReplState):
68
- return None
69
-
70
56
  class ReaperCommandHelper(click.Command):
71
57
  def get_help(self, ctx: click.Context):
72
- log(super().get_help(ctx))
73
- log()
74
- log('Sub-Commands:')
75
-
76
- log(lines_to_tabular([c.help(ReplState()).replace(f'{Reaper.COMMAND} ', ' ', 1) for c in Reaper.cmd_list()], separator='\t'))
77
- log()
78
- ClusterCommandHelper.cluster_help()
58
+ Command.intermediate_help(super().get_help(ctx), Reaper.COMMAND, Reaper.cmd_list(), show_cluster_help=True)
@@ -1,5 +1,5 @@
1
1
  from adam.commands.command import Command
2
- from adam.k8s_utils.pods import Pods
2
+ from adam.utils_k8s.pods import Pods
3
3
  from .reaper_session import ReaperSession
4
4
  from adam.repl_state import ReplState, RequiredState
5
5
 
@@ -7,7 +7,7 @@ import requests
7
7
  from typing import List, cast
8
8
 
9
9
  from adam.config import Config
10
- from adam.k8s_utils.kube_context import KubeContext
10
+ from adam.utils_k8s.kube_context import KubeContext
11
11
  from adam.repl_state import ReplState
12
12
  from adam.utils import lines_to_tabular, log2
13
13
 
@@ -149,7 +149,7 @@ class ReaperSession:
149
149
  return ReaperSession.schedules_ids_by_cluster[state.sts]
150
150
 
151
151
  if reaper := ReaperSession.create(state):
152
- state.wait_log("Inspecting Cassandra Reaper...")
152
+ Config().wait_log('Inspecting Cassandra Reaper...')
153
153
 
154
154
  schedules = reaper.schedule_ids(state, show_output = False)
155
155
  ReaperSession.schedules_ids_by_cluster[state.sts] = schedules
@@ -1,13 +1,11 @@
1
1
  import click
2
2
 
3
3
  from adam.commands.command import Command
4
- from adam.commands.command_helpers import ClusterCommandHelper
5
4
  from .repair_run import RepairRun
6
5
  from .repair_scan import RepairScan
7
6
  from .repair_stop import RepairStop
8
7
  from .repair_log import RepairLog
9
8
  from adam.repl_state import ReplState, RequiredState
10
- from adam.utils import lines_to_tabular, log, log2
11
9
 
12
10
  class Repair(Command):
13
11
  COMMAND = 'repair'
@@ -30,39 +28,17 @@ class Repair(Command):
30
28
  def run(self, cmd: str, state: ReplState):
31
29
  if not(args := self.args(cmd)):
32
30
  return super().run(cmd, state)
33
-
34
- state, args = self.apply_state(args, state)
35
31
  if not self.validate_state(state):
36
32
  return state
37
33
 
38
- if state.in_repl:
39
- log(lines_to_tabular([c.help(ReplState()) for c in Repair.cmd_list()], separator='\t'))
40
-
41
- return 'command-missing'
42
- else:
43
- # head with the Chain of Responsibility pattern
44
- cmds = Command.chain(Repair.cmd_list())
45
- if not cmds.run(cmd, state):
46
- log2('* Command is missing.')
47
- Command.display_help()
34
+ return super().intermediate_run(cmd, state, args, Repair.cmd_list())
48
35
 
49
36
  def cmd_list():
50
37
  return [RepairRun(), RepairScan(), RepairStop(), RepairLog()]
51
38
 
52
39
  def completion(self, state: ReplState):
53
- if state.sts:
54
- return super().completion(state)
55
- return {}
56
-
57
- def help(self, _: ReplState):
58
- return None
40
+ return super().completion(state)
59
41
 
60
42
  class RepairCommandHelper(click.Command):
61
43
  def get_help(self, ctx: click.Context):
62
- log(super().get_help(ctx))
63
- log()
64
- log('Sub-Commands:')
65
-
66
- log(lines_to_tabular([c.help(ReplState()).replace(f'{Repair.COMMAND} ', ' ', 1) for c in Repair.cmd_list()], separator='\t'))
67
- log()
68
- ClusterCommandHelper.cluster_help()
44
+ Command.intermediate_help(super().get_help(ctx), Repair.COMMAND, Repair.cmd_list(), show_cluster_help=True)
@@ -1,5 +1,5 @@
1
1
  from adam.commands.command import Command
2
- from adam.k8s_utils.jobs import Jobs
2
+ from adam.utils_k8s.jobs import Jobs
3
3
  from adam.repl_state import ReplState, RequiredState
4
4
 
5
5
  class RepairLog(Command):
@@ -1,6 +1,6 @@
1
1
  from adam.commands.command import Command
2
- from adam.k8s_utils.jobs import Jobs
3
- from adam.k8s_utils.volumes import Volumes
2
+ from adam.utils_k8s.jobs import Jobs
3
+ from adam.utils_k8s.volumes import Volumes
4
4
  from adam.repl_state import ReplState, RequiredState
5
5
  from adam.config import Config
6
6
  from adam.commands.reaper.reaper_session import ReaperSession
@@ -1,7 +1,7 @@
1
1
  import time
2
2
 
3
3
  from adam.commands.command import Command
4
- from adam.k8s_utils.pods import Pods
4
+ from adam.utils_k8s.pods import Pods
5
5
  from adam.repl_state import ReplState, RequiredState
6
6
  from adam.utils import log2
7
7
  from adam.config import Config
@@ -1,5 +1,5 @@
1
1
  from adam.commands.command import Command
2
- from adam.k8s_utils.jobs import Jobs
2
+ from adam.utils_k8s.jobs import Jobs
3
3
  from adam.repl_state import ReplState, RequiredState
4
4
  from adam.config import Config
5
5
 
adam/commands/report.py CHANGED
@@ -22,12 +22,18 @@ class Report(Command):
22
22
  def command(self):
23
23
  return Report.COMMAND
24
24
 
25
+ def required(self):
26
+ return ReplState.NON_L
27
+
25
28
  def run(self, cmd: str, state: ReplState):
26
29
  if not(args := self.args(cmd)):
27
30
  return super().run(cmd, state)
28
31
 
29
32
  output: dict[str, any] = {}
30
33
  state, args = self.apply_state(args, state)
34
+ if not self.validate_state(state):
35
+ return state
36
+
31
37
  if state.in_repl:
32
38
  args, show = Command.extract_options(args, ['-s', '--show'])
33
39
 
adam/commands/restart.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from adam.commands.command import Command
2
- from adam.k8s_utils.pods import Pods
3
- from adam.k8s_utils.statefulsets import StatefulSets
2
+ from adam.utils_k8s.pods import Pods
3
+ from adam.utils_k8s.statefulsets import StatefulSets
4
4
  from adam.repl_state import ReplState, RequiredState
5
5
  from adam.utils import log2
6
6
 
adam/commands/rollout.py CHANGED
@@ -4,7 +4,7 @@ from kubernetes.client.rest import ApiException
4
4
 
5
5
  from adam.commands.command import Command
6
6
  from adam.commands.watch import Watch
7
- from adam.k8s_utils.statefulsets import StatefulSets
7
+ from adam.utils_k8s.statefulsets import StatefulSets
8
8
  from adam.config import Config
9
9
  from adam.repl_state import ReplState, RequiredState
10
10
  from adam.utils import duration, log2
@@ -1,9 +1,13 @@
1
1
  import click
2
2
 
3
+ from adam.commands.audit.show_last10 import ShowLast10
3
4
  from adam.commands.command import Command
4
- from adam.commands.command_helpers import ClusterCommandHelper
5
+ from adam.commands.export.show_column_counts import ShowColumnCounts
6
+ from adam.commands.medusa.medusa_show_backupjobs import MedusaShowBackupJobs
7
+ from adam.commands.medusa.medusa_show_restorejobs import MedusaShowRestoreJobs
5
8
  from adam.commands.show.show_app_actions import ShowAppActions
6
9
  from adam.commands.show.show_app_queues import ShowAppQueues
10
+ from adam.commands.show.show_host import ShowHost
7
11
  from adam.commands.show.show_login import ShowLogin
8
12
  from .show_params import ShowParams
9
13
  from .show_app_id import ShowAppId
@@ -15,7 +19,6 @@ from .show_repairs import ShowRepairs
15
19
  from .show_storage import ShowStorage
16
20
  from .show_adam import ShowAdam
17
21
  from adam.repl_state import ReplState
18
- from adam.utils import lines_to_tabular, log, log2
19
22
 
20
23
  class Show(Command):
21
24
  COMMAND = 'show'
@@ -36,35 +39,17 @@ class Show(Command):
36
39
  if not(args := self.args(cmd)):
37
40
  return super().run(cmd, state)
38
41
 
39
- state, args = self.apply_state(args, state)
40
-
41
- if state.in_repl:
42
- log(lines_to_tabular([c.help(ReplState()) for c in Show.cmd_list()], separator='\t'))
43
-
44
- return 'command-missing'
45
- else:
46
- # head with the Chain of Responsibility pattern
47
- cmds = Command.chain(Show.cmd_list())
48
- if not cmds.run(cmd, state):
49
- log2('* Command is missing.')
50
- Command.display_help()
42
+ return super().intermediate_run(cmd, state, args, Show.cmd_list())
51
43
 
52
44
  def cmd_list():
53
- return [ShowAppActions(), ShowAppId(), ShowAppQueues(), ShowLogin(), ShowKubectlCommands(), ShowParams(), ShowProcesses(), ShowRepairs(),
54
- ShowStorage(), ShowAdam(), ShowCassandraStatus(), ShowCassandraVersion()]
45
+ return [ShowAppActions(), ShowAppId(), ShowAppQueues(), ShowHost(), ShowLogin(), ShowKubectlCommands(),
46
+ ShowParams(), ShowProcesses(), ShowRepairs(), ShowStorage(), ShowAdam(),
47
+ ShowCassandraStatus(), ShowCassandraVersion(), MedusaShowRestoreJobs(), MedusaShowBackupJobs(),
48
+ ShowLast10()]
55
49
 
56
50
  def completion(self, state: ReplState):
57
51
  return super().completion(state)
58
52
 
59
- def help(self, _: ReplState):
60
- return f"{Show.COMMAND}\t show kubectl commands"
61
-
62
53
  class ShowCommandHelper(click.Command):
63
54
  def get_help(self, ctx: click.Context):
64
- log(super().get_help(ctx))
65
- log()
66
- log('Catogories:')
67
-
68
- log(lines_to_tabular([c.help(ReplState()).replace(f'{Show.COMMAND} ', ' ', 1) for c in Show.cmd_list()], separator=':'))
69
- log()
70
- ClusterCommandHelper.cluster_help()
55
+ Command.intermediate_help(super().get_help(ctx), Show.COMMAND, Show.cmd_list(), show_cluster_help=True)
@@ -20,6 +20,9 @@ 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
27
  if not self.args(cmd):
25
28
  return super().run(cmd, state)
@@ -1,5 +1,5 @@
1
1
  from adam.commands.command import Command
2
- from adam.k8s_utils.custom_resources import CustomResources
2
+ from adam.utils_k8s.custom_resources import CustomResources
3
3
  from adam.repl_state import ReplState, RequiredState
4
4
  from adam.utils import log
5
5
 
@@ -18,14 +18,15 @@ class ShowAppQueues(Command):
18
18
  return ShowAppQueues.COMMAND
19
19
 
20
20
  def required(self):
21
- return RequiredState.CLUSTER_OR_POD
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
27
  state, args = self.apply_state(args, state)
28
- if not self.validate_state(state, app_required=RequiredState.APP_APP):
28
+ # if not self.validate_state(state, app_required=RequiredState.APP_APP):
29
+ if not self.validate_state(state):
29
30
  return state
30
31
 
31
32
  _, forced = Command.extract_options(args, '--force')
@@ -8,9 +8,9 @@ from adam.columns.columns import Columns
8
8
  from adam.commands.command import Command
9
9
  from adam.commands.issues import Issues
10
10
  from adam.config import Config
11
- from adam.k8s_utils.cassandra_nodes import CassandraNodes
12
- from adam.k8s_utils.secrets import Secrets
13
- from adam.k8s_utils.statefulsets import StatefulSets
11
+ from adam.utils_k8s.cassandra_nodes import CassandraNodes
12
+ from adam.utils_k8s.secrets import Secrets
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
16
16
  from adam.checks.status import parse_nodetool_status
@@ -1,7 +1,7 @@
1
1
  from adam.commands.command import Command
2
- from adam.k8s_utils.cassandra_clusters import CassandraClusters
3
- from adam.k8s_utils.cassandra_nodes import CassandraNodes
4
- from adam.k8s_utils.secrets import Secrets
2
+ from adam.utils_k8s.cassandra_clusters import CassandraClusters
3
+ from adam.utils_k8s.cassandra_nodes import CassandraNodes
4
+ from adam.utils_k8s.secrets import Secrets
5
5
  from adam.repl_state import ReplState, RequiredState
6
6
 
7
7
  class ShowCassandraVersion(Command):
@@ -0,0 +1,33 @@
1
+ from adam.commands.command import Command
2
+ from adam.repl_state import ReplState
3
+ from adam.utils import log
4
+ from adam.utils_net import get_my_host
5
+
6
+ class ShowHost(Command):
7
+ COMMAND = 'show host'
8
+
9
+ # the singleton pattern
10
+ def __new__(cls, *args, **kwargs):
11
+ if not hasattr(cls, 'instance'): cls.instance = super(ShowHost, 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 ShowHost.COMMAND
20
+
21
+ def run(self, cmd: str, state: ReplState):
22
+ if not(args := self.args(cmd)):
23
+ return super().run(cmd, state)
24
+
25
+ log(get_my_host())
26
+
27
+ return state
28
+
29
+ def completion(self, state: ReplState):
30
+ return super().completion(state)
31
+
32
+ def help(self, _: ReplState):
33
+ return f'{ShowHost.COMMAND}\t show host'
@@ -24,6 +24,9 @@ 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)
@@ -1,7 +1,7 @@
1
1
  from adam.commands.command import Command
2
2
  from adam.commands.commands_utils import show_table
3
3
  from adam.config import Config
4
- from adam.k8s_utils.statefulsets import StatefulSets
4
+ from adam.utils_k8s.statefulsets import StatefulSets
5
5
  from adam.repl_state import ReplState, RequiredState
6
6
 
7
7
  class ShowProcesses(Command):
@@ -1,6 +1,6 @@
1
1
  from adam.commands.command import Command
2
- from adam.k8s_utils.cassandra_clusters import CassandraClusters
3
- from adam.k8s_utils.cassandra_nodes import CassandraNodes
2
+ from adam.utils_k8s.cassandra_clusters import CassandraClusters
3
+ from adam.utils_k8s.cassandra_nodes import CassandraNodes
4
4
  from adam.repl_state import ReplState, RequiredState
5
5
 
6
6
  class ShowRepairs(Command):
@@ -1,7 +1,7 @@
1
1
  from adam.commands.command import Command
2
2
  from adam.commands.commands_utils import show_table
3
3
  from adam.config import Config
4
- from adam.k8s_utils.statefulsets import StatefulSets
4
+ from adam.utils_k8s.statefulsets import StatefulSets
5
5
  from adam.repl_state import ReplState, RequiredState
6
6
 
7
7
  class ShowStorage(Command):
adam/commands/watch.py CHANGED
@@ -6,7 +6,7 @@ from typing import List
6
6
  from adam.commands.command import Command
7
7
  from adam.commands.commands_utils import show_pods, show_rollout
8
8
  from adam.config import Config
9
- from adam.k8s_utils.statefulsets import StatefulSets
9
+ from adam.utils_k8s.statefulsets import StatefulSets
10
10
  from adam.repl_state import ReplState, RequiredState
11
11
  from adam.utils import convert_seconds, log2
12
12
 
adam/config.py CHANGED
@@ -1,14 +1,18 @@
1
+ import os
1
2
  from typing import TypeVar, cast
2
3
  import yaml
3
4
 
4
5
  from . import __version__
5
- from adam.utils import copy_config_file, get_deep_keys, log2
6
+ from adam.utils import copy_config_file, get_deep_keys, log2, is_debug_holder
6
7
 
7
8
  T = TypeVar('T')
8
9
 
9
10
  class Config:
10
11
  EMBEDDED_PARAMS = {}
11
12
 
13
+ global is_debug_holder
14
+ is_debug_holder[0] = lambda: Config().is_debug()
15
+
12
16
  # the singleton pattern
13
17
  def __new__(cls, *args, **kwargs):
14
18
  if not hasattr(cls, 'instance'): cls.instance = super(Config, cls).__new__(cls)
@@ -17,6 +21,7 @@ class Config:
17
21
 
18
22
  def __init__(self, path: str = None, is_user_entry = False):
19
23
  if path:
24
+ self.wait_log_flag = False
20
25
  try:
21
26
  with open(path) as f:
22
27
  self.params = cast(dict[str, any], yaml.safe_load(f))
@@ -37,7 +42,7 @@ class Config:
37
42
  return get_deep_keys(self.params)
38
43
 
39
44
  def is_debug(self):
40
- return Config().get('debug.show-out', False)
45
+ return os.getenv('QING_DEV', 'false').lower() == 'true' or Config().get('debug', False)
41
46
 
42
47
  def debug(self, s: None):
43
48
  if self.is_debug():
@@ -83,4 +88,12 @@ class Config:
83
88
  log2(f'incorrect path: {key}')
84
89
  return None
85
90
 
86
- return v if v else 'false'
91
+ return v if v else 'false'
92
+
93
+ def wait_log(self, msg: str):
94
+ if hasattr(self, 'wait_log_flag') and not self.wait_log_flag:
95
+ log2(msg)
96
+ self.wait_log_flag = True
97
+
98
+ def clear_wait_log_flag(self):
99
+ self.wait_log_flag = False