From 4fe80ef2ed1cda3a6357274eccafe5c1f21a5283 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 1 Dec 2009 14:02:12 +0100 Subject: [PATCH] Move the hooks file mask into constants.py This will allow reuse of the same mask for multiple validations. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/backend.py | 4 +--- lib/constants.py | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/backend.py b/lib/backend.py index f4e308e65..44e45f63a 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -2499,8 +2499,6 @@ class HooksRunner(object): on the master side. """ - RE_MASK = re.compile("^[a-zA-Z0-9_-]+$") - def __init__(self, hooks_base_dir=None): """Constructor for hooks runner. @@ -2607,7 +2605,7 @@ class HooksRunner(object): for relname in dir_contents: fname = os.path.join(dir_name, relname) if not (os.path.isfile(fname) and os.access(fname, os.X_OK) and - self.RE_MASK.match(relname) is not None): + constants.EXT_PLUGIN_MASK.match(relname) is not None): rrval = constants.HKR_SKIP output = "" else: diff --git a/lib/constants.py b/lib/constants.py index e5dafb174..02cb385ca 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -21,6 +21,8 @@ """Module holding different constants.""" +import re + from ganeti import _autoconf # various versions @@ -144,6 +146,9 @@ VALUE_NONE = "none" VALUE_TRUE = "true" VALUE_FALSE = "false" +# External script validation mask +EXT_PLUGIN_MASK = re.compile("^[a-zA-Z0-9_-]+$") + # hooks-related constants HOOKS_BASE_DIR = _autoconf.SYSCONFDIR + "/ganeti/hooks" HOOKS_PHASE_PRE = "pre" -- GitLab