Commit ebc75510 authored by Michael Hanselmann's avatar Michael Hanselmann

HooksMaster: Add more assertions for variable names

Also replace explicit loop with dict.update.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 0306ff62
...@@ -39,6 +39,7 @@ from ganeti import rpc ...@@ -39,6 +39,7 @@ from ganeti import rpc
from ganeti import cmdlib from ganeti import cmdlib
from ganeti import locking from ganeti import locking
from ganeti import utils from ganeti import utils
from ganeti import compat
_OP_PREFIX = "Op" _OP_PREFIX = "Op"
...@@ -448,10 +449,11 @@ class HooksMaster(object): ...@@ -448,10 +449,11 @@ class HooksMaster(object):
} }
if self.lu.HPATH is not None: if self.lu.HPATH is not None:
lu_env, lu_nodes_pre, lu_nodes_post = self.lu.BuildHooksEnv() (lu_env, lu_nodes_pre, lu_nodes_post) = self.lu.BuildHooksEnv()
if lu_env: if lu_env:
for key in lu_env: assert not compat.any(key.upper().startswith("GANETI")
env["GANETI_" + key] = lu_env[key] for key in lu_env)
env.update(("GANETI_%s" % key, value) for (key, value) in lu_env)
else: else:
lu_nodes_pre = lu_nodes_post = [] lu_nodes_pre = lu_nodes_post = []
...@@ -472,6 +474,10 @@ class HooksMaster(object): ...@@ -472,6 +474,10 @@ class HooksMaster(object):
env = dict([(str(key), str(val)) for key, val in env.iteritems()]) env = dict([(str(key), str(val)) for key, val in env.iteritems()])
assert compat.all(key == key.upper() and
(key == "PATH" or key.startswith("GANETI_"))
for key in env)
return self.callfn(node_list, hpath, phase, env) return self.callfn(node_list, hpath, phase, env)
def RunPhase(self, phase, nodes=None): def RunPhase(self, phase, nodes=None):
......
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