kaqing 2.0.32__py3-none-any.whl → 2.0.34__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/batch.py CHANGED
@@ -8,6 +8,7 @@ from adam.commands.command_helpers import ClusterCommandHelper, ClusterOrPodComm
8
8
  from adam.commands.cqlsh import CqlCommandHelper, Cqlsh
9
9
  from adam.commands.deploy.deploy import Deploy, DeployCommandHelper
10
10
  from adam.commands.deploy.undeploy import Undeploy, UndeployCommandHelper
11
+ from adam.commands.describe.describe import Describe, DescribeCommandHelper
11
12
  from adam.commands.issues import Issues
12
13
  from adam.commands.login import Login
13
14
  from adam.commands.logs import Logs
@@ -86,6 +87,19 @@ def deploy(kubeconfig: str, config: str, param: list[str], namespace: str, extra
86
87
  run_command(Deploy(), kubeconfig, config, param, None, namespace, None, extra_args)
87
88
 
88
89
 
90
+ @cli.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True), cls=DescribeCommandHelper, help='Describe keyspace(s) or table(s).')
91
+ @click.option('--kubeconfig', '-k', required=False, metavar='path', help='path to kubeconfig file')
92
+ @click.option('--config', default='params.yaml', metavar='path', help='path to kaqing parameters file')
93
+ @click.option('--param', '-v', multiple=True, metavar='<key>=<value>', help='parameter override')
94
+ @click.option('--cluster', '-c', required=False, metavar='statefulset', help='Kubernetes statefulset name')
95
+ @click.option('--namespace', '-n', required=False, metavar='namespace', help='Kubernetes namespace')
96
+ @click.option('--pod', '-p', required=False, metavar='pod', help='Kubernetes pod name')
97
+ @click.option('--all-nodes', '-a', is_flag=True, help='execute on all Cassandra nodes')
98
+ @click.argument('extra_args', nargs=-1, metavar='<cluster|pod>', type=click.UNPROCESSED)
99
+ def describe(kubeconfig: str, config: str, param: list[str], cluster: str, namespace: str, pod: str, all_nodes: bool, extra_args):
100
+ run_command(Describe(), kubeconfig, config, param, cluster, namespace, pod, ('--all-nodes',) + extra_args if all_nodes else extra_args)
101
+
102
+
89
103
  @cli.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True), cls=ClusterOrPodCommandHelper, help="Print Qing's issues.")
90
104
  @click.option('--kubeconfig', '-k', required=False, metavar='path', help='path to kubeconfig file')
91
105
  @click.option('--config', default='params.yaml', metavar='path', help='path to kaqing parameters file')
adam/commands/command.py CHANGED
@@ -3,8 +3,9 @@ import copy
3
3
  import subprocess
4
4
  import sys
5
5
 
6
- from adam.config import Config
6
+ from adam.commands.command_helpers import ClusterCommandHelper
7
7
  from adam.repl_state import ReplState, RequiredState
8
+ from adam.utils import lines_to_tabular, log, log2
8
9
 
9
10
  repl_cmds: list['Command'] = []
10
11
 
@@ -41,9 +42,8 @@ class Command:
41
42
  def validate_state(self, state: ReplState, pg_required: RequiredState = None, app_required: RequiredState = None):
42
43
  return state.validate(self.required(), pg_required=pg_required, app_required=app_required)
43
44
 
44
- @abstractmethod
45
- def help(self, state: ReplState) -> str:
46
- pass
45
+ def help(self, _: ReplState) -> str:
46
+ return None
47
47
 
48
48
  def args(self, cmd: str):
49
49
  a = list(filter(None, cmd.split(' ')))
@@ -102,4 +102,30 @@ class Command:
102
102
  while s := cmd._successor:
103
103
  print(f'-> {s.command()}', end = '')
104
104
  cmd = s
105
- print()
105
+ print()
106
+
107
+ def intermediate_run(self, cmd: str, state: ReplState, args: list[str], cmds: list['Command'], separator='\t'):
108
+ state, _ = self.apply_state(args, state)
109
+
110
+ if state.in_repl:
111
+ log(lines_to_tabular([c.help(state) for c in cmds], separator=separator))
112
+
113
+ return 'command-missing'
114
+ else:
115
+ # head with the Chain of Responsibility pattern
116
+ cmds = Command.chain(cmds)
117
+ if not cmds.run(cmd, state):
118
+ log2('* Command is missing.')
119
+ Command.display_help()
120
+
121
+ return state
122
+
123
+ def intermediate_help(super_help: str, cmd: str, cmd_list: list['Command'], separator='\t', show_cluster_help=False):
124
+ log(super_help)
125
+ log()
126
+ log('Sub-Commands:')
127
+
128
+ log(lines_to_tabular([c.help(ReplState()).replace(f'{cmd} ', ' ', 1) for c in cmd_list], separator=separator))
129
+ if show_cluster_help:
130
+ log()
131
+ ClusterCommandHelper.cluster_help()
@@ -10,18 +10,15 @@ from adam.repl_state import ReplState
10
10
  from adam.utils import log2
11
11
 
12
12
  @functools.lru_cache()
13
- def keyspaces(sts: str, namespace: str):
13
+ def keyspaces(state: ReplState, on_any=False):
14
14
  Config().wait_log("Inspecting Cassandra Keyspaces...")
15
15
 
