From b906d7c128fe6615b4e528c840a7e1b3758043de Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 5 Mar 2012 13:55:54 +0100 Subject: [PATCH] Add a helper type and function for the mirror type Currently we track the mirroring type as simply yes/no, with "yes" meaning DRBD. This is not enough for handling shared storage, so we need to add a type that gives the exact mirroring type (none, internal, external), and a function that ties the disk template type to the mirroring type. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- htools/Ganeti/HTools/Types.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/htools/Ganeti/HTools/Types.hs b/htools/Ganeti/HTools/Types.hs index 216b011c1..90cc6539e 100644 --- a/htools/Ganeti/HTools/Types.hs +++ b/htools/Ganeti/HTools/Types.hs @@ -58,6 +58,8 @@ module Ganeti.HTools.Types , DiskTemplate(..) , diskTemplateToRaw , diskTemplateFromRaw + , MirrorType(..) + , templateMirrorType , MoveJob , JobSet , Result(..) @@ -124,6 +126,22 @@ $(THH.declareSADT "DiskTemplate" ]) $(THH.makeJSONInstance ''DiskTemplate) +-- | Mirroring type. +data MirrorType = MirrorNone -- ^ No mirroring/movability + | MirrorInternal -- ^ DRBD-type mirroring + | MirrorExternal -- ^ Shared-storage type mirroring + deriving (Eq, Show, Read) + +-- | Correspondence between disk template and mirror type. +templateMirrorType :: DiskTemplate -> MirrorType +templateMirrorType DTDiskless = MirrorExternal +templateMirrorType DTFile = MirrorNone +templateMirrorType DTSharedFile = MirrorExternal +templateMirrorType DTPlain = MirrorNone +templateMirrorType DTBlock = MirrorExternal +templateMirrorType DTDrbd8 = MirrorInternal +templateMirrorType DTRbd = MirrorExternal + -- | The Group allocation policy type. -- -- Note that the order of constructors is important as the automatic -- GitLab