kaqing 1.77.0__py3-none-any.whl → 2.0.171__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- adam/__init__.py +1 -0
- adam/app_session.py +182 -0
- {walker → adam}/apps.py +8 -24
- {walker → adam}/batch.py +54 -97
- {walker → adam}/checks/check.py +3 -3
- {walker → adam}/checks/check_result.py +1 -1
- adam/checks/check_utils.py +65 -0
- {walker → adam}/checks/compactionstats.py +6 -6
- {walker → adam}/checks/cpu.py +14 -8
- adam/checks/cpu_metrics.py +52 -0
- {walker → adam}/checks/disk.py +6 -6
- {walker → adam}/checks/gossip.py +5 -5
- {walker → adam}/checks/memory.py +7 -7
- {walker → adam}/checks/status.py +5 -5
- {walker → adam}/cli.py +3 -3
- {walker → adam}/columns/column.py +1 -1
- adam/columns/columns.py +45 -0
- {walker → adam}/columns/compactions.py +5 -5
- {walker → adam}/columns/cpu.py +6 -4
- adam/columns/cpu_metrics.py +22 -0
- {walker → adam}/columns/dir_data.py +3 -3
- {walker → adam}/columns/dir_snapshots.py +3 -3
- {walker → adam}/columns/gossip.py +5 -5
- {walker → adam}/columns/host_id.py +3 -3
- {walker → adam}/columns/memory.py +3 -3
- {walker → adam}/columns/node_address.py +3 -3
- {walker → adam}/columns/node_load.py +3 -3
- {walker → adam}/columns/node_owns.py +3 -3
- {walker → adam}/columns/node_status.py +3 -3
- {walker → adam}/columns/node_tokens.py +3 -3
- {walker → adam}/columns/node_utils.py +2 -2
- {walker → adam}/columns/pod_name.py +2 -2
- {walker → adam}/columns/volume_cassandra.py +4 -4
- {walker → adam}/columns/volume_root.py +3 -3
- adam/commands/__init__.py +15 -0
- adam/commands/alter_tables.py +81 -0
- adam/commands/app_cmd.py +38 -0
- {walker → adam}/commands/app_ping.py +10 -16
- adam/commands/audit/audit.py +84 -0
- adam/commands/audit/audit_repair_tables.py +74 -0
- adam/commands/audit/audit_run.py +50 -0
- adam/commands/audit/show_last10.py +48 -0
- adam/commands/audit/show_slow10.py +47 -0
- adam/commands/audit/show_top10.py +45 -0
- adam/commands/audit/utils_show_top10.py +59 -0
- adam/commands/bash/__init__.py +5 -0
- adam/commands/bash/bash.py +36 -0
- adam/commands/bash/bash_completer.py +93 -0
- adam/commands/bash/utils_bash.py +16 -0
- adam/commands/cat.py +50 -0
- adam/commands/cd.py +43 -0
- adam/commands/check.py +73 -0
- {walker → adam}/commands/cli_commands.py +7 -8
- adam/commands/code.py +57 -0
- adam/commands/command.py +190 -0
- {walker → adam}/commands/command_helpers.py +1 -1
- {walker → adam}/commands/commands_utils.py +15 -25
- adam/commands/cp.py +89 -0
- adam/commands/cql/cql_completions.py +33 -0
- {walker/commands → adam/commands/cql}/cqlsh.py +20 -35
- adam/commands/cql/utils_cql.py +343 -0
- {walker/commands/frontend → adam/commands/deploy}/code_start.py +11 -14
- adam/commands/deploy/code_stop.py +40 -0
- {walker/commands/frontend → adam/commands/deploy}/code_utils.py +7 -9
- adam/commands/deploy/deploy.py +25 -0
- adam/commands/deploy/deploy_frontend.py +49 -0
- adam/commands/deploy/deploy_pg_agent.py +35 -0
- adam/commands/deploy/deploy_pod.py +108 -0
- adam/commands/deploy/deploy_utils.py +29 -0
- adam/commands/deploy/undeploy.py +25 -0
- adam/commands/deploy/undeploy_frontend.py +38 -0
- adam/commands/deploy/undeploy_pg_agent.py +39 -0
- adam/commands/deploy/undeploy_pod.py +48 -0
- adam/commands/devices/device.py +118 -0
- adam/commands/devices/device_app.py +173 -0
- adam/commands/devices/device_auit_log.py +49 -0
- adam/commands/devices/device_cass.py +185 -0
- adam/commands/devices/device_export.py +86 -0
- adam/commands/devices/device_postgres.py +144 -0
- adam/commands/devices/devices.py +25 -0
- {walker → adam}/commands/exit.py +3 -6
- adam/commands/export/clean_up_all_export_sessions.py +37 -0
- adam/commands/export/clean_up_export_sessions.py +51 -0
- adam/commands/export/drop_export_database.py +55 -0
- adam/commands/export/drop_export_databases.py +43 -0
- adam/commands/export/export.py +53 -0
- adam/commands/export/export_databases.py +170 -0
- adam/commands/export/export_handlers.py +71 -0
- adam/commands/export/export_select.py +81 -0
- adam/commands/export/export_select_x.py +54 -0
- adam/commands/export/export_use.py +52 -0
- adam/commands/export/exporter.py +352 -0
- adam/commands/export/import_session.py +40 -0
- adam/commands/export/importer.py +67 -0
- adam/commands/export/importer_athena.py +80 -0
- adam/commands/export/importer_sqlite.py +47 -0
- adam/commands/export/show_column_counts.py +54 -0
- adam/commands/export/show_export_databases.py +36 -0
- adam/commands/export/show_export_session.py +48 -0
- adam/commands/export/show_export_sessions.py +44 -0
- adam/commands/export/utils_export.py +314 -0
- {walker → adam}/commands/help.py +17 -12
- adam/commands/intermediate_command.py +49 -0
- adam/commands/issues.py +43 -0
- adam/commands/kubectl.py +38 -0
- adam/commands/login.py +70 -0
- {walker → adam}/commands/logs.py +8 -10
- adam/commands/ls.py +41 -0
- adam/commands/medusa/medusa.py +27 -0
- adam/commands/medusa/medusa_backup.py +57 -0
- adam/commands/medusa/medusa_restore.py +83 -0
- adam/commands/medusa/medusa_show_backupjobs.py +51 -0
- adam/commands/medusa/medusa_show_restorejobs.py +47 -0
- {walker → adam}/commands/nodetool.py +17 -21
- {walker → adam}/commands/param_get.py +15 -16
- adam/commands/param_set.py +43 -0
- adam/commands/postgres/postgres.py +104 -0
- adam/commands/postgres/postgres_context.py +274 -0
- {walker → adam}/commands/postgres/postgres_ls.py +7 -11
- {walker → adam}/commands/postgres/postgres_preview.py +8 -13
- adam/commands/postgres/psql_completions.py +10 -0
- adam/commands/postgres/utils_postgres.py +66 -0
- adam/commands/preview_table.py +37 -0
- adam/commands/pwd.py +47 -0
- adam/commands/reaper/reaper.py +35 -0
- adam/commands/reaper/reaper_forward.py +93 -0
- adam/commands/reaper/reaper_forward_session.py +6 -0
- {walker → adam}/commands/reaper/reaper_forward_stop.py +13 -19
- {walker → adam}/commands/reaper/reaper_restart.py +10 -17
- adam/commands/reaper/reaper_run_abort.py +46 -0
- adam/commands/reaper/reaper_runs.py +82 -0
- adam/commands/reaper/reaper_runs_abort.py +63 -0
- adam/commands/reaper/reaper_schedule_activate.py +45 -0
- adam/commands/reaper/reaper_schedule_start.py +45 -0
- adam/commands/reaper/reaper_schedule_stop.py +45 -0
- {walker → adam}/commands/reaper/reaper_schedules.py +6 -16
- {walker → adam}/commands/reaper/reaper_status.py +11 -19
- adam/commands/reaper/utils_reaper.py +196 -0
- adam/commands/repair/repair.py +26 -0
- {walker → adam}/commands/repair/repair_log.py +7 -10
- adam/commands/repair/repair_run.py +70 -0
- adam/commands/repair/repair_scan.py +71 -0
- {walker → adam}/commands/repair/repair_stop.py +8 -11
- adam/commands/report.py +61 -0
- adam/commands/restart.py +60 -0
- {walker → adam}/commands/rollout.py +25 -30
- adam/commands/shell.py +34 -0
- adam/commands/show/show.py +39 -0
- walker/commands/show/show_version.py → adam/commands/show/show_adam.py +14 -10
- adam/commands/show/show_app_actions.py +57 -0
- {walker → adam}/commands/show/show_app_id.py +12 -15
- {walker → adam}/commands/show/show_app_queues.py +9 -12
- adam/commands/show/show_cassandra_repairs.py +38 -0
- adam/commands/show/show_cassandra_status.py +124 -0
- {walker → adam}/commands/show/show_cassandra_version.py +6 -16
- adam/commands/show/show_commands.py +59 -0
- walker/commands/show/show_storage.py → adam/commands/show/show_host.py +11 -13
- adam/commands/show/show_login.py +62 -0
- {walker → adam}/commands/show/show_params.py +4 -4
- adam/commands/show/show_processes.py +51 -0
- adam/commands/show/show_storage.py +42 -0
- adam/commands/watch.py +82 -0
- {walker → adam}/config.py +10 -22
- {walker → adam}/embedded_apps.py +1 -1
- adam/embedded_params.py +2 -0
- adam/log.py +47 -0
- {walker → adam}/pod_exec_result.py +10 -2
- adam/repl.py +182 -0
- adam/repl_commands.py +124 -0
- adam/repl_state.py +458 -0
- adam/sql/__init__.py +0 -0
- adam/sql/sql_completer.py +120 -0
- adam/sql/sql_state_machine.py +618 -0
- adam/sql/term_completer.py +76 -0
- adam/sso/__init__.py +0 -0
- {walker → adam}/sso/authenticator.py +5 -1
- adam/sso/authn_ad.py +170 -0
- {walker → adam}/sso/authn_okta.py +39 -22
- adam/sso/cred_cache.py +60 -0
- adam/sso/id_token.py +23 -0
- adam/sso/idp.py +143 -0
- adam/sso/idp_login.py +50 -0
- adam/sso/idp_session.py +55 -0
- adam/sso/sso_config.py +63 -0
- adam/utils.py +679 -0
- adam/utils_app.py +98 -0
- adam/utils_athena.py +145 -0
- adam/utils_audits.py +106 -0
- adam/utils_issues.py +32 -0
- adam/utils_k8s/__init__.py +0 -0
- adam/utils_k8s/app_clusters.py +28 -0
- adam/utils_k8s/app_pods.py +33 -0
- adam/utils_k8s/cassandra_clusters.py +36 -0
- adam/utils_k8s/cassandra_nodes.py +33 -0
- adam/utils_k8s/config_maps.py +34 -0
- {walker/k8s_utils → adam/utils_k8s}/custom_resources.py +7 -2
- adam/utils_k8s/deployment.py +56 -0
- {walker/k8s_utils → adam/utils_k8s}/ingresses.py +3 -4
- {walker/k8s_utils → adam/utils_k8s}/jobs.py +3 -3
- adam/utils_k8s/k8s.py +87 -0
- {walker/k8s_utils → adam/utils_k8s}/kube_context.py +4 -4
- adam/utils_k8s/pods.py +290 -0
- {walker/k8s_utils → adam/utils_k8s}/secrets.py +8 -4
- adam/utils_k8s/service_accounts.py +170 -0
- {walker/k8s_utils → adam/utils_k8s}/services.py +3 -4
- {walker/k8s_utils → adam/utils_k8s}/statefulsets.py +6 -16
- {walker/k8s_utils → adam/utils_k8s}/volumes.py +10 -1
- adam/utils_net.py +24 -0
- adam/utils_repl/__init__.py +0 -0
- adam/utils_repl/automata_completer.py +48 -0
- adam/utils_repl/repl_completer.py +46 -0
- adam/utils_repl/state_machine.py +173 -0
- adam/utils_sqlite.py +109 -0
- adam/version.py +5 -0
- {kaqing-1.77.0.dist-info → kaqing-2.0.171.dist-info}/METADATA +1 -1
- kaqing-2.0.171.dist-info/RECORD +236 -0
- kaqing-2.0.171.dist-info/entry_points.txt +3 -0
- kaqing-2.0.171.dist-info/top_level.txt +1 -0
- kaqing-1.77.0.dist-info/RECORD +0 -159
- kaqing-1.77.0.dist-info/entry_points.txt +0 -3
- kaqing-1.77.0.dist-info/top_level.txt +0 -1
- walker/__init__.py +0 -3
- walker/app_session.py +0 -168
- walker/checks/check_utils.py +0 -97
- walker/columns/columns.py +0 -43
- walker/commands/add_user.py +0 -68
- walker/commands/app.py +0 -67
- walker/commands/bash.py +0 -87
- walker/commands/cd.py +0 -115
- walker/commands/check.py +0 -68
- walker/commands/command.py +0 -104
- walker/commands/cp.py +0 -95
- walker/commands/cql_utils.py +0 -53
- walker/commands/devices.py +0 -89
- walker/commands/frontend/code_stop.py +0 -57
- walker/commands/frontend/setup.py +0 -60
- walker/commands/frontend/setup_frontend.py +0 -58
- walker/commands/frontend/teardown.py +0 -61
- walker/commands/frontend/teardown_frontend.py +0 -42
- walker/commands/issues.py +0 -69
- walker/commands/login.py +0 -72
- walker/commands/ls.py +0 -145
- walker/commands/medusa/medusa.py +0 -69
- walker/commands/medusa/medusa_backup.py +0 -61
- walker/commands/medusa/medusa_restore.py +0 -86
- walker/commands/medusa/medusa_show_backupjobs.py +0 -52
- walker/commands/medusa/medusa_show_restorejobs.py +0 -52
- walker/commands/param_set.py +0 -44
- walker/commands/postgres/postgres.py +0 -113
- walker/commands/postgres/postgres_session.py +0 -225
- walker/commands/preview_table.py +0 -98
- walker/commands/processes.py +0 -53
- walker/commands/pwd.py +0 -64
- walker/commands/reaper/reaper.py +0 -78
- walker/commands/reaper/reaper_forward.py +0 -100
- walker/commands/reaper/reaper_run_abort.py +0 -65
- walker/commands/reaper/reaper_runs.py +0 -97
- walker/commands/reaper/reaper_runs_abort.py +0 -83
- walker/commands/reaper/reaper_schedule_activate.py +0 -64
- walker/commands/reaper/reaper_schedule_start.py +0 -64
- walker/commands/reaper/reaper_schedule_stop.py +0 -64
- walker/commands/reaper/reaper_session.py +0 -159
- walker/commands/repair/repair.py +0 -68
- walker/commands/repair/repair_run.py +0 -72
- walker/commands/repair/repair_scan.py +0 -79
- walker/commands/report.py +0 -57
- walker/commands/restart.py +0 -61
- walker/commands/show/show.py +0 -72
- walker/commands/show/show_app_actions.py +0 -53
- walker/commands/show/show_cassandra_status.py +0 -35
- walker/commands/show/show_commands.py +0 -58
- walker/commands/show/show_processes.py +0 -35
- walker/commands/show/show_repairs.py +0 -47
- walker/commands/status.py +0 -128
- walker/commands/storage.py +0 -52
- walker/commands/user_entry.py +0 -69
- walker/commands/watch.py +0 -85
- walker/embedded_params.py +0 -2
- walker/k8s_utils/cassandra_clusters.py +0 -48
- walker/k8s_utils/cassandra_nodes.py +0 -26
- walker/k8s_utils/pods.py +0 -211
- walker/repl.py +0 -165
- walker/repl_commands.py +0 -58
- walker/repl_state.py +0 -211
- walker/sso/authn_ad.py +0 -94
- walker/sso/idp.py +0 -150
- walker/sso/idp_login.py +0 -29
- walker/sso/sso_config.py +0 -45
- walker/utils.py +0 -194
- walker/version.py +0 -5
- {walker → adam}/checks/__init__.py +0 -0
- {walker → adam}/checks/check_context.py +0 -0
- {walker → adam}/checks/issue.py +0 -0
- {walker → adam}/cli_group.py +0 -0
- {walker → adam}/columns/__init__.py +0 -0
- {walker/commands → adam/commands/audit}/__init__.py +0 -0
- {walker/commands/frontend → adam/commands/cql}/__init__.py +0 -0
- {walker/commands/medusa → adam/commands/deploy}/__init__.py +0 -0
- {walker/commands/postgres → adam/commands/devices}/__init__.py +0 -0
- {walker/commands/reaper → adam/commands/export}/__init__.py +0 -0
- {walker/commands/repair → adam/commands/medusa}/__init__.py +0 -0
- {walker → adam}/commands/nodetool_commands.py +0 -0
- {walker/commands/show → adam/commands/postgres}/__init__.py +0 -0
- {walker/k8s_utils → adam/commands/reaper}/__init__.py +0 -0
- {walker/sso → adam/commands/repair}/__init__.py +0 -0
- /walker/medusa_show_restorejobs.py → /adam/commands/show/__init__.py +0 -0
- {walker → adam}/repl_session.py +0 -0
- {kaqing-1.77.0.dist-info → kaqing-2.0.171.dist-info}/WHEEL +0 -0
walker/commands/cp.py
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import click
|
|
2
|
-
import pyperclip
|
|
3
|
-
|
|
4
|
-
from walker.commands.command import Command
|
|
5
|
-
from walker.commands.command_helpers import ClusterOrPodCommandHelper
|
|
6
|
-
from walker.commands.cli_commands import CliCommands
|
|
7
|
-
from walker.repl_state import ReplState, RequiredState
|
|
8
|
-
from walker.utils import lines_to_tabular, log, log2
|
|
9
|
-
|
|
10
|
-
class ClipboardCopy(Command):
|
|
11
|
-
COMMAND = 'cp'
|
|
12
|
-
|
|
13
|
-
# the singleton pattern
|
|
14
|
-
def __new__(cls, *args, **kwargs):
|
|
15
|
-
if not hasattr(cls, 'instance'): cls.instance = super(ClipboardCopy, 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 ClipboardCopy.COMMAND
|
|
24
|
-
|
|
25
|
-
def required(self):
|
|
26
|
-
return RequiredState.CLUSTER_OR_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
|
-
state, args = self.apply_state(args, state)
|
|
33
|
-
if not self.validate_state(state):
|
|
34
|
-
return state
|
|
35
|
-
|
|
36
|
-
if len(args) < 1:
|
|
37
|
-
if state.in_repl:
|
|
38
|
-
log2('Key is required.')
|
|
39
|
-
log2()
|
|
40
|
-
log2('Keys:')
|
|
41
|
-
log2(lines_to_tabular([f'{k},{v}' for k, v in CliCommands.values(state, collapse=True).items()], separator=','))
|
|
42
|
-
else:
|
|
43
|
-
log2('* Key is missing.')
|
|
44
|
-
Command.display_help()
|
|
45
|
-
|
|
46
|
-
return 'command-missing'
|
|
47
|
-
|
|
48
|
-
key = args[0]
|
|
49
|
-
if not key in CliCommands.values(state):
|
|
50
|
-
if state.in_repl:
|
|
51
|
-
log2('Key is required.')
|
|
52
|
-
log2()
|
|
53
|
-
log2('Keys:')
|
|
54
|
-
log2(lines_to_tabular([f'{k},{v}' for k, v in CliCommands.values(state, collapse=True).items()], separator=','))
|
|
55
|
-
else:
|
|
56
|
-
log2('* Invalid key')
|
|
57
|
-
Command.display_help()
|
|
58
|
-
|
|
59
|
-
return 'command-invalid'
|
|
60
|
-
|
|
61
|
-
value = CliCommands.values(state)[key]
|
|
62
|
-
pyperclip.copy(value)
|
|
63
|
-
log2('The following line has been copied to clipboard. Use <Ctrl-V> to use it.')
|
|
64
|
-
log2(f' {value}')
|
|
65
|
-
|
|
66
|
-
return 'value-copied'
|
|
67
|
-
|
|
68
|
-
def completion(self, state: ReplState):
|
|
69
|
-
if state.sts:
|
|
70
|
-
return {ClipboardCopy.COMMAND: {key: None for key in CliCommands.values(state).keys()}}
|
|
71
|
-
|
|
72
|
-
return {}
|
|
73
|
-
|
|
74
|
-
def help(self, _: ReplState):
|
|
75
|
-
return f"{ClipboardCopy.COMMAND} <key>\t copy a value to clipboard for conveninence"
|
|
76
|
-
|
|
77
|
-
class CopyCommandHelper(click.Command):
|
|
78
|
-
def lines(self):
|
|
79
|
-
return [
|
|
80
|
-
'node-exec-?: kubectl exec command to the Cassandra pod',
|
|
81
|
-
'reaper-exec: kubectl exec command to the Reaper pod',
|
|
82
|
-
'reaper-forward: kubectl port-forward command to the Reaper pod',
|
|
83
|
-
'reaper-ui: uri to Reaper ui',
|
|
84
|
-
'reaper-username: Reaper user name',
|
|
85
|
-
'reaper-password: Reaper password',
|
|
86
|
-
]
|
|
87
|
-
|
|
88
|
-
def get_help(self, ctx: click.Context):
|
|
89
|
-
log(super().get_help(ctx))
|
|
90
|
-
log()
|
|
91
|
-
log('Keys:')
|
|
92
|
-
|
|
93
|
-
log(lines_to_tabular(self.lines(), separator=':'))
|
|
94
|
-
log()
|
|
95
|
-
ClusterOrPodCommandHelper.cluter_or_pod_help()
|
walker/commands/cql_utils.py
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import re
|
|
2
|
-
|
|
3
|
-
from walker.k8s_utils.cassandra_clusters import CassandraClusters
|
|
4
|
-
from walker.k8s_utils.cassandra_nodes import CassandraNodes
|
|
5
|
-
from walker.k8s_utils.secrets import Secrets
|
|
6
|
-
from walker.repl_state import ReplState
|
|
7
|
-
|
|
8
|
-
def run_cql(state: ReplState, cql: str, opts: list = [], show_out = False, use_single_quotes = False):
|
|
9
|
-
user, pw = Secrets.get_user_pass(state.sts if state.sts else state.pod, state.namespace, secret_path='cql.secret')
|
|
10
|
-
if use_single_quotes:
|
|
11
|
-
command = f"cqlsh -u {user} -p {pw} {' '.join(opts)} -e '{cql}'"
|
|
12
|
-
else:
|
|
13
|
-
command = f'cqlsh -u {user} -p {pw} {" ".join(opts)} -e "{cql}"'
|
|
14
|
-
|
|
15
|
-
if state.pod:
|
|
16
|
-
return CassandraNodes.exec(state.pod, state.namespace, command, show_out=show_out)
|
|
17
|
-
else:
|
|
18
|
-
return CassandraClusters.exec(state.sts, state.namespace, command, action='cql')
|
|
19
|
-
|
|
20
|
-
def parse_cql_desc_tables(out: str):
|
|
21
|
-
# Keyspace data_endpoint_auth
|
|
22
|
-
# ---------------------------
|
|
23
|
-
# "token"
|
|
24
|
-
|
|
25
|
-
# Keyspace reaper_db
|
|
26
|
-
# ------------------
|
|
27
|
-
# repair_run schema_migration
|
|
28
|
-
# repair_run_by_cluster schema_migration_leader
|
|
29
|
-
|
|
30
|
-
# Keyspace system
|
|
31
|
-
tables_by_keyspace: dict[str, list[str]] = {}
|
|
32
|
-
keyspace = None
|
|
33
|
-
state = 's0'
|
|
34
|
-
for line in out.split('\n'):
|
|
35
|
-
if state == 's0':
|
|
36
|
-
groups = re.match(r'^Keyspace (.*)$', line)
|
|
37
|
-
if groups:
|
|
38
|
-
keyspace = groups[1].strip(' \r')
|
|
39
|
-
state = 's1'
|
|
40
|
-
elif state == 's1':
|
|
41
|
-
if line.startswith('---'):
|
|
42
|
-
state = 's2'
|
|
43
|
-
elif state == 's2':
|
|
44
|
-
if not line.strip(' \r'):
|
|
45
|
-
state = 's0'
|
|
46
|
-
else:
|
|
47
|
-
for table in line.split(' '):
|
|
48
|
-
if t := table.strip(' \r'):
|
|
49
|
-
if not keyspace in tables_by_keyspace:
|
|
50
|
-
tables_by_keyspace[keyspace] = []
|
|
51
|
-
tables_by_keyspace[keyspace].append(t)
|
|
52
|
-
|
|
53
|
-
return tables_by_keyspace
|
walker/commands/devices.py
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
from walker.commands.command import Command
|
|
2
|
-
from walker.repl_state import ReplState
|
|
3
|
-
|
|
4
|
-
class DeviceCass(Command):
|
|
5
|
-
COMMAND = f'{ReplState.C}:'
|
|
6
|
-
|
|
7
|
-
# the singleton pattern
|
|
8
|
-
def __new__(cls, *args, **kwargs):
|
|
9
|
-
if not hasattr(cls, 'instance'): cls.instance = super(DeviceCass, cls).__new__(cls)
|
|
10
|
-
|
|
11
|
-
return cls.instance
|
|
12
|
-
|
|
13
|
-
def __init__(self, successor: Command=None):
|
|
14
|
-
super().__init__(successor)
|
|
15
|
-
|
|
16
|
-
def command(self):
|
|
17
|
-
return DeviceCass.COMMAND
|
|
18
|
-
|
|
19
|
-
def run(self, cmd: str, state: ReplState):
|
|
20
|
-
if not self.args(cmd):
|
|
21
|
-
return super().run(cmd, state)
|
|
22
|
-
|
|
23
|
-
state.device = ReplState.C
|
|
24
|
-
|
|
25
|
-
return state
|
|
26
|
-
|
|
27
|
-
def completion(self, state: ReplState):
|
|
28
|
-
return super().completion(state)
|
|
29
|
-
|
|
30
|
-
def help(self, _: ReplState):
|
|
31
|
-
return f'{DeviceCass.COMMAND}\t move to Cassandra Operations device'
|
|
32
|
-
|
|
33
|
-
class DevicePostgres(Command):
|
|
34
|
-
COMMAND = f'{ReplState.P}:'
|
|
35
|
-
|
|
36
|
-
# the singleton pattern
|
|
37
|
-
def __new__(cls, *args, **kwargs):
|
|
38
|
-
if not hasattr(cls, 'instance'): cls.instance = super(DevicePostgres, cls).__new__(cls)
|
|
39
|
-
|
|
40
|
-
return cls.instance
|
|
41
|
-
|
|
42
|
-
def __init__(self, successor: Command=None):
|
|
43
|
-
super().__init__(successor)
|
|
44
|
-
|
|
45
|
-
def command(self):
|
|
46
|
-
return DevicePostgres.COMMAND
|
|
47
|
-
|
|
48
|
-
def run(self, cmd: str, state: ReplState):
|
|
49
|
-
if not self.args(cmd):
|
|
50
|
-
return super().run(cmd, state)
|
|
51
|
-
|
|
52
|
-
state.device = ReplState.P
|
|
53
|
-
|
|
54
|
-
return state
|
|
55
|
-
|
|
56
|
-
def completion(self, state: ReplState):
|
|
57
|
-
return super().completion(state)
|
|
58
|
-
|
|
59
|
-
def help(self, _: ReplState):
|
|
60
|
-
return f'{DevicePostgres.COMMAND}\t move to Postgres Operations device'
|
|
61
|
-
|
|
62
|
-
class DeviceApp(Command):
|
|
63
|
-
COMMAND = f'{ReplState.A}:'
|
|
64
|
-
|
|
65
|
-
# the singleton pattern
|
|
66
|
-
def __new__(cls, *args, **kwargs):
|
|
67
|
-
if not hasattr(cls, 'instance'): cls.instance = super(DeviceApp, cls).__new__(cls)
|
|
68
|
-
|
|
69
|
-
return cls.instance
|
|
70
|
-
|
|
71
|
-
def __init__(self, successor: Command=None):
|
|
72
|
-
super().__init__(successor)
|
|
73
|
-
|
|
74
|
-
def command(self):
|
|
75
|
-
return DeviceApp.COMMAND
|
|
76
|
-
|
|
77
|
-
def run(self, cmd: str, state: ReplState):
|
|
78
|
-
if not self.args(cmd):
|
|
79
|
-
return super().run(cmd, state)
|
|
80
|
-
|
|
81
|
-
state.device = ReplState.A
|
|
82
|
-
|
|
83
|
-
return state
|
|
84
|
-
|
|
85
|
-
def completion(self, state: ReplState):
|
|
86
|
-
return super().completion(state)
|
|
87
|
-
|
|
88
|
-
def help(self, _: ReplState):
|
|
89
|
-
return f'{DeviceApp.COMMAND}\t move to App Operations device'
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
from walker.commands.command import Command
|
|
2
|
-
from walker.commands.frontend.code_utils import stop_user_codes
|
|
3
|
-
from walker.repl_state import ReplState, RequiredState
|
|
4
|
-
|
|
5
|
-
class CodeStop(Command):
|
|
6
|
-
COMMAND = 'code stop'
|
|
7
|
-
|
|
8
|
-
# the singleton pattern
|
|
9
|
-
def __new__(cls, *args, **kwargs):
|
|
10
|
-
if not hasattr(cls, 'instance'): cls.instance = super(CodeStop, cls).__new__(cls)
|
|
11
|
-
|
|
12
|
-
return cls.instance
|
|
13
|
-
|
|
14
|
-
def __init__(self, successor: Command=None):
|
|
15
|
-
super().__init__(successor)
|
|
16
|
-
|
|
17
|
-
def command(self):
|
|
18
|
-
return CodeStop.COMMAND
|
|
19
|
-
|
|
20
|
-
def required(self):
|
|
21
|
-
return RequiredState.NAMESPACE
|
|
22
|
-
|
|
23
|
-
def run(self, cmd: str, state: ReplState):
|
|
24
|
-
if not(args := self.args(cmd)):
|
|
25
|
-
return super().run(cmd, state)
|
|
26
|
-
|
|
27
|
-
state, args = self.apply_state(args, state)
|
|
28
|
-
if not self.validate_state(state):
|
|
29
|
-
return state
|
|
30
|
-
|
|
31
|
-
_, dry = Command.extract_options(args, '--dry')
|
|
32
|
-
stop_user_codes(state.namespace, dry)
|
|
33
|
-
|
|
34
|
-
# if not args:
|
|
35
|
-
# log2('Please specify <port>.')
|
|
36
|
-
# return state
|
|
37
|
-
|
|
38
|
-
# port = args[0]
|
|
39
|
-
# name = f'ops-{port}'
|
|
40
|
-
# user = os.getenv("USER")
|
|
41
|
-
# label_selector=f'user={user}'
|
|
42
|
-
# Ingresses.delete_ingresses(state.namespace, label_selector=label_selector)
|
|
43
|
-
# Services.delete_services(state.namespace, label_selector=label_selector)
|
|
44
|
-
|
|
45
|
-
# pattern = f'/c3/c3/ops/code/{user}/'
|
|
46
|
-
# self.kill_process_by_pattern(pattern)
|
|
47
|
-
|
|
48
|
-
return state
|
|
49
|
-
|
|
50
|
-
def completion(self, state: ReplState):
|
|
51
|
-
if state.namespace:
|
|
52
|
-
return super().completion(state)
|
|
53
|
-
|
|
54
|
-
return {}
|
|
55
|
-
|
|
56
|
-
def help(self, _: ReplState):
|
|
57
|
-
return f'{CodeStop.COMMAND}\t stop code server'
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import click
|
|
2
|
-
|
|
3
|
-
from walker.commands.command import Command
|
|
4
|
-
from walker.commands.command_helpers import ClusterCommandHelper
|
|
5
|
-
from .setup_frontend import SetupFrontend
|
|
6
|
-
from walker.repl_state import ReplState
|
|
7
|
-
from walker.utils import lines_to_tabular, log, log2
|
|
8
|
-
|
|
9
|
-
class Setup(Command):
|
|
10
|
-
COMMAND = 'setup'
|
|
11
|
-
reaper_login = None
|
|
12
|
-
|
|
13
|
-
# the singleton pattern
|
|
14
|
-
def __new__(cls, *args, **kwargs):
|
|
15
|
-
if not hasattr(cls, 'instance'): cls.instance = super(Setup, 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 Setup.COMMAND
|
|
24
|
-
|
|
25
|
-
def run(self, cmd: str, state: ReplState):
|
|
26
|
-
if not(args := self.args(cmd)):
|
|
27
|
-
return super().run(cmd, state)
|
|
28
|
-
|
|
29
|
-
state, args = self.apply_state(args, state)
|
|
30
|
-
|
|
31
|
-
if state.in_repl:
|
|
32
|
-
log(lines_to_tabular([c.help(ReplState()) for c in Setup.cmd_list()], separator=':'))
|
|
33
|
-
|
|
34
|
-
return 'command-missing'
|
|
35
|
-
else:
|
|
36
|
-
# head with the Chain of Responsibility pattern
|
|
37
|
-
cmds = Command.chain(Setup.cmd_list())
|
|
38
|
-
if not cmds.run(cmd, state):
|
|
39
|
-
log2('* Command is missing.')
|
|
40
|
-
Command.display_help()
|
|
41
|
-
|
|
42
|
-
def cmd_list():
|
|
43
|
-
return [SetupFrontend()]
|
|
44
|
-
|
|
45
|
-
def completion(self, state: ReplState):
|
|
46
|
-
if state.sts:
|
|
47
|
-
return super().completion(state)
|
|
48
|
-
|
|
49
|
-
return {}
|
|
50
|
-
|
|
51
|
-
def help(self, _: ReplState):
|
|
52
|
-
return None
|
|
53
|
-
|
|
54
|
-
class SetupCommandHelper(click.Command):
|
|
55
|
-
def get_help(self, ctx: click.Context):
|
|
56
|
-
log(super().get_help(ctx))
|
|
57
|
-
log()
|
|
58
|
-
log('Sub-Commands:')
|
|
59
|
-
|
|
60
|
-
log(lines_to_tabular([c.help(ReplState()).replace(f'{Setup.COMMAND} ', ' ', 1) for c in Setup.cmd_list()], separator=':'))
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
from walker.app_session import AppSession
|
|
2
|
-
from walker.commands.command import Command
|
|
3
|
-
from walker.k8s_utils.ingresses import Ingresses
|
|
4
|
-
from walker.k8s_utils.services import Services
|
|
5
|
-
from walker.repl_state import ReplState, RequiredState
|
|
6
|
-
from walker.utils import log2
|
|
7
|
-
|
|
8
|
-
class SetupFrontend(Command):
|
|
9
|
-
COMMAND = 'setup frontend'
|
|
10
|
-
|
|
11
|
-
# the singleton pattern
|
|
12
|
-
def __new__(cls, *args, **kwargs):
|
|
13
|
-
if not hasattr(cls, 'instance'): cls.instance = super(SetupFrontend, 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 SetupFrontend.COMMAND
|
|
22
|
-
|
|
23
|
-
def required(self):
|
|
24
|
-
return RequiredState.NAMESPACE
|
|
25
|
-
|
|
26
|
-
def run(self, cmd: str, state: ReplState):
|
|
27
|
-
if not(args := self.args(cmd)):
|
|
28
|
-
return super().run(cmd, state)
|
|
29
|
-
|
|
30
|
-
state, args = self.apply_state(args, state)
|
|
31
|
-
if not self.validate_state(state):
|
|
32
|
-
return state
|
|
33
|
-
|
|
34
|
-
log2('This will support c3/c3 only for demo.')
|
|
35
|
-
|
|
36
|
-
app_session: AppSession = AppSession.create('c3', 'c3', state.namespace)
|
|
37
|
-
try:
|
|
38
|
-
name = 'ops'
|
|
39
|
-
port = 7678
|
|
40
|
-
Services.create_service(name, state.namespace, port, {"run": "ops"})
|
|
41
|
-
Ingresses.create_ingress(name, state.namespace, app_session.host, '/c3/c3/ops($|/)', port, annotations={
|
|
42
|
-
'kubernetes.io/ingress.class': 'nginx',
|
|
43
|
-
'nginx.ingress.kubernetes.io/use-regex': 'true',
|
|
44
|
-
'nginx.ingress.kubernetes.io/rewrite-target': '/'
|
|
45
|
-
})
|
|
46
|
-
except Exception as e:
|
|
47
|
-
if e.status == 409:
|
|
48
|
-
log2(f"Error: '{name}' already exists in namespace '{state.namespace}'.")
|
|
49
|
-
else:
|
|
50
|
-
log2(f"Error creating ingress or service: {e}")
|
|
51
|
-
|
|
52
|
-
return state
|
|
53
|
-
|
|
54
|
-
def completion(self, _: ReplState):
|
|
55
|
-
return {}
|
|
56
|
-
|
|
57
|
-
def help(self, _: ReplState):
|
|
58
|
-
return f'{SetupFrontend.COMMAND}\t sets up frontend'
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import click
|
|
2
|
-
|
|
3
|
-
from walker.commands.command import Command
|
|
4
|
-
from walker.commands.command_helpers import ClusterCommandHelper
|
|
5
|
-
from walker.commands.frontend.teardown_frontend import TearDownFrontend
|
|
6
|
-
from .setup_frontend import SetupFrontend
|
|
7
|
-
from walker.repl_state import ReplState
|
|
8
|
-
from walker.utils import lines_to_tabular, log, log2
|
|
9
|
-
|
|
10
|
-
class TearDown(Command):
|
|
11
|
-
COMMAND = 'teardown'
|
|
12
|
-
reaper_login = None
|
|
13
|
-
|
|
14
|
-
# the singleton pattern
|
|
15
|
-
def __new__(cls, *args, **kwargs):
|
|
16
|
-
if not hasattr(cls, 'instance'): cls.instance = super(TearDown, cls).__new__(cls)
|
|
17
|
-
|
|
18
|
-
return cls.instance
|
|
19
|
-
|
|
20
|
-
def __init__(self, successor: Command=None):
|
|
21
|
-
super().__init__(successor)
|
|
22
|
-
|
|
23
|
-
def command(self):
|
|
24
|
-
return TearDown.COMMAND
|
|
25
|
-
|
|
26
|
-
def run(self, cmd: str, state: ReplState):
|
|
27
|
-
if not(args := self.args(cmd)):
|
|
28
|
-
return super().run(cmd, state)
|
|
29
|
-
|
|
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 TearDown.cmd_list()], separator=':'))
|
|
34
|
-
|
|
35
|
-
return 'command-missing'
|
|
36
|
-
else:
|
|
37
|
-
# head with the Chain of Responsibility pattern
|
|
38
|
-
cmds = Command.chain(TearDown.cmd_list())
|
|
39
|
-
if not cmds.run(cmd, state):
|
|
40
|
-
log2('* Command is missing.')
|
|
41
|
-
Command.display_help()
|
|
42
|
-
|
|
43
|
-
def cmd_list():
|
|
44
|
-
return [TearDownFrontend()]
|
|
45
|
-
|
|
46
|
-
def completion(self, state: ReplState):
|
|
47
|
-
if state.sts:
|
|
48
|
-
return super().completion(state)
|
|
49
|
-
|
|
50
|
-
return {}
|
|
51
|
-
|
|
52
|
-
def help(self, _: ReplState):
|
|
53
|
-
return None
|
|
54
|
-
|
|
55
|
-
class TearDownCommandHelper(click.Command):
|
|
56
|
-
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'{TearDown.COMMAND} ', ' ', 1) for c in TearDown.cmd_list()], separator=':'))
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
from walker.commands.command import Command
|
|
2
|
-
from walker.k8s_utils.ingresses import Ingresses
|
|
3
|
-
from walker.k8s_utils.services import Services
|
|
4
|
-
from walker.repl_state import ReplState, RequiredState
|
|
5
|
-
|
|
6
|
-
class TearDownFrontend(Command):
|
|
7
|
-
COMMAND = 'teardown frontend'
|
|
8
|
-
|
|
9
|
-
# the singleton pattern
|
|
10
|
-
def __new__(cls, *args, **kwargs):
|
|
11
|
-
if not hasattr(cls, 'instance'): cls.instance = super(TearDownFrontend, 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 TearDownFrontend.COMMAND
|
|
20
|
-
|
|
21
|
-
def required(self):
|
|
22
|
-
return RequiredState.NAMESPACE
|
|
23
|
-
|
|
24
|
-
def run(self, cmd: str, state: ReplState):
|
|
25
|
-
if not(args := self.args(cmd)):
|
|
26
|
-
return super().run(cmd, state)
|
|
27
|
-
|
|
28
|
-
state, args = self.apply_state(args, state)
|
|
29
|
-
if not self.validate_state(state):
|
|
30
|
-
return state
|
|
31
|
-
|
|
32
|
-
name = 'ops'
|
|
33
|
-
Ingresses.delete_ingress(name, state.namespace)
|
|
34
|
-
Services.delete_service(name, state.namespace)
|
|
35
|
-
|
|
36
|
-
return state
|
|
37
|
-
|
|
38
|
-
def completion(self, _: ReplState):
|
|
39
|
-
return {}
|
|
40
|
-
|
|
41
|
-
def help(self, _: ReplState):
|
|
42
|
-
return f'{TearDownFrontend.COMMAND}\t tear down frontend'
|
walker/commands/issues.py
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
from walker.checks.check_result import CheckResult
|
|
2
|
-
from walker.checks.check_utils import run_checks
|
|
3
|
-
from walker.checks.issue import Issue
|
|
4
|
-
from walker.commands.command import Command
|
|
5
|
-
from walker.repl_session import ReplSession
|
|
6
|
-
from walker.repl_state import ReplState
|
|
7
|
-
from walker.utils import lines_to_tabular, log, log2
|
|
8
|
-
|
|
9
|
-
class Issues(Command):
|
|
10
|
-
COMMAND = 'issues'
|
|
11
|
-
|
|
12
|
-
# the singleton pattern
|
|
13
|
-
def __new__(cls, *args, **kwargs):
|
|
14
|
-
if not hasattr(cls, 'instance'): cls.instance = super(Issues, cls).__new__(cls)
|
|
15
|
-
|
|
16
|
-
return cls.instance
|
|
17
|
-
|
|
18
|
-
def __init__(self, successor: Command=None):
|
|
19
|
-
super().__init__(successor)
|
|
20
|
-
|
|
21
|
-
def command(self):
|
|
22
|
-
return Issues.COMMAND
|
|
23
|
-
|
|
24
|
-
def run(self, cmd: str, state: ReplState):
|
|
25
|
-
if not(args := self.args(cmd)):
|
|
26
|
-
return super().run(cmd, state)
|
|
27
|
-
|
|
28
|
-
state, args = self.apply_state(args, state)
|
|
29
|
-
args, show = Command.extract_options(args, ['-s', '--show'])
|
|
30
|
-
|
|
31
|
-
results = run_checks(state.sts, state.namespace, state.pod, show_output=show)
|
|
32
|
-
|
|
33
|
-
issues = CheckResult.collect_issues(results)
|
|
34
|
-
Issues.show_issues(issues, in_repl=state.in_repl)
|
|
35
|
-
|
|
36
|
-
return issues if issues else 'issues'
|
|
37
|
-
|
|
38
|
-
def show(check_results: list[CheckResult], in_repl = False):
|
|
39
|
-
Issues.show_issues(CheckResult.collect_issues(check_results), in_repl=in_repl)
|
|
40
|
-
|
|
41
|
-
def show_issues(issues: list[Issue], in_repl = False):
|
|
42
|
-
if not issues:
|
|
43
|
-
log2('No issues found.')
|
|
44
|
-
else:
|
|
45
|
-
suggested = 0
|
|
46
|
-
log2(f'* {len(issues)} issues found.')
|
|
47
|
-
lines = []
|
|
48
|
-
for i, issue in enumerate(issues, start=1):
|
|
49
|
-
lines.append(f"{i}||{issue.category}||{issue.desc}")
|
|
50
|
-
lines.append(f"||statefulset||{issue.statefulset}@{issue.namespace}")
|
|
51
|
-
lines.append(f"||pod||{issue.pod}@{issue.namespace}")
|
|
52
|
-
if issue.details:
|
|
53
|
-
lines.append(f"||details||{issue.details}")
|
|
54
|
-
|
|
55
|
-
if issue.suggestion:
|
|
56
|
-
lines.append(f'||suggestion||{issue.suggestion}')
|
|
57
|
-
if in_repl:
|
|
58
|
-
ReplSession().prompt_session.history.append_string(issue.suggestion)
|
|
59
|
-
suggested += 1
|
|
60
|
-
log(lines_to_tabular(lines, separator='||'))
|
|
61
|
-
if suggested:
|
|
62
|
-
log2()
|
|
63
|
-
log2(f'* {suggested} suggested commands are added to history. Press <Up> arrow to access them.')
|
|
64
|
-
|
|
65
|
-
def completion(self, _: ReplState):
|
|
66
|
-
return {Issues.COMMAND: None}
|
|
67
|
-
|
|
68
|
-
def help(self, _: ReplState):
|
|
69
|
-
return f'{Issues.COMMAND}\t find all issues'
|
walker/commands/login.py
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import signal
|
|
3
|
-
import traceback
|
|
4
|
-
|
|
5
|
-
from walker.app_session import AppSession
|
|
6
|
-
from walker.apps import Apps
|
|
7
|
-
from walker.sso.idp import Idp
|
|
8
|
-
from walker.sso.idp_login import IdpLogin
|
|
9
|
-
from walker.commands.command import Command
|
|
10
|
-
from walker.repl_state import ReplState
|
|
11
|
-
from walker.sso.sso_config import SsoConfig
|
|
12
|
-
from walker.utils import log, log2
|
|
13
|
-
|
|
14
|
-
class Login(Command):
|
|
15
|
-
COMMAND = 'login'
|
|
16
|
-
|
|
17
|
-
# the singleton pattern
|
|
18
|
-
def __new__(cls, *args, **kwargs):
|
|
19
|
-
if not hasattr(cls, 'instance'): cls.instance = super(Login, cls).__new__(cls)
|
|
20
|
-
|
|
21
|
-
return cls.instance
|
|
22
|
-
|
|
23
|
-
def __init__(self, successor: Command=None):
|
|
24
|
-
super().__init__(successor)
|
|
25
|
-
|
|
26
|
-
def command(self):
|
|
27
|
-
return Login.COMMAND
|
|
28
|
-
|
|
29
|
-
def run(self, cmd: str, state: ReplState):
|
|
30
|
-
def custom_handler(signum, frame):
|
|
31
|
-
AppSession.ctrl_c_entered = True
|
|
32
|
-
|
|
33
|
-
signal.signal(signal.SIGINT, custom_handler)
|
|
34
|
-
|
|
35
|
-
if not(args := self.args(cmd)):
|
|
36
|
-
return super().run(cmd, state)
|
|
37
|
-
|
|
38
|
-
state, args = self.apply_state(args, state)
|
|
39
|
-
|
|
40
|
-
# args, print_token = Command.extract_options(args, '--print-token')
|
|
41
|
-
|
|
42
|
-
username: str = None
|
|
43
|
-
if len(args) > 0:
|
|
44
|
-
username = args[0]
|
|
45
|
-
|
|
46
|
-
# print(SsoConfig().config)
|
|
47
|
-
# SsoConfig().find_idp_url()
|
|
48
|
-
# print(json.dumps(SsoConfig(), indent=4))
|
|
49
|
-
|
|
50
|
-
login: IdpLogin = None
|
|
51
|
-
try:
|
|
52
|
-
if not(host := Apps.app_host('c3', 'c3', state.namespace)):
|
|
53
|
-
log2('Cannot locate ingress for app.')
|
|
54
|
-
return state
|
|
55
|
-
|
|
56
|
-
# uri = Idp.build_uri(host, host)
|
|
57
|
-
if not (login := Idp.login(host, username=username, use_cached=False)):
|
|
58
|
-
log2('Invalid username/password. Please try again.')
|
|
59
|
-
except:
|
|
60
|
-
log2(traceback.format_exc())
|
|
61
|
-
pass
|
|
62
|
-
|
|
63
|
-
# if print_token:
|
|
64
|
-
log(f'IDP_TOKEN={login.ser() if login else ""}')
|
|
65
|
-
|
|
66
|
-
return state
|
|
67
|
-
|
|
68
|
-
def completion(self, _: ReplState):
|
|
69
|
-
return {}
|
|
70
|
-
|
|
71
|
-
def help(self, _: ReplState):
|
|
72
|
-
return f'{Login.COMMAND}\t SSO login'
|