From 35e994e9304cd227e4524333594fc538d81a7d7d Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 2 Mar 2009 12:19:45 +0000 Subject: [PATCH] Export tags to cluster verify hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch export the cluster and node tags to the cluster verify hook scripts. The tags are exported as a space-separated list, which allows easy parsing from the shell (e.g. βfor tag in $GANETI_CLUSTER_TAGS; do ...β) and therefore requires the previous βDon't allow spaces in tag namesβ patch. The patch also fixes a minor line length style problem. Reviewed-by: ultrotter --- doc/hooks.rst | 8 +++++++- lib/cmdlib.py | 15 ++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/doc/hooks.rst b/doc/hooks.rst index 7df231cf7..7dbe7d5e9 100644 --- a/doc/hooks.rst +++ b/doc/hooks.rst @@ -304,7 +304,7 @@ post-execution hooks, in order to allow administrators to enhance the cluster verification procedure. :directory: cluster-verify -:env. vars: CLUSTER, MASTER +:env. vars: CLUSTER, MASTER, CLUSTER_TAGS, NODE_TAGS_<name> :pre-execution: none :post-execution: all nodes @@ -478,6 +478,12 @@ EXPORT_DO_SHUTDOWN the filesystem would need a check (journal replay or full fsck) in order to guarantee consistency. +CLUSTER_TAGS + The list of cluster tags, space separated. + +NODE_TAGS_<name> + The list of tags for node *<name>*, space separated. + Examples -------- diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 6bdc26340..6ad6c0406 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -782,12 +782,13 @@ class LUVerifyCluster(LogicalUnit): else: for minor, (iname, must_exist) in drbd_map.items(): if minor not in used_minors and must_exist: - feedback_fn(" - ERROR: drbd minor %d of instance %s is not active" % - (minor, iname)) + feedback_fn(" - ERROR: drbd minor %d of instance %s is" + " not active" % (minor, iname)) bad = True for minor in used_minors: if minor not in drbd_map: - feedback_fn(" - ERROR: unallocated drbd minor %d is in use" % minor) + feedback_fn(" - ERROR: unallocated drbd minor %d is in use" % + minor) bad = True return bad @@ -915,8 +916,12 @@ class LUVerifyCluster(LogicalUnit): """ all_nodes = self.cfg.GetNodeList() - # TODO: populate the environment with useful information for verify hooks - env = {} + env = { + "CLUSTER_TAGS": " ".join(self.cfg.GetClusterInfo().GetTags()) + } + for node in self.cfg.GetAllNodesInfo().values(): + env["NODE_TAGS_%s" % node.name] = " ".join(node.GetTags()) + return env, [], all_nodes def Exec(self, feedback_fn): -- GitLab