Some daemons will need more than the single logfile that is currently allowed. This patch introduces the infrastructure to allow this.
Signed-off-by: Michele Tartara <[email protected]> --- lib/constants.py | 27 +++++++++++++++++++++++++++ test/py/ganeti.constants_unittest.py | 6 ++++++ 2 files changed, 33 insertions(+) diff --git a/lib/constants.py b/lib/constants.py index 80254d0..fadca60 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -158,6 +158,13 @@ CONFD = "ganeti-confd" RAPI = "ganeti-rapi" MASTERD = "ganeti-masterd" +DAEMONS = compat.UniqueFrozenset([ + NODED, + CONFD, + RAPI, + MASTERD, + ]) + DAEMONS_PORTS = { # daemon-name: ("proto", "default-port") NODED: ("tcp", 1811), @@ -183,6 +190,26 @@ DAEMONS_LOGFILES = \ dict((daemon, pathutils.GetLogFilename(DAEMONS_LOGBASE[daemon])) for daemon in DAEMONS_LOGBASE) +# Some daemons might require more than one logfile. + +# These are the only valid reasons for having an extra logfile +EXTRA_LOGREASON_ACCESS = "access" +EXTRA_LOGREASON_ERROR = "error" + +VALID_EXTRA_LOGREASONS = compat.UniqueFrozenset([ + EXTRA_LOGREASON_ACCESS, + EXTRA_LOGREASON_ERROR, + ]) + +# These are the extra logfiles, grouped by daemon +DAEMONS_EXTRA_LOGBASE = {} + +DAEMONS_EXTRA_LOGFILES = \ + dict((daemon, dict((extra, + pathutils.GetLogFilename(DAEMONS_EXTRA_LOGBASE[daemon][extra])) + for extra in DAEMONS_EXTRA_LOGBASE[daemon])) + for daemon in DAEMONS_EXTRA_LOGBASE) + DEV_CONSOLE = "/dev/console" PROC_MOUNTS = "/proc/mounts" diff --git a/test/py/ganeti.constants_unittest.py b/test/py/ganeti.constants_unittest.py index 9b7edcd..0e21feb 100755 --- a/test/py/ganeti.constants_unittest.py +++ b/test/py/ganeti.constants_unittest.py @@ -98,6 +98,12 @@ class TestConstants(unittest.TestCase): self.assertTrue(constants.DEFAULT_ENABLED_HYPERVISOR in constants.HYPER_TYPES) + def testExtraLogfiles(self): + for daemon in constants.DAEMONS_EXTRA_LOGBASE: + self.assertTrue(daemon in constants.DAEMONS) + for log_reason in constants.DAEMONS_EXTRA_LOGBASE[daemon]: + self.assertTrue(log_reason in constants.VALID_EXTRA_LOGREASONS) + class TestExportedNames(unittest.TestCase): _VALID_NAME_RE = re.compile(r"^[A-Z][A-Z0-9_]+$") -- 1.8.1.3
