From d25643d188b67de105bf4a1eca16525b26a54dd2 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Sat, 2 Jul 2011 23:18:25 +0200 Subject: [PATCH] htools: add DiskTemplate to instance definition Currently always fixed to DRBD8, as that is what we assume already. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- htools/Ganeti/HTools/IAlloc.hs | 2 +- htools/Ganeti/HTools/Instance.hs | 6 ++++-- htools/Ganeti/HTools/Luxi.hs | 2 +- htools/Ganeti/HTools/QC.hs | 2 ++ htools/Ganeti/HTools/Rapi.hs | 2 +- htools/Ganeti/HTools/Text.hs | 2 +- htools/hspace.hs | 2 +- 7 files changed, 11 insertions(+), 7 deletions(-) diff --git a/htools/Ganeti/HTools/IAlloc.hs b/htools/Ganeti/HTools/IAlloc.hs index b53d7747a..d45559f32 100644 --- a/htools/Ganeti/HTools/IAlloc.hs +++ b/htools/Ganeti/HTools/IAlloc.hs @@ -67,7 +67,7 @@ parseBaseInstance n a = do vcpus <- extract "vcpus" tags <- extract "tags" let running = "running" - return (n, Instance.create n mem disk vcpus running tags True 0 0) + return (n, Instance.create n mem disk vcpus running tags True 0 0 DTDrbd8) -- | Parses an instance as found in the cluster instance list. parseInstance :: NameAssoc -- ^ The node name-to-index association list diff --git a/htools/Ganeti/HTools/Instance.hs b/htools/Ganeti/HTools/Instance.hs index 4cf80586d..dc070e488 100644 --- a/htools/Ganeti/HTools/Instance.hs +++ b/htools/Ganeti/HTools/Instance.hs @@ -65,6 +65,7 @@ data Instance = Instance , movable :: Bool -- ^ Can the instance be moved? , autoBalance :: Bool -- ^ Is the instance auto-balanced? , tags :: [String] -- ^ List of instance tags + , diskTemplate :: T.DiskTemplate -- ^ The disk template of the instance } deriving (Show, Read) instance T.Element Instance where @@ -91,9 +92,9 @@ type List = Container.Container Instance -- Some parameters are not initialized by function, and must be set -- later (via 'setIdx' for example). create :: String -> Int -> Int -> Int -> String - -> [String] -> Bool -> T.Ndx -> T.Ndx -> Instance + -> [String] -> Bool -> T.Ndx -> T.Ndx -> T.DiskTemplate -> Instance create name_init mem_init dsk_init vcpus_init run_init tags_init - auto_balance_init pn sn = + auto_balance_init pn sn dt = Instance { name = name_init , alias = name_init , mem = mem_init @@ -108,6 +109,7 @@ create name_init mem_init dsk_init vcpus_init run_init tags_init , tags = tags_init , movable = True , autoBalance = auto_balance_init + , diskTemplate = dt } -- | Changes the index. diff --git a/htools/Ganeti/HTools/Luxi.hs b/htools/Ganeti/HTools/Luxi.hs index 1fd3bf3df..ce0f21aa8 100644 --- a/htools/Ganeti/HTools/Luxi.hs +++ b/htools/Ganeti/HTools/Luxi.hs @@ -131,7 +131,7 @@ parseInstance ktn (JSArray [ name, disk, mem, vcpus xtags <- convert "tags" tags xauto_balance <- convert "auto_balance" auto_balance let inst = Instance.create xname xmem xdisk xvcpus - xrunning xtags xauto_balance xpnode snode + xrunning xtags xauto_balance xpnode snode DTDrbd8 return (xname, inst) parseInstance _ v = fail ("Invalid instance query result: " ++ show v) diff --git a/htools/Ganeti/HTools/QC.hs b/htools/Ganeti/HTools/QC.hs index a03302629..12d0d2204 100644 --- a/htools/Ganeti/HTools/QC.hs +++ b/htools/Ganeti/HTools/QC.hs @@ -111,6 +111,7 @@ setInstanceSmallerThanNode node inst = -- | Create an instance given its spec. createInstance mem dsk vcpus = Instance.create "inst-unnamed" mem dsk vcpus "running" [] True (-1) (-1) + Types.DTDrbd8 -- | Create a small cluster by repeating a node spec. makeSmallCluster :: Node.Node -> Int -> Node.List @@ -191,6 +192,7 @@ instance Arbitrary Instance.Instance where sn <- arbitrary vcpus <- choose (0, maxCpu) return $ Instance.create name mem dsk vcpus run_st [] True pn sn + Types.DTDrbd8 -- | Generas an arbitrary node based on sizing information. genNode :: Maybe Int -- ^ Minimum node size in terms of units diff --git a/htools/Ganeti/HTools/Rapi.hs b/htools/Ganeti/HTools/Rapi.hs index e9eb4ccba..0808822c3 100644 --- a/htools/Ganeti/HTools/Rapi.hs +++ b/htools/Ganeti/HTools/Rapi.hs @@ -120,7 +120,7 @@ parseInstance ktn a = do tags <- extract "tags" a auto_balance <- extract "auto_balance" beparams let inst = Instance.create name mem disk vcpus running tags - auto_balance pnode snode + auto_balance pnode snode DTDrbd8 return (name, inst) -- | Construct a node from a JSON object. diff --git a/htools/Ganeti/HTools/Text.hs b/htools/Ganeti/HTools/Text.hs index fccb65237..4e8c2377e 100644 --- a/htools/Ganeti/HTools/Text.hs +++ b/htools/Ganeti/HTools/Text.hs @@ -172,7 +172,7 @@ loadInst ktn [name, mem, dsk, vcpus, status, auto_bal, pnode, snode, tags] = do " has same primary and secondary node - " ++ pnode let vtags = sepSplit ',' tags newinst = Instance.create name vmem vdsk vvcpus status vtags - auto_balance pidx sidx + auto_balance pidx sidx DTDrbd8 return (name, newinst) loadInst _ s = fail $ "Invalid/incomplete instance data: '" ++ show s ++ "'" diff --git a/htools/hspace.hs b/htools/hspace.hs index 89d2f7320..a9148be25 100644 --- a/htools/hspace.hs +++ b/htools/hspace.hs @@ -280,7 +280,7 @@ main = do -- utility functions let iofspec spx = Instance.create "new" (rspecMem spx) (rspecDsk spx) - (rspecCpu spx) "running" [] True (-1) (-1) + (rspecCpu spx) "running" [] True (-1) (-1) DTDrbd8 exitifbad val = (case val of Bad s -> do hPrintf stderr "Failure: %s\n" s :: IO () -- GitLab