16
- user, pw = Secrets.get_user_pass(sts, namespace, secret_path='cql.secret')
17
- command = f'cqlsh -u {user} -p {pw} -e "describe keyspaces"'
18
-
19
- r: list[PodExecResult] = CassandraClusters.exec(sts, namespace, command, show_out=False, action='cql', on_any=True)
16
+ r: list[PodExecResult] = run_cql(state, 'describe keyspaces', show_out=False, on_any=on_any)
20
17
  if not r:
21
18
  log2('No pod is available')
22
19
  return []
23
20
 
24
- return parse_cql_desc_keyspaces(r[0].stdout)
21
+ return parse_cql_desc_keyspaces(r.stdout if state.pod else r[0].stdout)
25
22
 
26
23
  def table_names(state: ReplState):
27
24
  return [f'{k}.{t}' for k, ts in tables(state, on_any=True).items() for t in ts]
adam/commands/cqlsh.py CHANGED
@@ -56,11 +56,17 @@ class Cqlsh(Command):
56
56
  if state.sts or state.pod:
57
57
  ts = table_names(state)
58
58
  return {Cqlsh.COMMAND: None} | {
59
- 'delete': {'from': {t: {'where': None} for t in ts}},
59
+ 'delete': {'from': {t: {'where': {'id': {'=': None}}} for t in ts}},
60
60
  'insert': {'into': {t: {'values': None} for t in ts}},
61
- 'select': {'*': {'from': {t: {'limit': {'1': None}, 'where': None} for t in ts}}},
61
+ 'select': {'*': {'from': {t: {
62
+ 'limit': {'1': None},
63
+ 'where': {'id': {'=': None}}
64
+ } for t in ts}}},
62
65
  'update': {t: {'set': None} for t in ts},
63
- 'describe': {'keyspaces': None, 'table': {t: None for t in ts}, 'tables': None},
66
+ 'describe': {
67
+ 'keyspaces': None,
68
+ 'table': {t: None for t in ts},
69
+ 'tables': None},
64
70
  }
65
71
 
66
72
  return {}
@@ -5,7 +5,6 @@ from adam.commands.deploy.deploy_pg_agent import DeployPgAgent
5
5
  from adam.commands.deploy.deploy_pod import DeployPod
6
6
  from .deploy_frontend import DeployFrontend
7
7
  from adam.repl_state import ReplState
8
- from adam.utils import lines_to_tabular, log, log2
9
8
 
10
9
  class Deploy(Command):
11
10
  COMMAND = 'deploy'
@@ -27,18 +26,7 @@ class Deploy(Command):
27
26
  if not(args := self.args(cmd)):
28
27
  return super().run(cmd, state)
29
28
 
30
- state, args = self.apply_state(args, state)
31
-
32
- if state.in_repl:
33
- log(lines_to_tabular([c.help(ReplState()) for c in Deploy.cmd_list()], separator='\t'))
34
-
35
- return 'command-missing'
36
- else:
37
- # head with the Chain of Responsibility pattern
38
- cmds = Command.chain(Deploy.cmd_list())
39
- if not cmds.run(cmd, state):
40
- log2('* Command is missing.')
41
- Command.display_help()
29
+ return super().intermediate_run(cmd, state, args, Deploy.cmd_list())
42
30
 
43
31
  def cmd_list():
44
32
  return [DeployFrontend(), DeployPod(), DeployPgAgent()]
@@ -49,13 +37,6 @@ class Deploy(Command):
49
37
 
50
38
  return {}
51
39
 
52
- def help(self, _: ReplState):
53
- return None
54
-
55
40
  class DeployCommandHelper(click.Command):
56
41
  def get_help(self, ctx: click.Context):
57
- log(super().get_help(ctx))
58
- log()
59
- log('Sub-Commands:')
60
-
61
- log(lines_to_tabular([c.help(ReplState()).replace(f'{Deploy.COMMAND} ', ' ', 1) for c in Deploy.cmd_list()], separator='\t'))
42
+ Command.intermediate_help(super().get_help(ctx), Deploy.COMMAND, Deploy.cmd_list())
@@ -5,7 +5,6 @@ from adam.commands.deploy.undeploy_frontend import UndeployFrontend
5
5
  from adam.commands.deploy.undeploy_pg_agent import UndeployPgAgent
6
6
  from adam.commands.deploy.undeploy_pod import UndeployPod
7
7
  from adam.repl_state import ReplState
8
- from adam.utils import lines_to_tabular, log, log2
9
8
 
10
9
  class Undeploy(Command):
11
10
  COMMAND = 'undeploy'
@@ -27,18 +26,7 @@ class Undeploy(Command):
27
26
  if not(args := self.args(cmd)):
28
27
  return super().run(cmd, state)
29
28
 
30
- state, args = self.apply_state(args, state)
31
-
32
- if state.in_repl:
33
- log(lines_to_tabular([c.help(ReplState()) for c in Undeploy.cmd_list()], separator='\t'))
34
-
35
- return 'command-missing'
36
- else:
37
- # head with the Chain of Responsibility pattern
38
- cmds = Command.chain(Undeploy.cmd_list())
39
- if not cmds.run(cmd, state):
40
- log2('* Command is missing.')
41
- Command.display_help()
29
+ return super().intermediate_run(cmd, state, args, Undeploy.cmd_list())
42
30
 
43
31
  def cmd_list():
44
32
  return [UndeployFrontend(), UndeployPod(), UndeployPgAgent()]
@@ -49,13 +37,6 @@ class Undeploy(Command):
49
37
 
50
38
  return {}
51
39
 
52
- def help(self, _: ReplState):
53
- return None
54
-
55
40
  class UndeployCommandHelper(click.Command):
56
41
  def get_help(self, ctx: click.Context):
57
- log(super().get_help(ctx))
58
- log()
59
- log('Sub-Commands:')
60
-
61
- log(lines_to_tabular([c.help(ReplState()).replace(f'{Undeploy.COMMAND} ', ' ', 1) for c in Undeploy.cmd_list()], separator='\t'))
42
+ Command.intermediate_help(super().get_help(ctx), Undeploy.COMMAND, Undeploy.cmd_list())
@@ -0,0 +1,46 @@
1
+ import click
2
+
3
+ from adam.commands.command import Command
4
+ from adam.commands.describe.describe_keyspace import DescribeKeyspace
5
+ from adam.commands.describe.describe_keyspaces import DescribeKeyspaces
6
+ from adam.commands.describe.describe_table import DescribeTable
7
+ from adam.commands.describe.describe_tables import DescribeTables
8
+ from adam.repl_state import ReplState, RequiredState
9
+
10
+ class Describe(Command):
11
+ COMMAND = 'describe'
12
+ reaper_login = None
13
+
14
+ # the singleton pattern
15
+ def __new__(cls, *args, **kwargs):
16
+ if not hasattr(cls, 'instance'): cls.instance = super(Describe, cls).__new__(cls)
17
+
18
+ return cls.instance
19
+
20
+ def __init__(self, successor: Command=None):
21
+ super().__init__(successor)
22
+
23
+ def required(self):
24
+ return RequiredState.CLUSTER
25
+
26
+ def command(self):
27
+ return Describe.COMMAND
28
+
29
+ def run(self, cmd: str, state: ReplState):
30
+ if not(args := self.args(cmd)):
31
+ return super().run(cmd, state)
32
+
33
+ return super().intermediate_run(cmd, state, args, Describe.cmd_list())
34
+
35
+ def cmd_list():
36
+ return [DescribeKeyspace(), DescribeKeyspaces(), DescribeTable(), DescribeTables()]
37
+
38
+ def completion(self, state: ReplState):
39
+ if state.sts:
40
+ return super().completion(state)
41
+
42
+ return {}
43
+
44
+ class DescribeCommandHelper(click.Command):
45
+ def get_help(self, ctx: click.Context):
46
+ Command.intermediate_help(super().get_help(ctx), Describe.COMMAND, Describe.cmd_list(), show_cluster_help=True)
@@ -52,7 +52,7 @@ class DescribeKeyspace(Command):
52
52
 
53
53
  def completion(self, state: ReplState) -> dict[str, any]:
54
54
  if state.sts:
55
- return super().completion(state, {ks: {'--all-nodes': None} for ks in keyspaces(state.sts, state.namespace)})
55
+ return super().completion(state, {ks: {'--all-nodes': None} for ks in keyspaces(state, on_any=True)})
56
56
 
57
57
  return {}
58
58
 
@@ -1,5 +1,5 @@
1
1
  from adam.commands.command import Command
2
- from adam.commands.cql_utils import keyspaces, run_cql
2
+ from adam.commands.cql_utils import run_cql
3
3
  from adam.pod_exec_result import PodExecResult
4
4
  from adam.repl_state import ReplState, RequiredState
5
5
  from adam.utils import log2
@@ -1,5 +1,5 @@
1
1
  from adam.commands.command import Command
2
- from adam.commands.cql_utils import keyspaces, run_cql, table_names, tables
2
+ from adam.commands.cql_utils import run_cql, table_names
3
3
  from adam.pod_exec_result import PodExecResult
4
4
  from adam.repl_state import ReplState, RequiredState
5
5
  from adam.utils import log2
@@ -1,5 +1,5 @@
1
1
  from adam.commands.command import Command
2
- from adam.commands.cql_utils import keyspaces, run_cql, table_names, tables
2
+ from adam.commands.cql_utils import run_cql
3
3
  from adam.pod_exec_result import PodExecResult
4
4
  from adam.repl_state import ReplState, RequiredState
5
5
  from adam.utils import log2
@@ -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 .medusa_backup import MedusaBackup
6
5
  from .medusa_restore import MedusaRestore
7
6
  from .medusa_show_backupjobs import MedusaShowBackupJobs
8
7
  from .medusa_show_restorejobs import MedusaShowRestoreJobs
9
8
  from adam.repl_state import ReplState, RequiredState
10
- from adam.utils import lines_to_tabular, log, log2
11
9
 
12
10
  class Medusa(Command):
13
11
  COMMAND = 'medusa'
@@ -31,20 +29,7 @@ class Medusa(Command):
31
29
  if not(args := self.args(cmd)):
32
30
  return super().run(cmd, state)
33
31
 
34
- state, args = self.apply_state(args, state)
35
- if not self.validate_state(state):
36
- return state
37
-
38
- if state.in_repl:
39
- log(lines_to_tabular([c.help(ReplState()) for c in Medusa.cmd_list()], separator=':'))
40
-
41
- return 'command-missing'
42
- else:
43
- # head with the Chain of Responsibility pattern
44
- cmds = Command.chain(Medusa.cmd_list())
45
- if not cmds.run(cmd, state):
46
- log2('* Command is missing.')
47
- Command.display_help()
32
+ return super().intermediate_run(cmd, state, args, Medusa.cmd_list())
48
33
 
49
34
  def cmd_list():
50
35
  return [MedusaBackup(), MedusaRestore(), MedusaShowBackupJobs(), MedusaShowRestoreJobs()]
@@ -55,15 +40,6 @@ class Medusa(Command):
55
40
 
56
41
  return {}
57
42
 
