From c0f2b2296f1e6f58a0b74c99f27869823918cab8 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 14 Oct 2008 14:42:49 +0000
Subject: [PATCH] Some fixes related to auto_balance

Change the constant name to match the value (autobalance ->
auto_balance).

Also add the auto_balance header so that gnt-instance can list it.

Reviewed-by: ultrotter
---
 lib/cmdlib.py        | 10 +++++-----
 lib/constants.py     |  4 ++--
 scripts/gnt-instance |  1 +
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 62c1c8d0c..e0cbe8680 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -691,7 +691,7 @@ class LUVerifyCluster(LogicalUnit):
         needed_mem = 0
         for instance in instances:
           bep = self.cfg.GetClusterInfo().FillBE(instance_cfg[instance])
-          if bep[constants.BE_AUTOBALANCE]:
+          if bep[constants.BE_AUTO_BALANCE]:
             needed_mem += bep[constants.BE_MEMORY]
         if nodeinfo['mfree'] < needed_mem:
           feedback_fn("  - ERROR: not enough memory on node %s to accomodate"
@@ -857,7 +857,7 @@ class LUVerifyCluster(LogicalUnit):
         feedback_fn("  - WARNING: multiple secondaries for instance %s"
                     % instance)
 
-      if not cluster.FillBE(inst_config)[constants.BE_AUTOBALANCE]:
+      if not cluster.FillBE(inst_config)[constants.BE_AUTO_BALANCE]:
         i_non_a_balanced.append(instance)
 
       for snode in inst_config.secondary_nodes:
@@ -4625,8 +4625,8 @@ class LUSetInstanceParams(LogicalUnit):
 
     if constants.BE_MEMORY in self.op.beparams and not self.force:
       mem_check_list = [pnode]
-      if be_new[constants.BE_AUTOBALANCE]:
-        # either we changed autobalance to yes or it was from before
+      if be_new[constants.BE_AUTO_BALANCE]:
+        # either we changed auto_balance to yes or it was from before
         mem_check_list.extend(instance.secondary_nodes)
       instance_info = self.rpc.call_instance_info(pnode, instance.name,
                                                   instance.hypervisor)
@@ -4651,7 +4651,7 @@ class LUSetInstanceParams(LogicalUnit):
                                      " from starting, due to %d MB of memory"
                                      " missing on its primary node" % miss_mem)
 
-      if be_new[constants.BE_AUTOBALANCE]:
+      if be_new[constants.BE_AUTO_BALANCE]:
         for node in instance.secondary_nodes:
           if node not in nodeinfo or not isinstance(nodeinfo[node], dict):
             self.warn.append("Can't get info from secondary node %s" % node)
diff --git a/lib/constants.py b/lib/constants.py
index 69049cceb..6dae29462 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -278,12 +278,12 @@ HVS_PARAMETERS = frozenset([
 # BE parameter names
 BE_MEMORY = "memory"
 BE_VCPUS = "vcpus"
-BE_AUTOBALANCE = "auto_balance"
+BE_AUTO_BALANCE = "auto_balance"
 
 BES_PARAMETERS = frozenset([
   BE_MEMORY,
   BE_VCPUS,
-  BE_AUTOBALANCE,
+  BE_AUTO_BALANCE,
   ])
 
 # BE GROUP
diff --git a/scripts/gnt-instance b/scripts/gnt-instance
index 266b84127..8d31219c2 100755
--- a/scripts/gnt-instance
+++ b/scripts/gnt-instance
@@ -201,6 +201,7 @@ def ListInstances(opts, args):
       "hvparams": "Hypervisor_parameters",
       "be/memory": "Configured_memory",
       "be/vcpus": "VCPUs",
+      "be/auto_balance": "Auto_balance",
       }
   else:
     headers = None
-- 
GitLab