Commit 4fe80ef2 authored by Iustin Pop's avatar Iustin Pop

Move the hooks file mask into constants.py

This will allow reuse of the same mask for multiple validations.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 4dfd6266
......@@ -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:
......
......@@ -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"
......
Markdown is supported
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