58
- def help(self, _: ReplState):
59
- return None
60
-
61
43
  class MedusaCommandHelper(click.Command):
62
44
  def get_help(self, ctx: click.Context):
63
- log(super().get_help(ctx))
64
- log()
65
- log('Sub-Commands:')
66
-
67
- log(lines_to_tabular([c.help(ReplState()).replace(f'{Medusa.COMMAND} ', ' ', 1) for c in Medusa.cmd_list()], separator=':'))
68
- log()
69
- ClusterCommandHelper.cluster_help()
45
+ Command.intermediate_help(super().get_help(ctx), Medusa.COMMAND, Medusa.cmd_list(), show_cluster_help=True)
@@ -49,4 +49,4 @@ class MedusaShowBackupJobs(Command):
49
49
  return {}
50
50
 
51
51
  def help(self, _: ReplState):
52
- return f'{MedusaShowBackupJobs.COMMAND}\t show backups'
52
+ return f'{MedusaShowBackupJobs.COMMAND}\t show Medusa backups'
@@ -49,4 +49,4 @@ class MedusaShowRestoreJobs(Command):
49
49
  return {}
50
50
 
51
51
  def help(self, _: ReplState):
52
- return f'{MedusaShowRestoreJobs.COMMAND}\t show restores'
52
+ return f'{MedusaShowRestoreJobs.COMMAND}\t show Medusa restores'
@@ -1,12 +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 .postgres_ls import PostgresLs
6
5
  from .postgres_preview import PostgresPreview
7
6
  from .postgres_session import PostgresSession
8
7
  from adam.repl_state import ReplState
9
- from adam.utils import lines_to_tabular, log, log2
8
+ from adam.utils import log, log2
10
9
 
11
10
  class Postgres(Command):
12
11
  COMMAND = 'pg'
@@ -100,13 +99,7 @@ class Postgres(Command):
100
99
 
101
100
  class PostgresCommandHelper(click.Command):
102
101
  def get_help(self, ctx: click.Context):
103
- log(super().get_help(ctx))
104
- log()
105
- log('Sub-Commands:')
106
-
107
- log(lines_to_tabular([c.help(ReplState()).replace(f'{Postgres.COMMAND} ', ' ', 1) for c in Postgres.cmd_list()], separator='\t'))
108
- log()
109
- ClusterCommandHelper.cluster_help()
102
+ Command.intermediate_help(super().get_help(ctx), Postgres.COMMAND, Postgres.cmd_list(), show_cluster_help=True)
110
103
  log('PG-Name: Kubernetes secret for Postgres credentials')
111
104
  log(' e.g. stgawsscpsr-c3-c3-k8spg-cs-001')
112
105
  log('Database: Postgres database name within a host')
@@ -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,12 @@ 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
- if not self.validate_state(state):
44
- return state
45
-
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()
40
+ return super().intermediate_run(cmd, state, args, Reaper.cmd_list())
56
41
 
57
42
  def cmd_list():
58
43
  return [ReaperSchedules(), ReaperScheduleStop(), ReaperScheduleActivate(), ReaperScheduleStart(),
59
- ReaperForwardStop(), ReaperForward(), ReaperRunAbort(), ReaperRunsAbort(), ReaperRestart(), ReaperRuns(), ReaperStatus()]
44
+ ReaperForwardStop(), ReaperForward(), ReaperRunAbort(), ReaperRunsAbort(), ReaperRestart(),
45
+ ReaperRuns(), ReaperStatus()]
60
46
 
61
47
  def completion(self, state: ReplState):
62
48
  if state.sts:
@@ -64,15 +50,6 @@ class Reaper(Command):
64
50
 
65
51
  return {}
66
52
 
67
- def help(self, _: ReplState):
68
- return None
69
-
70
53
  class ReaperCommandHelper(click.Command):
71
54
  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()
55
+ Command.intermediate_help(super().get_help(ctx), Reaper.COMMAND, Reaper.cmd_list(), show_cluster_help=True)
@@ -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'
@@ -31,20 +29,7 @@ class Repair(Command):
31
29
  if not(args := self.args(cmd)):
32
30
  return super().run(cmd, state)
33
31
 
34
- state, args = self.apply_state(args, state)
35
- if not self.validate_state(state):
36
- return state
37
-
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()
32
+ return super().intermediate_run(cmd, state, args, Repair.cmd_list())
48
33
 
49
34
  def cmd_list():
50
35
  return [RepairRun(), RepairScan(), RepairStop(), RepairLog()]
@@ -54,15 +39,6 @@ class Repair(Command):
54
39
  return super().completion(state)
55
40
  return {}
56
41
 
57
- def help(self, _: ReplState):
58
- return None
59
-
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,7 +1,8 @@
1
1
  import click
2
2
 
3
3
  from adam.commands.command import Command
4
- from adam.commands.command_helpers import ClusterCommandHelper
4
+ from adam.commands.medusa.medusa_show_backupjobs import MedusaShowBackupJobs
5
+ from adam.commands.medusa.medusa_show_restorejobs import MedusaShowRestoreJobs
5
6
  from adam.commands.show.show_app_actions import ShowAppActions
6
7
  from adam.commands.show.show_app_queues import ShowAppQueues
7
8
  from adam.commands.show.show_login import ShowLogin
@@ -15,7 +16,6 @@ from .show_repairs import ShowRepairs
15
16
  from .show_storage import ShowStorage
16
17
  from .show_adam import ShowAdam
17
18
  from adam.repl_state import ReplState
18
- from adam.utils import lines_to_tabular, log, log2
19
19
 
