From 6520ba1457f3785b6bae4e80c8ed00f7369d11c0 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Mon, 6 Sep 2010 16:31:04 +0100
Subject: [PATCH] Check for nodegroup uuid indexing

Since the uuid is immutable the probability of it getting out of sync
between the object and the dict key is very low. Still, checking is
cheap, so we do it to be more sure nothing is wrong.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/config.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/config.py b/lib/config.py
index 07bc65575..93f591304 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -461,6 +461,13 @@ class ConfigWriter:
                       (node.name, node.master_candidate, node.drain,
                        node.offline))
 
+    # nodegroups checks
+    for nodegroup_uuid in data.nodegroups:
+      nodegroup = data.nodegroups[nodegroup_uuid]
+      if nodegroup.uuid != nodegroup_uuid:
+        result.append("nodegroup '%s' (uuid: '%s') indexed by wrong uuid '%s'"
+                      % (nodegroup.name, nodegroup.uuid, nodegroup_uuid))
+
     # drbd minors check
     _, duplicates = self._UnlockedComputeDRBDMap()
     for node, minor, instance_a, instance_b in duplicates:
-- 
GitLab