In this way, the auto-balancing functionality of the
maintenance daemon can conveniently be controlled via
the OpSetParams opcode.

Signed-off-by: Klaus Aehlig <[email protected]>
---
 lib/cmdlib/cluster/__init__.py |  6 ++++++
 lib/config/__init__.py         | 10 ++++++++++
 2 files changed, 16 insertions(+)

diff --git a/lib/cmdlib/cluster/__init__.py b/lib/cmdlib/cluster/__init__.py
index 6f395a6..39c2186 100644
--- a/lib/cmdlib/cluster/__init__.py
+++ b/lib/cmdlib/cluster/__init__.py
@@ -1798,6 +1798,12 @@ class LUClusterSetParams(LogicalUnit):
     if self.op.maint_round_delay is not None:
       self.cfg.SetMaintdRoundDelay(self.op.maint_round_delay)
 
+    if self.op.maint_balance is not None:
+      self.cfg.SetMaintdBalance(self.op.maint_balance)
+
+    if self.op.maint_balance_threshold is not None:
+      self.cfg.SetMaintdBalanceThreshold(self.op.maint_balance_threshold)
+
     network_name = self.op.instance_communication_network
     if network_name is not None:
       return self._ModifyInstanceCommunicationNetwork(self.cfg,
diff --git a/lib/config/__init__.py b/lib/config/__init__.py
index 618a8f6..cc25bb1 100644
--- a/lib/config/__init__.py
+++ b/lib/config/__init__.py
@@ -3388,6 +3388,16 @@ class ConfigWriter(object):
     utils.SimpleRetry(True, self._wconfd.SetMaintdRoundDelay, 0.1, 30,
                       args=[delay])
 
+  def SetMaintdBalance(self, flag):
+    """Enable/disable auto-balancing by the maintenance daemon"""
+    utils.SimpleRetry(True, self._wconfd.SetMaintdBalance, 0.1, 30,
+                      args=[flag])
+
+  def SetMaintdBalanceThreshold(self, score):
+    """Set the minimal score improvement per move for balancing steps"""
+    utils.SimpleRetry(True, self._wconfd.SetMaintdBalanceThreshold, 0.1, 30,
+                      args=[score])
+
 
 class DetachedConfig(ConfigWriter):
   """Read-only snapshot of the config."""
-- 
2.4.3.573.g4eafbef

Reply via email to