From ee2f0ed4ee397308459ece5346bd92a63d697903 Mon Sep 17 00:00:00 2001
From: Luca Bigliardi <shammash@google.com>
Date: Fri, 25 Jun 2010 11:01:10 +0100
Subject: [PATCH] Set drbd usermode helper on config upgrade

Signed-off-by: Luca Bigliardi <shammash@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/constants.py | 1 +
 lib/objects.py   | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/lib/constants.py b/lib/constants.py
index 4e388b8bc..32aa2acf7 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -441,6 +441,7 @@ IP6_ADDRESS_ANY = "::"
 TCP_PING_TIMEOUT = 10
 GANETI_RUNAS = "root"
 DEFAULT_VG = "xenvg"
+DEFAULT_DRBD_HELPER = "/bin/true"
 MIN_VG_SIZE = 20480
 DEFAULT_MAC_PREFIX = "aa:00:00"
 LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
diff --git a/lib/objects.py b/lib/objects.py
index 9e9163cbb..42036e180 100644
--- a/lib/objects.py
+++ b/lib/objects.py
@@ -364,6 +364,12 @@ class ConfigData(ConfigObject):
       node.UpgradeConfig()
     for instance in self.instances.values():
       instance.UpgradeConfig()
+    if self.cluster.drbd_usermode_helper is None:
+      # To decide if we set an helper let's check if at least one instance has
+      # a DRBD disk. This does not cover all the possible scenarios but it
+      # gives a good approximation.
+      if self.HasAnyDiskOfType(constants.LD_DRBD8):
+        self.cluster.drbd_usermode_helper = constants.DEFAULT_DRBD_HELPER
 
 
 class NIC(ConfigObject):
-- 
GitLab