When looking up configuration data of instances which don't
exist, the code so far fails with a cryptic error messages
about NoneType not having an attribute. Although actually
this situation should not happen, let's at least throw an
exception with a proper description.

Signed-off-by: Helga Velroyen <[email protected]>
---
 lib/cmdlib/cluster.py | 2 +-
 lib/config.py         | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/cmdlib/cluster.py b/lib/cmdlib/cluster.py
index 30e35c4..6cb1401 100644
--- a/lib/cmdlib/cluster.py
+++ b/lib/cmdlib/cluster.py
@@ -2892,7 +2892,7 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
     if test:
       nimg.hyp_fail = True
     else:
-      nimg.instances = [inst.uuid for (_, inst) in
+      nimg.instances = [uuid for (uuid, _) in
                         self.cfg.GetMultiInstanceInfoByName(idata)]
 
   def _UpdateNodeInfo(self, ninfo, nresult, nimg, vg_name):
diff --git a/lib/config.py b/lib/config.py
index b6f1373..7729cda 100644
--- a/lib/config.py
+++ b/lib/config.py
@@ -1782,7 +1782,11 @@ class ConfigWriter(object):
     result = []
     for name in inst_names:
       instance = self._UnlockedGetInstanceInfoByName(name)
-      result.append((instance.uuid, instance))
+      if instance:
+        result.append((instance.uuid, instance))
+      else:
+        raise errors.ConfigurationError("Instance data of instance '%s'"
+                                        " not found." % name)
     return result
 
   @locking.ssynchronized(_config_lock, shared=1)
-- 
2.2.0.rc0.207.ga3a616c

Reply via email to