Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add '--secure' flag in 'chadmin zookeeper' commands #88

Merged
merged 2 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion ch_tools/chadmin/cli/zookeeper_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
@group("zookeeper")
@option("--port", help="ZooKeeper port.", type=int, default=2181)
@option("--host", help="ZooKeeper host.", type=str)
@option("--secure", help="Use secure connection.", default=False, is_flag=True)
@option(
"--verify-ssl-certs/--no-verify-ssl-certs",
help="Check or not SSL Certificates in secure connection.",
default=True,
)
@option("--timeout", help="ZooKeeper timeout.", default=10)
@option(
"--zkcli-identity",
Expand Down Expand Up @@ -52,7 +58,16 @@
)
@pass_context
def zookeeper_group(
ctx, host, port, timeout, zkcli_identity, no_chroot, no_ch_config, zk_root_path
ctx,
host,
secure,
verify_ssl_certs,
port,
timeout,
zkcli_identity,
no_chroot,
no_ch_config,
zk_root_path,
):
"""ZooKeeper management commands.

Expand All @@ -64,6 +79,8 @@ def zookeeper_group(
ctx.obj["zk_client_args"] = {
"port": port,
"host": host,
"use_ssl": secure,
"verify_ssl_certs": verify_ssl_certs,
"timeout": timeout,
"zkcli_identity": zkcli_identity,
"no_chroot": no_chroot,
Expand Down
9 changes: 8 additions & 1 deletion ch_tools/chadmin/internal/zookeeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ def _get_zk_client(ctx):
args = ctx.obj.get("zk_client_args", {})
host = args.get("host")
port = args.get("port", 2181)
use_ssl = args.get("use_ssl", False)
verify_ssl_certs = args.get("verify_ssl_certs", True)
timeout = args.get("timeout", 10)
zkcli_identity = args.get("zkcli_identity")
no_chroot = args.get("no_chroot", False)
Expand Down Expand Up @@ -334,5 +336,10 @@ def _get_zk_client(ctx):
auth_data = [("digest", zkcli_identity)]

return KazooClient(
connect_str, auth_data=auth_data, timeout=timeout, logger=logging.getLogger()
connect_str,
auth_data=auth_data,
timeout=timeout,
logger=logging.getLogger(),
use_ssl=use_ssl,
verify_certs=verify_ssl_certs,
)