From 2ee88aeb76a2430ec0c7f86629bf66cfd0b6f564 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Tue, 9 Jun 2009 17:25:46 +0100
Subject: [PATCH] LUSetInstanceParams: save cluster

Rather than querying for the cluster multiple times, save it.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/cmdlib.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 6037efa3b..16b4ec966 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -5985,6 +5985,7 @@ class LUSetInstanceParams(LogicalUnit):
     # checking the new params on the primary/secondary nodes
 
     instance = self.instance = self.cfg.GetInstanceInfo(self.op.instance_name)
+    cluster = self.cluster = self.cfg.GetClusterInfo()
     assert self.instance is not None, \
       "Cannot retrieve locked instance %s" % self.op.instance_name
     pnode = instance.primary_node
@@ -6001,7 +6002,6 @@ class LUSetInstanceParams(LogicalUnit):
             pass
         else:
           i_hvdict[key] = val
-      cluster = self.cfg.GetClusterInfo()
       utils.ForceDictType(i_hvdict, constants.HVS_PARAMETER_TYPES)
       hv_new = objects.FillDict(cluster.hvparams[instance.hypervisor],
                                 i_hvdict)
@@ -6025,7 +6025,6 @@ class LUSetInstanceParams(LogicalUnit):
             pass
         else:
           i_bedict[key] = val
-      cluster = self.cfg.GetClusterInfo()
       utils.ForceDictType(i_bedict, constants.BES_PARAMETER_TYPES)
       be_new = objects.FillDict(cluster.beparams[constants.PP_DEFAULT],
                                 i_bedict)
-- 
GitLab