kaqing 2.0.111__tar.gz → 2.0.114__tar.gz
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.
- {kaqing-2.0.111 → kaqing-2.0.114}/PKG-INFO +1 -1
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/batch.py +1 -1
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/app.py +1 -1
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/audit/audit.py +8 -7
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/audit/audit_repair_tables.py +2 -1
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/audit/audit_run.py +2 -1
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/audit/show_last10.py +2 -1
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/audit/show_slow10.py +2 -1
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/audit/show_top10.py +2 -1
- kaqing-2.0.114/adam/commands/bash/bash.py +124 -0
- kaqing-2.0.114/adam/commands/bash/bash_completer.py +93 -0
- kaqing-2.0.114/adam/commands/cat.py +55 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/cd.py +9 -3
- kaqing-2.0.114/adam/commands/code.py +60 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/command.py +3 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/cql/cql_utils.py +95 -3
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/cql/cqlsh.py +5 -3
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/devices.py +29 -0
- kaqing-2.0.114/adam/commands/export/export.py +63 -0
- kaqing-2.0.114/adam/commands/export/export_on_x.py +76 -0
- kaqing-2.0.114/adam/commands/export/export_rmdbs.py +65 -0
- kaqing-2.0.114/adam/commands/export/export_select.py +68 -0
- kaqing-2.0.114/adam/commands/export/export_use.py +56 -0
- kaqing-2.0.114/adam/commands/export/utils_export.py +201 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/help.py +2 -0
- kaqing-2.0.114/adam/commands/kubectl.py +41 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/ls.py +23 -11
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/nodetool.py +5 -2
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/postgres/postgres.py +1 -1
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/preview_table.py +3 -2
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/pwd.py +2 -1
- kaqing-2.0.114/adam/embedded_params.py +2 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/pod_exec_result.py +3 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/repl.py +49 -33
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/repl_commands.py +18 -8
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/repl_state.py +98 -20
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/sql/sql_completer.py +12 -3
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/sql/sql_state_machine.py +37 -3
- kaqing-2.0.114/adam/sso/__init__.py +0 -0
- kaqing-2.0.114/adam/utils_athena.py +126 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_audits.py +0 -89
- kaqing-2.0.114/adam/utils_export.py +42 -0
- kaqing-2.0.114/adam/utils_k8s/__init__.py +0 -0
- kaqing-2.0.114/adam/utils_k8s/app_clusters.py +33 -0
- kaqing-2.0.114/adam/utils_k8s/app_pods.py +31 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_k8s/cassandra_nodes.py +1 -1
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_k8s/pods.py +30 -0
- kaqing-2.0.114/adam/version.py +5 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/kaqing.egg-info/PKG-INFO +1 -1
- {kaqing-2.0.111 → kaqing-2.0.114}/kaqing.egg-info/SOURCES.txt +17 -1
- {kaqing-2.0.111 → kaqing-2.0.114}/setup.py +1 -1
- kaqing-2.0.111/adam/commands/bash.py +0 -150
- kaqing-2.0.111/adam/embedded_params.py +0 -2
- kaqing-2.0.111/adam/version.py +0 -5
- {kaqing-2.0.111 → kaqing-2.0.114}/README +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/__init__.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/app_session.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/apps.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/checks/__init__.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/checks/check.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/checks/check_context.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/checks/check_result.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/checks/check_utils.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/checks/compactionstats.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/checks/cpu.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/checks/disk.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/checks/gossip.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/checks/issue.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/checks/memory.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/checks/status.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/cli.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/cli_group.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/__init__.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/column.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/columns.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/compactions.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/cpu.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/dir_data.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/dir_snapshots.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/gossip.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/host_id.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/memory.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/node_address.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/node_load.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/node_owns.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/node_status.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/node_tokens.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/node_utils.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/pod_name.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/volume_cassandra.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/columns/volume_root.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/__init__.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/alter_tables.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/app_ping.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/audit/__init__.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/audit/utils_show_top10.py +0 -0
- {kaqing-2.0.111/adam/commands/cql → kaqing-2.0.114/adam/commands/bash}/__init__.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/check.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/cli_commands.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/command_helpers.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/commands_utils.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/cp.py +0 -0
- {kaqing-2.0.111/adam/commands/deploy → kaqing-2.0.114/adam/commands/cql}/__init__.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/cql/cql_completions.py +0 -0
- {kaqing-2.0.111/adam/commands/medusa → kaqing-2.0.114/adam/commands/deploy}/__init__.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/deploy/code_start.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/deploy/code_stop.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/deploy/code_utils.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/deploy/deploy.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/deploy/deploy_frontend.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/deploy/deploy_pg_agent.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/deploy/deploy_pod.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/deploy/deploy_utils.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/deploy/undeploy.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/deploy/undeploy_frontend.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/deploy/undeploy_pg_agent.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/deploy/undeploy_pod.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/exit.py +0 -0
- {kaqing-2.0.111/adam/commands/postgres → kaqing-2.0.114/adam/commands/export}/__init__.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/issues.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/login.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/logs.py +0 -0
- {kaqing-2.0.111/adam/commands/reaper → kaqing-2.0.114/adam/commands/medusa}/__init__.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/medusa/medusa.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/medusa/medusa_backup.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/medusa/medusa_restore.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/medusa/medusa_show_backupjobs.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/medusa/medusa_show_restorejobs.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/nodetool_commands.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/param_get.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/param_set.py +0 -0
- {kaqing-2.0.111/adam/commands/repair → kaqing-2.0.114/adam/commands/postgres}/__init__.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/postgres/postgres_context.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/postgres/postgres_ls.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/postgres/postgres_preview.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/postgres/postgres_utils.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/postgres/psql_completions.py +0 -0
- {kaqing-2.0.111/adam/commands/show → kaqing-2.0.114/adam/commands/reaper}/__init__.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/reaper/reaper.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/reaper/reaper_forward.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/reaper/reaper_forward_stop.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/reaper/reaper_restart.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/reaper/reaper_run_abort.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/reaper/reaper_runs.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/reaper/reaper_runs_abort.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/reaper/reaper_schedule_activate.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/reaper/reaper_schedule_start.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/reaper/reaper_schedule_stop.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/reaper/reaper_schedules.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/reaper/reaper_session.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/reaper/reaper_status.py +0 -0
- {kaqing-2.0.111/adam/sql → kaqing-2.0.114/adam/commands/repair}/__init__.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/repair/repair.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/repair/repair_log.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/repair/repair_run.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/repair/repair_scan.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/repair/repair_stop.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/report.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/restart.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/rollout.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/shell.py +0 -0
- {kaqing-2.0.111/adam/sso → kaqing-2.0.114/adam/commands/show}/__init__.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/show/show.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/show/show_adam.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/show/show_app_actions.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/show/show_app_id.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/show/show_app_queues.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/show/show_cassandra_status.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/show/show_cassandra_version.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/show/show_commands.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/show/show_host.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/show/show_login.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/show/show_params.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/show/show_processes.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/show/show_repairs.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/show/show_storage.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/commands/watch.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/config.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/embedded_apps.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/log.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/repl_session.py +0 -0
- {kaqing-2.0.111/adam/utils_k8s → kaqing-2.0.114/adam/sql}/__init__.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/sql/term_completer.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/sso/authenticator.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/sso/authn_ad.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/sso/authn_okta.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/sso/cred_cache.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/sso/id_token.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/sso/idp.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/sso/idp_login.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/sso/idp_session.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/sso/sso_config.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_k8s/cassandra_clusters.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_k8s/config_maps.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_k8s/custom_resources.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_k8s/deployment.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_k8s/ingresses.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_k8s/jobs.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_k8s/kube_context.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_k8s/secrets.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_k8s/service_accounts.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_k8s/services.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_k8s/statefulsets.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_k8s/volumes.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/adam/utils_net.py +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/kaqing.egg-info/dependency_links.txt +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/kaqing.egg-info/entry_points.txt +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/kaqing.egg-info/top_level.txt +0 -0
- {kaqing-2.0.111 → kaqing-2.0.114}/setup.cfg +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
3
|
from adam.commands.audit.audit import Audit, AuditCommandHelper
|
|
4
|
-
from adam.commands.bash import Bash
|
|
4
|
+
from adam.commands.bash.bash import Bash
|
|
5
5
|
from adam.commands.check import Check, CheckCommandHelper
|
|
6
6
|
from adam.commands.cp import ClipboardCopy, CopyCommandHelper
|
|
7
7
|
from adam.commands.command import Command
|
|
@@ -11,6 +11,7 @@ from adam.config import Config
|
|
|
11
11
|
from adam.repl_state import ReplState
|
|
12
12
|
from adam.sql.sql_completer import SqlCompleter
|
|
13
13
|
from adam.utils import log2
|
|
14
|
+
from adam.utils_athena import Athena
|
|
14
15
|
from adam.utils_audits import Audits
|
|
15
16
|
|
|
16
17
|
class Audit(Command):
|
|
@@ -51,7 +52,7 @@ class Audit(Command):
|
|
|
51
52
|
else:
|
|
52
53
|
log2(sql)
|
|
53
54
|
|
|
54
|
-
|
|
55
|
+
Athena.run_query(sql)
|
|
55
56
|
|
|
56
57
|
return state
|
|
57
58
|
|
|
@@ -61,14 +62,14 @@ class Audit(Command):
|
|
|
61
62
|
Config().wait_log(f'Inspecting audit database schema...')
|
|
62
63
|
self.schema_read = True
|
|
63
64
|
# warm up the caches first time when l: drive is accessed
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
Athena.table_names()
|
|
66
|
+
Athena.column_names()
|
|
67
|
+
Athena.column_names(partition_cols_only=True)
|
|
67
68
|
|
|
68
69
|
return super().completion(state) | show_top10_completions_for_nesting() | SqlCompleter(
|
|
69
|
-
lambda:
|
|
70
|
-
columns=lambda table:
|
|
71
|
-
partition_columns=lambda table:
|
|
70
|
+
lambda: Athena.table_names(),
|
|
71
|
+
columns=lambda table: Athena.column_names(),
|
|
72
|
+
partition_columns=lambda table: Athena.column_names(partition_cols_only=True),
|
|
72
73
|
variant='athena'
|
|
73
74
|
).completions_for_nesting()
|
|
74
75
|
|
|
@@ -5,6 +5,7 @@ from adam.commands.command import Command
|
|
|
5
5
|
from adam.config import Config
|
|
6
6
|
from adam.repl_state import ReplState
|
|
7
7
|
from adam.utils import log, log2
|
|
8
|
+
from adam.utils_athena import Athena
|
|
8
9
|
from adam.utils_audits import AuditMeta, Audits
|
|
9
10
|
|
|
10
11
|
class AuditRepairTables(Command):
|
|
@@ -69,7 +70,7 @@ class AuditRepairTables(Command):
|
|
|
69
70
|
if show_sql:
|
|
70
71
|
log(f'MSCK REPAIR TABLE {table}')
|
|
71
72
|
|
|
72
|
-
executor.submit(
|
|
73
|
+
executor.submit(Athena.run_query, f'MSCK REPAIR TABLE {table}', None,)
|
|
73
74
|
executor.submit(Audits.put_meta, Audits.PARTITIONS_ADDED, meta,)
|
|
74
75
|
|
|
75
76
|
def help(self, _: ReplState):
|
|
@@ -4,6 +4,7 @@ from adam.commands.command import Command
|
|
|
4
4
|
from adam.config import Config
|
|
5
5
|
from adam.repl_state import ReplState
|
|
6
6
|
from adam.utils import log2
|
|
7
|
+
from adam.utils_athena import Athena
|
|
7
8
|
from adam.utils_audits import AuditMeta, Audits
|
|
8
9
|
|
|
9
10
|
class AuditRun(Command):
|
|
@@ -41,7 +42,7 @@ class AuditRun(Command):
|
|
|
41
42
|
tables = Config().get('audit.athena.repair-cluster-tables', 'cluster').split(',')
|
|
42
43
|
with concurrent.futures.ThreadPoolExecutor(max_workers=Config().get('audit.workers', 3)) as executor:
|
|
43
44
|
for table in tables:
|
|
44
|
-
executor.submit(
|
|
45
|
+
executor.submit(Athena.run_query, f'MSCK REPAIR TABLE {table}', None,)
|
|
45
46
|
else:
|
|
46
47
|
log2(f'No new clusters were found.')
|
|
47
48
|
|
|
@@ -2,6 +2,7 @@ from adam.commands.audit.utils_show_top10 import extract_limit_and_duration
|
|
|
2
2
|
from adam.commands.command import Command
|
|
3
3
|
from adam.repl_state import ReplState
|
|
4
4
|
from adam.utils import log2
|
|
5
|
+
from adam.utils_athena import Athena
|
|
5
6
|
from adam.utils_audits import Audits
|
|
6
7
|
|
|
7
8
|
class ShowLast10(Command):
|
|
@@ -38,7 +39,7 @@ class ShowLast10(Command):
|
|
|
38
39
|
f"ORDER BY ts DESC LIMIT {limit};"])
|
|
39
40
|
log2(query)
|
|
40
41
|
log2()
|
|
41
|
-
|
|
42
|
+
Athena.run_query(query)
|
|
42
43
|
|
|
43
44
|
return state
|
|
44
45
|
|
|
@@ -2,6 +2,7 @@ from adam.commands.audit.utils_show_top10 import extract_limit_and_duration
|
|
|
2
2
|
from adam.commands.command import Command
|
|
3
3
|
from adam.repl_state import ReplState
|
|
4
4
|
from adam.utils import log2
|
|
5
|
+
from adam.utils_athena import Athena
|
|
5
6
|
from adam.utils_audits import Audits
|
|
6
7
|
|
|
7
8
|
class ShowSlow10(Command):
|
|
@@ -38,7 +39,7 @@ class ShowSlow10(Command):
|
|
|
38
39
|
f"ORDER BY CAST(duration AS REAL) DESC LIMIT {limit};"])
|
|
39
40
|
log2(query)
|
|
40
41
|
log2()
|
|
41
|
-
|
|
42
|
+
Athena.run_query(query)
|
|
42
43
|
|
|
43
44
|
return state
|
|
44
45
|
|
|
@@ -2,6 +2,7 @@ from adam.commands.audit.utils_show_top10 import extract_limit_and_duration
|
|
|
2
2
|
from adam.commands.command import Command
|
|
3
3
|
from adam.repl_state import ReplState
|
|
4
4
|
from adam.utils import log2
|
|
5
|
+
from adam.utils_athena import Athena
|
|
5
6
|
from adam.utils_audits import Audits
|
|
6
7
|
|
|
7
8
|
class ShowTop10(Command):
|
|
@@ -37,7 +38,7 @@ class ShowTop10(Command):
|
|
|
37
38
|
f"GROUP BY line ORDER BY cnt DESC LIMIT {limit};"])
|
|
38
39
|
log2(query)
|
|
39
40
|
log2()
|
|
40
|
-
|
|
41
|
+
Athena.run_query(query)
|
|
41
42
|
|
|
42
43
|
return state
|
|
43
44
|
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
|
|
3
|
+
from adam.commands.bash.bash_completer import BashCompleter
|
|
4
|
+
from adam.commands.command import Command
|
|
5
|
+
from adam.utils_k8s.app_clusters import AppClusters
|
|
6
|
+
from adam.utils_k8s.app_pods import AppPods
|
|
7
|
+
from adam.utils_k8s.cassandra_clusters import CassandraClusters
|
|
8
|
+
from adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
9
|
+
from adam.pod_exec_result import PodExecResult
|
|
10
|
+
from adam.repl_state import BashSession, ReplState, RequiredState
|
|
11
|
+
from adam.utils_k8s.statefulsets import StatefulSets
|
|
12
|
+
from build.lib.adam.utils_k8s.cassandra_nodes import CassandraNodes
|
|
13
|
+
|
|
14
|
+
class Bash(Command):
|
|
15
|
+
COMMAND = 'bash'
|
|
16
|
+
|
|
17
|
+
# the singleton pattern
|
|
18
|
+
def __new__(cls, *args, **kwargs):
|
|
19
|
+
if not hasattr(cls, 'instance'): cls.instance = super(Bash, 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 Bash.COMMAND
|
|
28
|
+
|
|
29
|
+
def required(self):
|
|
30
|
+
return [RequiredState.CLUSTER_OR_POD, RequiredState.APP_APP]
|
|
31
|
+
|
|
32
|
+
def run(self, cmd: str, s0: ReplState):
|
|
33
|
+
if not(args := self.args(cmd)):
|
|
34
|
+
return super().run(cmd, s0)
|
|
35
|
+
|
|
36
|
+
state, args = self.apply_state(args, s0, args_to_check=2)
|
|
37
|
+
if not self.validate_state(state):
|
|
38
|
+
return state
|
|
39
|
+
|
|
40
|
+
def _run(state_changed: bool, cli: Callable[[str], None]):
|
|
41
|
+
if state.in_repl:
|
|
42
|
+
if state_changed:
|
|
43
|
+
r = self.exec_with_dir(state, args)
|
|
44
|
+
else:
|
|
45
|
+
r = self.exec_with_dir(s0, args)
|
|
46
|
+
|
|
47
|
+
if not r:
|
|
48
|
+
state.exit_bash()
|
|
49
|
+
|
|
50
|
+
return 'inconsistent pwd'
|
|
51
|
+
|
|
52
|
+
return r
|
|
53
|
+
else:
|
|
54
|
+
cli(' '.join(args))
|
|
55
|
+
|
|
56
|
+
return state
|
|
57
|
+
|
|
58
|
+
if state.device == ReplState.A:
|
|
59
|
+
def cli(command: str):
|
|
60
|
+
if state.app_pod:
|
|
61
|
+
AppPods.exec(state.app_pod, state.namespace, command, show_out=True)
|
|
62
|
+
elif state.app_app:
|
|
63
|
+
AppClusters.exec(AppPods.pod_names(state.namespace, state.app_env, state.app_app), state.namespace, command, action='bash', show_out=True)
|
|
64
|
+
|
|
65
|
+
return _run(s0.app_env != state.app_env or s0.app_app != state.app_app or s0.app_pod != state.app_pod, cli)
|
|
66
|
+
|
|
67
|
+
def cli(command: str):
|
|
68
|
+
if state.pod:
|
|
69
|
+
CassandraNodes.exec(state.pod, state.namespace, command, show_out=True)
|
|
70
|
+
elif state.sts:
|
|
71
|
+
CassandraClusters.exec(state.sts, state.namespace, command, action='bash', show_out=True)
|
|
72
|
+
|
|
73
|
+
return _run(s0.sts != state.sts or s0.pod != state.pod, cli)
|
|
74
|
+
|
|
75
|
+
def exec_with_dir(self, state: ReplState, args: list[str]) -> list[PodExecResult]:
|
|
76
|
+
session_just_created = False
|
|
77
|
+
if not args:
|
|
78
|
+
session_just_created = True
|
|
79
|
+
session = BashSession(state.device)
|
|
80
|
+
state.enter_bash(session)
|
|
81
|
+
|
|
82
|
+
if state.bash_session:
|
|
83
|
+
if args != ['pwd']:
|
|
84
|
+
if args:
|
|
85
|
+
args.append('&&')
|
|
86
|
+
args.extend(['pwd', '>', f'/tmp/.qing-{state.bash_session.session_id}'])
|
|
87
|
+
|
|
88
|
+
if not session_just_created:
|
|
89
|
+
if pwd := state.bash_session.pwd(state):
|
|
90
|
+
args = ['cd', pwd, '&&'] + args
|
|
91
|
+
|
|
92
|
+
command = ' '.join(args)
|
|
93
|
+
|
|
94
|
+
rs = []
|
|
95
|
+
|
|
96
|
+
if state.device == ReplState.A:
|
|
97
|
+
if state.app_pod:
|
|
98
|
+
rs = [AppPods.exec(state.app_pod, state.namespace, command,
|
|
99
|
+
show_out=not session_just_created, shell='bash')]
|
|
100
|
+
elif state.app_app:
|
|
101
|
+
rs = AppClusters.exec(AppPods.pod_names(state.namespace, state.app_env, state.app_app), state.namespace, command, action='bash',
|
|
102
|
+
show_out=not session_just_created, shell='bash')
|
|
103
|
+
else:
|
|
104
|
+
if state.pod:
|
|
105
|
+
rs = [CassandraNodes.exec(state.pod, state.namespace, command,
|
|
106
|
+
show_out=not session_just_created, shell='bash')]
|
|
107
|
+
elif state.sts:
|
|
108
|
+
rs = CassandraClusters.exec(state.sts, state.namespace, command, action='bash',
|
|
109
|
+
show_out=not session_just_created, shell='bash')
|
|
110
|
+
|
|
111
|
+
return rs
|
|
112
|
+
|
|
113
|
+
def completion(self, state: ReplState):
|
|
114
|
+
if state.device == ReplState.A and state.app_app:
|
|
115
|
+
return { Bash.COMMAND: BashCompleter(lambda: []) } | \
|
|
116
|
+
{f'@{p}': {Bash.COMMAND: BashCompleter(lambda: [])} for p in AppPods.pod_names(state.namespace, state.app_env, state.app_app)}
|
|
117
|
+
elif state.sts:
|
|
118
|
+
return { Bash.COMMAND: BashCompleter(lambda: []) } | \
|
|
119
|
+
{f'@{p}': {Bash.COMMAND: BashCompleter(lambda: [])} for p in StatefulSets.pod_names(state.sts, state.namespace)}
|
|
120
|
+
|
|
121
|
+
return {}
|
|
122
|
+
|
|
123
|
+
def help(self, _: ReplState):
|
|
124
|
+
return f'{Bash.COMMAND} [pod-name] [bash-commands] [&]\t run bash on the Cassandra nodes'
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
from prompt_toolkit.completion import WordCompleter
|
|
3
|
+
|
|
4
|
+
from adam.utils_repl.automata_completer import AutomataCompleter
|
|
5
|
+
from adam.utils_repl.state_machine import State, StateMachine
|
|
6
|
+
|
|
7
|
+
BASH_SPEC = [
|
|
8
|
+
# <command> ::= <simple_command> | <pipeline> | <conditional_command>
|
|
9
|
+
# <simple_command> ::= <word> <argument>* <redirection>*
|
|
10
|
+
# <pipeline> ::= <command> '|' <command>
|
|
11
|
+
# <conditional_command> ::= <command> '&&' <command> | <command> '||' <command>
|
|
12
|
+
# <word> ::= <letter> <letter_or_digit>*
|
|
13
|
+
# <argument> ::= <word>
|
|
14
|
+
# <redirection> ::= '>' <filename> | '<' <filename>
|
|
15
|
+
# <filename> ::= <word>
|
|
16
|
+
# <letter> ::= 'a' | 'b' | ... | 'z' | 'A' | 'B' | ... | 'Z'
|
|
17
|
+
# <digit> ::= '0' | '1' | ... | '9'
|
|
18
|
+
# <letter_or_digit> ::= <letter> | <digit>
|
|
19
|
+
|
|
20
|
+
' > word > cmd ^ hosts',
|
|
21
|
+
'cmd > word > cmd ^ |,>,2>,<,&,&&,||',
|
|
22
|
+
'- > pipe > cmd_pipe',
|
|
23
|
+
'- > _rdr0_ > cmd_rdr0',
|
|
24
|
+
'- > _rdr1_ > cmd_rdr1',
|
|
25
|
+
'- > _rdr2_ > cmd_rdr2',
|
|
26
|
+
'- > & > cmd_bg ^ |,>,2>,<,&,&&,||',
|
|
27
|
+
'- > &&|_or_ > nocmd',
|
|
28
|
+
'cmd_a > word > cmd',
|
|
29
|
+
'cmd_pipe > word > cmd',
|
|
30
|
+
'cmd_rdr0 > word > cmd_rdr0_f',
|
|
31
|
+
'cmd_rdr1 > word > cmd_rdr1_f',
|
|
32
|
+
'cmd_rdr2 > word > cmd_rdr2_f',
|
|
33
|
+
'cmd_rdr1_f > pipe > cmd_pipe ^ |,2>,<,&,&&,||',
|
|
34
|
+
'- > _rdr2_ > cmd_rdr2',
|
|
35
|
+
'- > _rdr0_ > cmd_rdr0',
|
|
36
|
+
'cmd_rdr2_f > pipe > cmd_pipe ^ |,<,&,&&,||',
|
|
37
|
+
'- > _rdr0_ > cmd_rdr0',
|
|
38
|
+
'- > & > cmd_bg ^ |,>,2>,<,&,&&,||',
|
|
39
|
+
'- > &&|_or_ > nocmd',
|
|
40
|
+
'cmd_rdr0_f > pipe > cmd_pipe ^ |,&,&&,||',
|
|
41
|
+
'- > & > cmd_bg ^ |,>,2>,<,&,&&,||',
|
|
42
|
+
'- > &&|_or_ > cmd',
|
|
43
|
+
'cmd_bg > &&|_or_ > nocmd ^ &&,||',
|
|
44
|
+
'nocmd > word > cmd',
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
BASH_KEYWORDS = [
|
|
48
|
+
'&',
|
|
49
|
+
'&&',
|
|
50
|
+
'|',
|
|
51
|
+
'||',
|
|
52
|
+
'>',
|
|
53
|
+
'2>',
|
|
54
|
+
'>>',
|
|
55
|
+
'<',
|
|
56
|
+
'hosts'
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
class BashStateMachine(StateMachine[str]):
|
|
60
|
+
def spec(self) -> str:
|
|
61
|
+
return BASH_SPEC
|
|
62
|
+
|
|
63
|
+
def keywords(self) -> list[str]:
|
|
64
|
+
return BASH_KEYWORDS
|
|
65
|
+
|
|
66
|
+
class BashCompleter(AutomataCompleter[str]):
|
|
67
|
+
def __init__(self,
|
|
68
|
+
hosts: Callable[[], list[str]],
|
|
69
|
+
debug = False):
|
|
70
|
+
super().__init__(BashStateMachine(debug=debug), '', debug=debug)
|
|
71
|
+
|
|
72
|
+
self.hosts = hosts
|
|
73
|
+
self.debug = debug
|
|
74
|
+
|
|
75
|
+
def suggestions_completer(self, state: State, suggestions: str) -> list[str]:
|
|
76
|
+
if not suggestions:
|
|
77
|
+
return None
|
|
78
|
+
|
|
79
|
+
terms = []
|
|
80
|
+
for suggestion in suggestions.split(','):
|
|
81
|
+
terms.extend(self._terms(state, suggestion))
|
|
82
|
+
|
|
83
|
+
return WordCompleter(terms)
|
|
84
|
+
|
|
85
|
+
def _terms(self, _: State, word: str) -> list[str]:
|
|
86
|
+
terms = []
|
|
87
|
+
|
|
88
|
+
if word == 'hosts':
|
|
89
|
+
terms.extend(self.hosts())
|
|
90
|
+
else:
|
|
91
|
+
terms.append(word)
|
|
92
|
+
|
|
93
|
+
return terms
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from adam.commands.bash.bash import Bash
|
|
2
|
+
from adam.commands.command import Command
|
|
3
|
+
from adam.repl_state import ReplState, RequiredState
|
|
4
|
+
from adam.utils import log2
|
|
5
|
+
from adam.utils_k8s.app_pods import AppPods
|
|
6
|
+
from adam.utils_k8s.statefulsets import StatefulSets
|
|
7
|
+
|
|
8
|
+
class Cat(Command):
|
|
9
|
+
COMMAND = 'cat'
|
|
10
|
+
|
|
11
|
+
# the singleton pattern
|
|
12
|
+
def __new__(cls, *args, **kwargs):
|
|
13
|
+
if not hasattr(cls, 'instance'): cls.instance = super(Cat, 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 Cat.COMMAND
|
|
22
|
+
|
|
23
|
+
def required(self):
|
|
24
|
+
return [RequiredState.CLUSTER_OR_POD, RequiredState.APP_APP]
|
|
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 len(args) < 1:
|
|
33
|
+
if state.in_repl:
|
|
34
|
+
log2('File is required.')
|
|
35
|
+
log2()
|
|
36
|
+
else:
|
|
37
|
+
log2('* File is missing.')
|
|
38
|
+
Command.display_help()
|
|
39
|
+
|
|
40
|
+
return 'command-missing'
|
|
41
|
+
|
|
42
|
+
return Bash().run('bash ' + cmd, state)
|
|
43
|
+
|
|
44
|
+
def completion(self, state: ReplState):
|
|
45
|
+
if state.device == ReplState.A and state.app_app:
|
|
46
|
+
return super().completion(state) | \
|
|
47
|
+
{f'@{p}': {Cat.COMMAND: None} for p in AppPods.pod_names(state.namespace, state.app_env, state.app_app)}
|
|
48
|
+
elif state.device == ReplState.C and state.sts:
|
|
49
|
+
return super().completion(state) | \
|
|
50
|
+
{f'@{p}': {Cat.COMMAND: None} for p in StatefulSets.pod_names(state.sts, state.namespace)}
|
|
51
|
+
|
|
52
|
+
return {}
|
|
53
|
+
|
|
54
|
+
def help(self, _: ReplState):
|
|
55
|
+
return f'{Cat.COMMAND} file [&]\t run cat command on the Cassandra nodes'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from adam.commands.command import Command
|
|
2
2
|
from adam.commands.postgres.postgres_utils import pg_database_names
|
|
3
3
|
from adam.commands.postgres.postgres_context import PostgresContext
|
|
4
|
+
from adam.utils_k8s.app_pods import AppPods
|
|
4
5
|
from adam.utils_k8s.cassandra_clusters import CassandraClusters
|
|
5
6
|
from adam.utils_k8s.kube_context import KubeContext
|
|
6
7
|
from adam.utils_k8s.statefulsets import StatefulSets
|
|
@@ -51,13 +52,18 @@ class Cd(Command):
|
|
|
51
52
|
if dir == '':
|
|
52
53
|
state.app_env = None
|
|
53
54
|
state.app_app = None
|
|
55
|
+
state.app_pod = None
|
|
54
56
|
elif dir == '..':
|
|
55
|
-
if state.
|
|
57
|
+
if state.app_pod:
|
|
58
|
+
state.app_pod = None
|
|
59
|
+
elif state.app_app:
|
|
56
60
|
state.app_app = None
|
|
57
61
|
else:
|
|
58
62
|
state.app_env = None
|
|
59
63
|
else:
|
|
60
|
-
if
|
|
64
|
+
if state.app_app:
|
|
65
|
+
state.app_pod = dir
|
|
66
|
+
elif not state.app_env:
|
|
61
67
|
tks = dir.split('@')
|
|
62
68
|
if len(tks) > 1:
|
|
63
69
|
state.namespace = tks[1]
|
|
@@ -106,7 +112,7 @@ class Cd(Command):
|
|
|
106
112
|
return {Cd.COMMAND: {p: None for p in PostgresContext.hosts(state.namespace)}}
|
|
107
113
|
elif state.device == ReplState.A:
|
|
108
114
|
if state.app_app:
|
|
109
|
-
return {Cd.COMMAND: {'..': None}}
|
|
115
|
+
return {Cd.COMMAND: {'..': None} | {pod: None for pod in AppPods.pod_names(state.namespace, state.app_env, state.app_app)}}
|
|
110
116
|
elif state.app_env:
|
|
111
117
|
return {Cd.COMMAND: {'..': None} | {app[0].split('-')[1]: None for app in Apps.apps(state.app_env)}}
|
|
112
118
|
else:
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import code
|
|
2
|
+
from functools import partial
|
|
3
|
+
|
|
4
|
+
from adam.commands.command import Command
|
|
5
|
+
from adam.commands.cql.cql_utils import cassandra_table_names, run_cql
|
|
6
|
+
from adam.repl_state import ReplState, RequiredState
|
|
7
|
+
from adam.utils import lines_to_tabular
|
|
8
|
+
from adam.utils_k8s.statefulsets import StatefulSets
|
|
9
|
+
|
|
10
|
+
class Code(Command):
|
|
11
|
+
COMMAND = 'python'
|
|
12
|
+
|
|
13
|
+
# the singleton pattern
|
|
14
|
+
def __new__(cls, *args, **kwargs):
|
|
15
|
+
if not hasattr(cls, 'instance'): cls.instance = super(Code, 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 Code.COMMAND
|
|
24
|
+
|
|
25
|
+
def required(self):
|
|
26
|
+
return RequiredState.NAMESPACE
|
|
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
|
+
sts = state.sts
|
|
37
|
+
pod = state.pod
|
|
38
|
+
pods = StatefulSets.pod_names(state.sts, state.namespace)
|
|
39
|
+
tables = cassandra_table_names(state)
|
|
40
|
+
cql = partial(run_cql, state, show_out=True)
|
|
41
|
+
|
|
42
|
+
my_local = globals() | locals()
|
|
43
|
+
# my_local = globals() | {'StatefulSets': StatefulSets} | locals()
|
|
44
|
+
lines = [
|
|
45
|
+
'sts: StatefulSet name',
|
|
46
|
+
'pod: Pod name',
|
|
47
|
+
'pods: Pod names in the current StatefulSet',
|
|
48
|
+
'tables: Cassandra tables names in the current StatefulSet',
|
|
49
|
+
"cql('select...'): run cql statement"
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
code.interact(local=my_local, banner=lines_to_tabular(lines, header='Variables', separator=':'))
|
|
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'{Code.COMMAND} \t invoke interactive Python shell'
|
|
@@ -56,6 +56,9 @@ class Command:
|
|
|
56
56
|
return a
|
|
57
57
|
|
|
58
58
|
def apply_state(self, args: list[str], state: ReplState, resolve_pg = True, args_to_check = 6) -> tuple[ReplState, list[str]]:
|
|
59
|
+
"""
|
|
60
|
+
Applies any contextual arguments such as namespace or statefulset to the ReplState and returns any non-contextual arguments.
|
|
61
|
+
"""
|
|
59
62
|
return state.apply_args(args, cmd=self.command_tokens(), resolve_pg=resolve_pg, args_to_check=args_to_check)
|
|
60
63
|
|
|
61
64
|
def command_tokens(self):
|
|
@@ -23,8 +23,8 @@ def keyspaces(state: ReplState, on_any=False):
|
|
|
23
23
|
|
|
24
24
|
return parse_cql_desc_keyspaces(r.stdout if state.pod else r[0].stdout)
|
|
25
25
|
|
|
26
|
-
def cassandra_table_names(state: ReplState):
|
|
27
|
-
return [f'{k}.{t}' for k, ts in tables(state, on_any=True).items() for t in ts]
|
|
26
|
+
def cassandra_table_names(state: ReplState, keyspace = None):
|
|
27
|
+
return [f'{k}.{t}' for k, ts in tables(state, on_any=True).items() for t in ts if not keyspace or k == keyspace]
|
|
28
28
|
|
|
29
29
|
@functools.lru_cache()
|
|
30
30
|
def tables(state: ReplState, on_any=False) -> dict[str, list[str]]:
|
|
@@ -35,6 +35,15 @@ def tables(state: ReplState, on_any=False) -> dict[str, list[str]]:
|
|
|
35
35
|
|
|
36
36
|
return parse_cql_desc_tables(r.stdout if state.pod else r[0].stdout)
|
|
37
37
|
|
|
38
|
+
@functools.lru_cache()
|
|
39
|
+
def table_spec(state: ReplState, table: str, on_any=False) -> 'TableSpec':
|
|
40
|
+
r: list[PodExecResult] = run_cql(state, f'describe table {table}', show_out=False, on_any=on_any)
|
|
41
|
+
if not r:
|
|
42
|
+
log2('No pod is available')
|
|
43
|
+
return None
|
|
44
|
+
|
|
45
|
+
return parse_cql_desc_table(r.stdout if state.pod else r[0].stdout)
|
|
46
|
+
|
|
38
47
|
def run_cql(state: ReplState, cql: str, opts: list = [], show_out = False, use_single_quotes = False, on_any = False, background=False) -> list[PodExecResult]:
|
|
39
48
|
user, pw = Secrets.get_user_pass(state.sts if state.sts else state.pod, state.namespace, secret_path='cql.secret')
|
|
40
49
|
if use_single_quotes:
|
|
@@ -109,4 +118,87 @@ def parse_cql_desc_keyspaces(out: str) -> list[str]:
|
|
|
109
118
|
if s := ks.strip(' \r\t'):
|
|
110
119
|
kses.append(s)
|
|
111
120
|
|
|
112
|
-
return kses
|
|
121
|
+
return kses
|
|
122
|
+
|
|
123
|
+
class ColumnSpec:
|
|
124
|
+
def __init__(self, name: str, type: str, key_index = -1):
|
|
125
|
+
self.name = name
|
|
126
|
+
self.type = type
|
|
127
|
+
self.key_index = key_index
|
|
128
|
+
|
|
129
|
+
def __eq__(self, other):
|
|
130
|
+
if not isinstance(other, ColumnSpec):
|
|
131
|
+
return NotImplemented # Or raise TypeError, depending on desired strictness
|
|
132
|
+
|
|
133
|
+
# Then, compare the relevant attributes for equality
|
|
134
|
+
return self.name == other.name and self.type == other.type and self.key_index == other.key_index
|
|
135
|
+
|
|
136
|
+
class TableSpec:
|
|
137
|
+
def __init__(self, columns: list[ColumnSpec]):
|
|
138
|
+
self.columns = columns
|
|
139
|
+
|
|
140
|
+
def row_key(self):
|
|
141
|
+
for c in self.columns:
|
|
142
|
+
if c.key_index == 0:
|
|
143
|
+
return c.name
|
|
144
|
+
|
|
145
|
+
def keys(self):
|
|
146
|
+
return [c.name for c in self.columns if c.key_index > -1]
|
|
147
|
+
|
|
148
|
+
def parse_cql_desc_table(out: str) -> TableSpec:
|
|
149
|
+
# CREATE TABLE azops88_db.analyticscontainer_dfeevalhistory (
|
|
150
|
+
# id text,
|
|
151
|
+
# columnname text,
|
|
152
|
+
# version bigint static,
|
|
153
|
+
# contentb blob,
|
|
154
|
+
# contentbool boolean,
|
|
155
|
+
# contentn double,
|
|
156
|
+
# contents text,
|
|
157
|
+
# PRIMARY KEY (id, columnname)
|
|
158
|
+
# ) WITH CLUSTERING ORDER BY (columnname ASC)
|
|
159
|
+
# AND additional_write_policy = '99p'
|
|
160
|
+
# AND bloom_filter_fp_chance = 0.1
|
|
161
|
+
# AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
|
|
162
|
+
# AND cdc = false
|
|
163
|
+
# AND comment = ''
|
|
164
|
+
# AND compaction = {'class': 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
|
|
165
|
+
# AND compression = {'chunk_length_in_kb': '16', 'class': 'org.apache.cassandra.io.compress.SnappyCompressor'}
|
|
166
|
+
# AND memtable = 'default'
|
|
167
|
+
# AND crc_check_chance = 1.0
|
|
168
|
+
# AND default_time_to_live = 0
|
|
169
|
+
# AND extensions = {}
|
|
170
|
+
# AND gc_grace_seconds = 3600
|
|
171
|
+
# AND max_index_interval = 2048
|
|
172
|
+
# AND memtable_flush_period_in_ms = 0
|
|
173
|
+
# AND min_index_interval = 128
|
|
174
|
+
# AND read_repair = 'BLOCKING'
|
|
175
|
+
# AND speculative_retry = '99p';
|
|
176
|
+
pkeys = {}
|
|
177
|
+
columns: list[ColumnSpec] = []
|
|
178
|
+
|
|
179
|
+
state = 's0'
|
|
180
|
+
for line in out.split('\n'):
|
|
181
|
+
if state == 's0':
|
|
182
|
+
if line.startswith('CREATE TABLE'):
|
|
183
|
+
state = 's1'
|
|
184
|
+
elif state == 's1':
|
|
185
|
+
if line.startswith(')'):
|
|
186
|
+
state = 's2'
|
|
187
|
+
continue
|
|
188
|
+
|
|
189
|
+
groups = re.match(r'^\s*PRIMARY KEY\s*\((.*)\).*$', line)
|
|
190
|
+
if groups:
|
|
191
|
+
pkeys = {n.strip(' '): i for i, n in enumerate(groups[1].strip(' \r').split(','))}
|
|
192
|
+
continue
|
|
193
|
+
|
|
194
|
+
groups = re.match(r'^\s*(\S*?)\s*(\S*?),.*$', line)
|
|
195
|
+
if groups:
|
|
196
|
+
columns.append(ColumnSpec(groups[1], groups[2]))
|
|
197
|
+
elif state == 's2':
|
|
198
|
+
pass
|
|
199
|
+
|
|
200
|
+
for column in columns:
|
|
201
|
+
if column.name in pkeys.keys():
|
|
202
|
+
column.key_index = pkeys[column.name]
|
|
203
|
+
|
|
204
|
+
return TableSpec(columns)
|