From a10a476a4f4f0d3da9819ea9980158b7abbaa1aa Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Sat, 2 Jul 2011 23:44:22 +0200
Subject: [PATCH] htools: add an utility function for disk templates

In the future we'll use this instead of requiring the number of nodes
from the user.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 htools/Ganeti/HTools/Instance.hs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/htools/Ganeti/HTools/Instance.hs b/htools/Ganeti/HTools/Instance.hs
index dc070e488..873275595 100644
--- a/htools/Ganeti/HTools/Instance.hs
+++ b/htools/Ganeti/HTools/Instance.hs
@@ -41,6 +41,7 @@ module Ganeti.HTools.Instance
     , specOf
     , shrinkByType
     , runningStates
+    , requiredNodes
     ) where
 
 import qualified Ganeti.HTools.Types as T
@@ -183,3 +184,8 @@ shrinkByType _ f = T.Bad $ "Unhandled failure mode " ++ show f
 specOf :: Instance -> T.RSpec
 specOf Instance { mem = m, dsk = d, vcpus = c } =
     T.RSpec { T.rspecCpu = c, T.rspecMem = m, T.rspecDsk = d }
+
+-- | Computed the number of nodes for a given disk template
+requiredNodes :: T.DiskTemplate -> Int
+requiredNodes T.DTDrbd8 = 2
+requiredNodes _         = 1
-- 
GitLab