From d52ea9917007a1b16d6542fad00292c188a0c66f Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Thu, 22 Oct 2009 17:20:16 +0200
Subject: [PATCH] cmdlib._AssembleInstanceDisks: Fix case where variable
 wouldn't be set
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The β€œresult” variable may not be set and/or come from the previous loop.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 lib/cmdlib.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 63378717f..436cc6e81 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -3352,6 +3352,8 @@ def _AssembleInstanceDisks(lu, instance, ignore_secondaries=False,
 
   # 2nd pass, do only the primary node
   for inst_disk in instance.disks:
+    dev_path = None
+
     for node, node_disk in inst_disk.ComputeNodeTree(instance.primary_node):
       if node != instance.primary_node:
         continue
@@ -3366,8 +3368,10 @@ def _AssembleInstanceDisks(lu, instance, ignore_secondaries=False,
                            " (is_primary=True, pass=2): %s",
                            inst_disk.iv_name, node, msg)
         disks_ok = False
-    device_info.append((instance.primary_node, inst_disk.iv_name,
-                        result.payload))
+      else:
+        dev_path = result.payload
+
+    device_info.append((instance.primary_node, inst_disk.iv_name, dev_path))
 
   # leave the disks configured for the primary node
   # this is a workaround that would be fixed better by
-- 
GitLab