This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
certbot-haproxy/certbot_haproxy/constants.py

37 lines
1.1 KiB
Python

"""HAProxy plugin constants."""
from certbot import util
CLI_DEFAULTS_DEBIAN_JESSIE = dict(
server_root="/etc/haproxy",
version_cmd=['haproxy', '-v'],
restart_cmd=['systemctl', 'restart', 'haproxy'],
conftest_cmd=['haproxy' '-c' '-f'], # Need the config file as an argument.
)
CLI_DEFAULTS_DEBIAN_WHEEZY = dict(
server_root="/etc/haproxy",
version_cmd=['haproxy', '-v'],
restart_cmd=['service', 'haproxy', 'restart'],
conftest_cmd=['haproxy' '-c' '-f'], # Need the config file as an argument.
)
CLI_DEFAULTS = {
"debian": CLI_DEFAULTS_DEBIAN_JESSIE,
"debian:jessie": CLI_DEFAULTS_DEBIAN_JESSIE,
"debian:wheezy": CLI_DEFAULTS_DEBIAN_WHEEZY,
"ubuntu": CLI_DEFAULTS_DEBIAN_WHEEZY
}
def os_constant(key):
"""Get a constant value for operating system
:param key: name of cli constant
:return: value of constant for active os
"""
os_info = util.get_os_info()
try:
constants = CLI_DEFAULTS[os_info[0].lower()]
except KeyError:
constants = CLI_DEFAULTS["debian"]
return constants[key]