20
20
  class Show(Command):
21
21
  COMMAND = 'show'
@@ -36,35 +36,16 @@ class Show(Command):
36
36
  if not(args := self.args(cmd)):
37
37
  return super().run(cmd, state)
38
38
 
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()
39
+ return super().intermediate_run(cmd, state, args, Show.cmd_list())
51
40
 
52
41
  def cmd_list():
53
- return [ShowAppActions(), ShowAppId(), ShowAppQueues(), ShowLogin(), ShowKubectlCommands(), ShowParams(), ShowProcesses(), ShowRepairs(),
54
- ShowStorage(), ShowAdam(), ShowCassandraStatus(), ShowCassandraVersion()]
42
+ return [ShowAppActions(), ShowAppId(), ShowAppQueues(), ShowLogin(), ShowKubectlCommands(),
43
+ ShowParams(), ShowProcesses(), ShowRepairs(), ShowStorage(), ShowAdam(),
44
+ ShowCassandraStatus(), ShowCassandraVersion(), MedusaShowRestoreJobs(), MedusaShowBackupJobs()]
55
45
 
56
46
  def completion(self, state: ReplState):
57
47
  return super().completion(state)
58
48
 
59
- def help(self, _: ReplState):
60
- return f"{Show.COMMAND}\t show kubectl commands"
61
-
62
49
  class ShowCommandHelper(click.Command):
63
50
  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()
51
+ Command.intermediate_help(super().get_help(ctx), Show.COMMAND, Show.cmd_list(), show_cluster_help=True)
adam/repl_commands.py CHANGED
@@ -11,6 +11,7 @@ from adam.commands.deploy.undeploy import Undeploy
11
11
  from adam.commands.deploy.undeploy_frontend import UndeployFrontend
12
12
  from adam.commands.deploy.undeploy_pg_agent import UndeployPgAgent
13
13
  from adam.commands.deploy.undeploy_pod import UndeployPod
14
+ from adam.commands.describe.describe import Describe
14
15
  from adam.commands.describe.describe_keyspace import DescribeKeyspace
15
16
  from adam.commands.describe.describe_keyspaces import DescribeKeyspaces
16
17
  from adam.commands.describe.describe_table import DescribeTable
@@ -58,7 +59,7 @@ class ReplCommands:
58
59
  cmds: list[Command] = ReplCommands.navigation() + ReplCommands.cassandra_check() + ReplCommands.cassandra_ops() + \
59
60
  ReplCommands.tools() + ReplCommands.app() + ReplCommands.exit()
60
61
 
61
- intermediate_cmds: list[Command] = [App(), Reaper(), Repair(), Deploy(), Show(), Undeploy()]
62
+ intermediate_cmds: list[Command] = [App(), Reaper(), Repair(), Deploy(), Describe(), Show(), Undeploy()]
62
63
  ic = [c.command() for c in intermediate_cmds]
63
64
  # 1. dedup commands
64
65
  deduped = []
@@ -79,7 +80,7 @@ class ReplCommands:
79
80
  GetParam(), SetParam(), ShowParams(), ShowKubectlCommands(), ShowLogin(), ShowAdam()]
80
81
 
81
82
  def cassandra_check() -> list[Command]:
82
- return [DescribeKeyspace(), DescribeKeyspaces(), DescribeTable(), DescribeTables(), ShowCassandraStatus(),
83
+ return Describe.cmd_list() + [ShowCassandraStatus(),
83
84
  ShowCassandraVersion(), ShowRepairs(), ShowStorage(), ShowProcesses(), Check(), Issues(), NodeTool(), Report()]
84
85
 
85
86
  def cassandra_ops() -> list[Command]:
adam/version.py CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
- __version__ = "2.0.32" #: the working version
4
+ __version__ = "2.0.34" #: the working version
5
5
  __release__ = "1.0.0" #: the release version
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kaqing
3
- Version: 2.0.32
3
+ Version: 2.0.34
4
4
  Summary: UNKNOWN
5
5
  Home-page: UNKNOWN
6
6
  License: UNKNOWN
@@ -1,7 +1,7 @@
1
1
  adam/__init__.py,sha256=oVw1FNd9HZPJ7wm6BNn5ybyNGJLjJ8kopMeBiwgMaOI,59
2
2
  adam/app_session.py,sha256=Klypm4JYHOlovaRCHAZ2P_Mj_nheMlcQgX403R0TJGk,6969
3
3
  adam/apps.py,sha256=UTpUJBAMRFvR8kJZwileGC0UmPvsOjJ_AgvWoGmnIFI,6701
4
- adam/batch.py,sha256=o82yYDgyoJw1t87QyAfn9jGqIcWX23ehRI21U4JUTv8,23221
4
+ adam/batch.py,sha256=zUVW9PeOIybXY8sJksJfOlEEkeikBsu5PrukAhnGcgc,24503
5
5
  adam/cli.py,sha256=03pIZdomAu7IL-GSP6Eun_PKwwISShRAmfx6eVRPGC0,458
6
6
  adam/cli_group.py,sha256=W3zy1BghCtVcEXizq8fBH-93ZRVVwgAyGPzy0sHno1Y,593
7
7
  adam/config.py,sha256=5v8tf98SPnb9Mmn9EzxV1_EbjVrHo1ElkvyHpFMfbzk,2783
@@ -10,11 +10,11 @@ adam/embedded_params.py,sha256=_9tBKpkSzBfzm-s3tUgZs8DcSVBnPA1iumG0ZRCbZIs,4586
10
10
  adam/log.py,sha256=gg5DK52wLPc9cjykeh0WFHyAk1qI3HEpGaAK8W2dzXY,1146
11
11
  adam/pod_exec_result.py,sha256=nq0xnCNOpUGBSijGF0H-YNrwBc9vUQs4DkvLMIFS5LQ,951
12
12
  adam/repl.py,sha256=Yx7paOgzj-KCX8q46nsr9LQJAmoz-Gvnzo7dH9rwh_0,7277
13
- adam/repl_commands.py,sha256=Qg5b83NOoVigHB9b5wThhpUUTb-Gxy1b4IkBXQqQJa4,4708
13
+ adam/repl_commands.py,sha256=aH7xxbsQGrpL9Ozk9QF54iToK6wbDT3Pu9rMyw9sDBY,4719
14
14
  adam/repl_session.py,sha256=uIogcvWBh7wd8QQ-p_JgLsyJ8YJgINw5vOd6JIsd7Vo,472
15
15
  adam/repl_state.py,sha256=591d7gV6uQSFtm7IWdlIYAHjfAzs9bdvIkwlIAeKddE,7540
16
16
  adam/utils.py,sha256=2DoWsrcaioFFH0-RjT30qelVRPUJqCGTfz_ucfE7F8g,7406
17
- adam/version.py,sha256=qtphQaScnn_fuEjBWxm_MIQUMnw5QrS97RmQmJfBlrQ,139
17
+ adam/version.py,sha256=0DrCK4Qgn-81E2AOhv1X8dSDYX-GZcodTWUjebMSSKM,139
18
18
  adam/checks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  adam/checks/check.py,sha256=Qopr3huYcMu2bzQgb99dEUYjFzkjKHRI76S6KA9b9Rk,702
20
20
  adam/checks/check_context.py,sha256=FEHkQ32jY1EDopQ2uYWqy9v7aEEX1orLpJWhopwAlh4,402
@@ -54,12 +54,12 @@ adam/commands/bash.py,sha256=1O9cCl9JHQdttqNAgdB44rO0NjCqHzHv4psAEQMJcjw,2714
54
54
  adam/commands/cd.py,sha256=XEoiMhbJgA2KVKwhHFcs5BRAlf9qpgbAh6IImpKOtHI,4486
55
55
  adam/commands/check.py,sha256=853FPfgTMGxQXI_5UaPAtzaSWB_BvEVm48EkJhsHe4w,2181
56
56
  adam/commands/cli_commands.py,sha256=PEEyrG9yz7RAEZwHbbuFpyE3fVi8vrIWbr0d1H0Gp9o,3620
57
- adam/commands/command.py,sha256=lULNtaRJ-S9hTBpJY2rjWwZaQi_S4zGqZrsd89M_wik,2879
57
+ adam/commands/command.py,sha256=Xq5-nWLcWDq5w9nw-U78RlbwTqHeXchydBcb5rQ7Cj8,3930
58
58
  adam/commands/command_helpers.py,sha256=leOJJK1UXczNTJHN9TGMCbIpUpmpreULvQ-TvnsYS7w,1134
59
59
  adam/commands/commands_utils.py,sha256=ShUcxtDSd9B3NM0GDj3NBvKdmjCGY8qXgeUJpzNF63E,3122
60
60
  adam/commands/cp.py,sha256=dyQViRDPNqsKRkxPb7WyEVIBNw7YB6IfYa2q3VtfzyA,3107
61
- adam/commands/cql_utils.py,sha256=jEVFn1_1LjwuJDt7xrL5YDnl4dPXUpAkLUf0XeSSTnU,4028
62
- adam/commands/cqlsh.py,sha256=4dcemAdCQvpUAkLTpkOEhrbRHimovxSAG8eJ0i4RQM8,2939
61
+ adam/commands/cql_utils.py,sha256=LGRwhGf1bCZ0SS0F9a2dXGcCbcKpoR10wuQyaXuAm-A,3893
62
+ adam/commands/cqlsh.py,sha256=PknA1I13E4L6leSq6TC3fsyJw_bugo6376q0FE0Ufz0,3088
63
63
  adam/commands/devices.py,sha256=_f8j6aQzTL8_pFlWYawRuG2Ju1zPjYSPcRIlLnZng10,2397
64
64
  adam/commands/exit.py,sha256=5MWUAmzYBlsrp0CoiTDB13SUkX9Ya18UlGeOIPia6TA,798
65
65
  adam/commands/help.py,sha256=Ey3R1X8w_CMhdADI0t8dSQ28euhDHheJm7NermiGni4,1645
@@ -82,33 +82,34 @@ adam/commands/deploy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
82
82
  adam/commands/deploy/code_start.py,sha256=-iH8HThTNM83IfBxT_LqTByuHVatV9d-Il4OYOfrwLI,1370
83
83
  adam/commands/deploy/code_stop.py,sha256=ch7ZMgosvTHsGaIcDwQY5XYh_5HYrUjBkZFOI-d2gOU,1696
84
84
  adam/commands/deploy/code_utils.py,sha256=5Gp4U8HzKpPkbkHDU7whlvGOK-wWaAbCIIGzVoN9hio,3296
85
- adam/commands/deploy/deploy.py,sha256=Yy333-bEyTkB0-U5Qb4SXh_QGVUFngrPy99ROPWzn1Q,1874
85
+ adam/commands/deploy/deploy.py,sha256=lDuOb460Wm8RkkX811SPGYv59wP0uc9LgCsVG-71bDI,1254
86
86
  adam/commands/deploy/deploy_frontend.py,sha256=S3SvJD4JZQ9kDOOP_mrTnZFDl54AHhio5xxNgIUBZVk,1704
87
87
  adam/commands/deploy/deploy_pg_agent.py,sha256=VlOplID4MBABzuXeueyjKOTZjlQlQWLwvLSxpii4FHU,1203
88
88
  adam/commands/deploy/deploy_pod.py,sha256=YamltqBcxDpM3Bqhq-pFHxzZDxmEXGmkP5HXlJjRs8o,4663
89
89
  adam/commands/deploy/deploy_utils.py,sha256=daJhX2kCg5aGt4ZLQdz5AbR-AS7q2y-bZNVxHzP708c,1524
90
- adam/commands/deploy/undeploy.py,sha256=HDPFSYTOAmSc11OmgKBxq64S4lqyEC8zL1q69CVDlLQ,1930
90
+ adam/commands/deploy/undeploy.py,sha256=hLrkliNVL7YBQ9sSpJgGeSZiSx7cqkWlv6Y_T3NqR5Y,1308
91
91
  adam/commands/deploy/undeploy_frontend.py,sha256=gHekPn7l19JgVbhneKpQ7ModNoDFmzWRMyQv9v4FBxo,1261
92
92
  adam/commands/deploy/undeploy_pg_agent.py,sha256=RYME8no1FT94WpVg-HXDGL1NmLlpE1I9R4htitjaxpo,1319
93
93
  adam/commands/deploy/undeploy_pod.py,sha256=hTcL8cAh7xYPcSm9sgiVFCxPh3SskefBfTmla310oUA,1905
94
94
  adam/commands/describe/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
95
- adam/commands/describe/describe_keyspace.py,sha256=9HN6_bJSmfgNl16rYsWkCD7Q3gHhb3lcpUD_Vjosm70,1935
96
- adam/commands/describe/describe_keyspaces.py,sha256=uXiVgpJlJz-8Q_rB2u3LWQixdECw6VWinfN70a5c3WQ,1585
97
- adam/commands/describe/describe_table.py,sha256=8jBiTqvZy0xzZdVTSzW6co6Ku-_seLqkdmrA3QXFgSQ,1902
98
- adam/commands/describe/describe_tables.py,sha256=RbbDhbyNjB1NyHP5LREAMPpXlgd1zmPlFQIp6jUVCdI,1585
95
+ adam/commands/describe/describe.py,sha256=isRQ1z3lrFtaSkeWPndLGvaIbZivlBxI8D1X8ywNe1E,1510
96
+ adam/commands/describe/describe_keyspace.py,sha256=CdgDBMlOngp_P5dK4QbqmqEGVZfhrRcFyISSrXoXoa4,1927
97
+ adam/commands/describe/describe_keyspaces.py,sha256=O6ZY3q7H3-fNDEHf_qjgfTQmdYPXExAZh1M1COPJbnM,1574
98
+ adam/commands/describe/describe_table.py,sha256=HL9Bufqj60R7GqqfhMvNgb6-eGPpOOf_okHoNT-2B9s,1883
99
+ adam/commands/describe/describe_tables.py,sha256=2EtkLavSTNy-JHtegR9qUoVYs2NPmAz1Tq-yc-hKzZY,1553
99
100
  adam/commands/medusa/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
100
- adam/commands/medusa/medusa.py,sha256=Y_yyOZRb6u45wfTVBRp3kuklyYDTSlaAJQdAiymP_8M,2185
101
+ adam/commands/medusa/medusa.py,sha256=KNFjStvilIuOJt3wTtcWmKvdm8FdCnrDY2ltEWbratk,1402
101
102
  adam/commands/medusa/medusa_backup.py,sha256=j4DTVWFT-4rzs4gG_pBvjE-JuPsVCJIsnyQjIzJ4EbA,1801
102
103
  adam/commands/medusa/medusa_restore.py,sha256=MU47bmozrjfGJ6GVkj_OVgLH6Uz_fGh03MdLR4ZDKHE,3308
103
- adam/commands/medusa/medusa_show_backupjobs.py,sha256=anDaXLWcDnXaw07-6bgZwpcjVibEVkueCS1vE08TnH4,1749
104
- adam/commands/medusa/medusa_show_restorejobs.py,sha256=vEYlsM28XjeodeH1E3826sliux2TscSyEY4s7RU4r3I,1644
104
+ adam/commands/medusa/medusa_show_backupjobs.py,sha256=QekHpKezVJdgfa9hOxfgyx-y4D08tmHzyu_AAa8QPR0,1756
105
+ adam/commands/medusa/medusa_show_restorejobs.py,sha256=wgPonSmC6buDIp3k3WUY-Yu2MyP1xyE3Q_XhvAwpnx4,1651
105
106
  adam/commands/postgres/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
106
- adam/commands/postgres/postgres.py,sha256=ugnQulU6h3pSySYRwU801raxqsC8W5DcFLSbqnk7SPo,3597
107
+ adam/commands/postgres/postgres.py,sha256=Q63WomZGXj10q94gG9J9hN6n_ybokMWhf9jBkmtgGb8,3360
107
108
  adam/commands/postgres/postgres_ls.py,sha256=HwZTgwGKXUqHX33S8aQPF6FqCrLqtoz4cLyJV2SpoE0,1186
108
109
  adam/commands/postgres/postgres_preview.py,sha256=MLzdEc4mvNj6V1Q8jO5OPznXyYELJHgd35_eQgLlNIU,1274
109
110
  adam/commands/postgres/postgres_session.py,sha256=8Tb0dHyJv7KmAaLZbR3kV2fkX8MfnDtlzUobpNJjRys,9503
110
111
  adam/commands/reaper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
111
- adam/commands/reaper/reaper.py,sha256=SbxXgJ6b4wdXx5a1Fps71iEa1hmycWbArh1oC5bS83M,2677
112
+ adam/commands/reaper/reaper.py,sha256=83R0ZRitEwaYKKssfKxn3zAzLnWIP9QKd1mA6awceS8,1908
112
113
  adam/commands/reaper/reaper_forward.py,sha256=mUp409MzT91cVXGxoPfBGceaR3qZ0rVdWKGdyzPNzSA,3177
113
114
  adam/commands/reaper/reaper_forward_stop.py,sha256=mllxBGxOUkFYMvF0eaFbL5VGMVAiFuT5KY8rKWTIiOE,1384
114
115
  adam/commands/reaper/reaper_restart.py,sha256=fX_ywBBKMo_5I0h2IDb0u7NeCN0Gk6OZeaZELrKb9I4,1290
@@ -122,13 +123,13 @@ adam/commands/reaper/reaper_schedules.py,sha256=-b7eKl0wJT7zMru8qKcLqG5JF0-LfeTc
122
123
  adam/commands/reaper/reaper_session.py,sha256=Y-NYEpADhE1XJoaXQKBa8lObtoz4ny8_XB7byV-2RZ0,6650
123
124
  adam/commands/reaper/reaper_status.py,sha256=g3Uep1AVYOThAaZoFjn4bWTKHElZnCleJyYYHP9HayY,1967
124
125
  adam/commands/repair/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
125
- adam/commands/repair/repair.py,sha256=5jdKVpP03GYNPuqeGlidOcFLTwl9gIzVDbxgXtUjAjw,2100
126
+ adam/commands/repair/repair.py,sha256=Z284AKjUupQ-Uul5xDVr_ljfiXJ0VmAXsrlhLPjRp5A,1315
126
127
  adam/commands/repair/repair_log.py,sha256=c7TI9hblpqn1tn7lTxj7VkIQKdNigYIIX-nxiFRZkns,1159
127
128
  adam/commands/repair/repair_run.py,sha256=C9F86ia46rBCwkP8BFM5nw-AJ05jm4Bx9wnMnyZXR04,2598
128
129
  adam/commands/repair/repair_scan.py,sha256=m6PErrbuQgryCMm_2pbGAwQdKNQvXLahcHXFfNKoU-s,2439
129
130
  adam/commands/repair/repair_stop.py,sha256=on3jHmOwtWOL7SJlFd8ryBflzqDsxwJNwtAbhDjYUNc,1193
130
131
  adam/commands/show/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
131
- adam/commands/show/show.py,sha256=7dAsliNuDz6QNM24RoWJgKhJf_nuQTugp715vZ8hxh0,2509
132
+ adam/commands/show/show.py,sha256=rPhozvl8Yb7sBRNg_byw15jLRVLeN-mbms3wKyl78xI,1981
132
133
  adam/commands/show/show_adam.py,sha256=osuafMipN2My4O7bLdukBLsDHtTKguDfTagmgz7aZvw,1314
133
134
  adam/commands/show/show_app_actions.py,sha256=3knASTOIecvdLEJusbsGEGXVxeCpqHozbnFAEq_2pqY,1925
134
135
  adam/commands/show/show_app_id.py,sha256=-2hxOUv_Rm_j6d6PWVcHW-w-_alfGrOB4chmVQS48Bs,1384
@@ -166,8 +167,8 @@ adam/sso/idp.py,sha256=fvcwUw_URTgsO6ySaqTIw0zQT2qRO1IPSGhf6rPtybo,5804
166
167
  adam/sso/idp_login.py,sha256=QAtCUeDTVWliJy40RK_oac8Vgybr13xH8wzeBoxPaa8,1754
167
168
  adam/sso/idp_session.py,sha256=9BUHNRf70u4rVKrVY1HKPOEmOviXvkjam8WJxmXSKIM,1735
168
169
  adam/sso/sso_config.py,sha256=5N8WZgIJQBtHUy585XLRWKjpU87_v6QluyNK9E27D5s,2459
169
- kaqing-2.0.32.dist-info/METADATA,sha256=Kopbtb9YdV0spXv3HIfE6X7h3cYXu5nGR2BbWr14vuI,132
170
- kaqing-2.0.32.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
171
- kaqing-2.0.32.dist-info/entry_points.txt,sha256=SkzhuQJUWsXOzHeZ5TgQ2c3_g53UGK23zzJU_JTZOZI,39
172
- kaqing-2.0.32.dist-info/top_level.txt,sha256=8_2PZkwBb-xDcnc8a2rAbQeJhXKXskc7zTP7pSPa1fw,5
173
- kaqing-2.0.32.dist-info/RECORD,,
170
+ kaqing-2.0.34.dist-info/METADATA,sha256=dKclseXC1V5jp_JD65TwLgCdYNZiaObVfemki32hG6w,132
171
+ kaqing-2.0.34.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
172
+ kaqing-2.0.34.dist-info/entry_points.txt,sha256=SkzhuQJUWsXOzHeZ5TgQ2c3_g53UGK23zzJU_JTZOZI,39
173
+ kaqing-2.0.34.dist-info/top_level.txt,sha256=8_2PZkwBb-xDcnc8a2rAbQeJhXKXskc7zTP7pSPa1fw,5
174
+ kaqing-2.0.34.dist-info/RECORD,,