Commit 0e137c28 authored by Iustin Pop's avatar Iustin Pop

Some small improvements to the hooks environment

For the configuration update hook, it's useful to have a consistent name
for the target of the operation. As such, the LU code is modified to
include an GANETI_OP_TARGET that points either to the cluster (name),
node name or instance name depending on the opcode.

Also, the NoHooksLU is modified such that its build env method returns
an empty (but conformant) result. This should improve things in case by
mistake this class' BuildHooksEnv is called.

Reviewed-by: imsnah
parent 6a4aa7c1
......@@ -161,7 +161,7 @@ class NoHooksLU(LogicalUnit):
This is a no-op, since we don't run hooks.
"""
return
return {}, [], []
def _GetWantedNodes(lu, nodes):
......@@ -239,6 +239,7 @@ def _BuildInstanceHookEnv(name, primary_node, secondary_nodes, os_type, status,
secondary_nodes: List of secondary nodes as strings
"""
env = {
"OP_TARGET": name,
"INSTANCE_NAME": name,
"INSTANCE_PRIMARY": primary_node,
"INSTANCE_SECONDARIES": " ".join(secondary_nodes),
......@@ -545,7 +546,8 @@ class LUInitCluster(LogicalUnit):
ourselves in the post-run node list.
"""
return {}, [], [self.hostname.name]
env = {"OP_TARGET": self.op.cluster_name}
return env, [], [self.hostname.name]
def CheckPrereq(self):
"""Verify that the passed name is a valid one.
......@@ -936,6 +938,7 @@ class LURenameCluster(LogicalUnit):
"""
env = {
"OP_TARGET": self.op.sstore.GetClusterName(),
"NEW_NAME": self.op.name,
}
mn = self.sstore.GetMasterNode()
......@@ -1126,6 +1129,7 @@ class LURemoveNode(LogicalUnit):
"""
env = {
"OP_TARGET": self.op.node_name,
"NODE_NAME": self.op.node_name,
}
all_nodes = self.cfg.GetNodeList()
......@@ -1365,6 +1369,7 @@ class LUAddNode(LogicalUnit):
"""
env = {
"OP_TARGET": self.op.node_name,
"NODE_NAME": self.op.node_name,
"NODE_PIP": self.op.primary_ip,
"NODE_SIP": self.op.secondary_ip,
......@@ -1587,6 +1592,7 @@ class LUMasterFailover(LogicalUnit):
"""
env = {
"OP_TARGET": self.new_master,
"NEW_MASTER": self.new_master,
"OLD_MASTER": self.old_master,
}
......
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