Commit d95216a0 authored by Chris's avatar Chris
Browse files

Improve handling of --haproxy-sockets from config files and overriding arguments.

parent c5ba15bc
......@@ -499,15 +499,19 @@ def __get_haproxy_socket_mapping(args):
# files in the sockets dictionary.
for i, paths in enumerate(conf_cert_paths):
for path in paths:
if path in mapping:
# When certificate path is already in the mapping add the socket
# file to the mapping if haproxy_sockets is not disabled.
if args.haproxy_sockets is False:
# haproxy_sockets are disabled, just ensure the path is in the
# mapping without sockets.
mapping[path] = []
else:
# Make sure paths are mapped to all unique sockets.
mapping[path] = unique(
mapping[path] + conf_haproxy_sockets[i],
mapping.get(path, []) + conf_haproxy_sockets[i],
preserve_order=False
)
else:
mapping[path] = conf_haproxy_sockets[i]
logger.debug("Paths to socket mapping: %s", str(mapping))
logger.debug("Paths to socket mappings: %s", str(mapping))
return mapping
......@@ -537,47 +541,6 @@ def __get_validated_args():
return args
def __get_haproxy_socket_mapping(args):
"""
Get mapping of configured sockets and certificate directories.
From: haproxy config, stapled config and command line arguments.
:param Namespace args: Argparser argument list.
:return dict Of cert-paths and sockets for inform of changes.
"""
# Parse the cert_paths argument
arg_cert_paths = __get_arg_cert_paths(args)
# Parse haproxy_sockets argument.
arg_haproxy_sockets = __get_arg_haproxy_sockets(args)
# Make a mapping from certificate paths to sockets in a dict.
mapping = dict(zip(arg_cert_paths, arg_haproxy_sockets))
# Parse HAProxy config files.
try:
conf_cert_paths, conf_haproxy_sockets = parse_haproxy_config(
args.haproxy_config
)
except (OSError) as exc:
logger.critical(exc)
exit(1)
# Combine the socket and certificate paths of the arguments and config
# files in the sockets dictionary.
for i, paths in enumerate(conf_cert_paths):
for path in paths:
if path in mapping:
mapping[path] = unique(
mapping[path] + conf_haproxy_sockets[i],
preserve_order=False
)
else:
mapping[path] = conf_haproxy_sockets[i]
logger.debug("Paths to socket mapping: %s", str(mapping))
return mapping
if __name__ == '__main__':
try:
init()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment