From 981bb5cf47640ba052786557de8b0f90be651c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= <rn@google.com> Date: Tue, 13 Mar 2012 11:31:33 +0100 Subject: [PATCH] htools: Adding spindle usage to Instance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For now we just pass in "1" as spindle usage and adapt the backend later. Signed-off-by: RenΓ© Nussbaumer <rn@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- htools/Ganeti/HTools/IAlloc.hs | 2 +- htools/Ganeti/HTools/Instance.hs | 7 +++++-- htools/Ganeti/HTools/Luxi.hs | 2 +- htools/Ganeti/HTools/Program/Hspace.hs | 2 +- htools/Ganeti/HTools/QC.hs | 4 ++-- htools/Ganeti/HTools/Rapi.hs | 2 +- htools/Ganeti/HTools/Text.hs | 2 +- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/htools/Ganeti/HTools/IAlloc.hs b/htools/Ganeti/HTools/IAlloc.hs index d426aeffa..d881921ce 100644 --- a/htools/Ganeti/HTools/IAlloc.hs +++ b/htools/Ganeti/HTools/IAlloc.hs @@ -70,7 +70,7 @@ parseBaseInstance n a = do vcpus <- extract "vcpus" tags <- extract "tags" dt <- extract "disk_template" - return (n, Instance.create n mem disk vcpus Running tags True 0 0 dt) + return (n, Instance.create n mem disk vcpus Running tags True 0 0 dt 1) -- | 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 8de3c8bce..269f3209c 100644 --- a/htools/Ganeti/HTools/Instance.hs +++ b/htools/Ganeti/HTools/Instance.hs @@ -79,6 +79,7 @@ data Instance = Instance , autoBalance :: Bool -- ^ Is the instance auto-balanced? , tags :: [String] -- ^ List of instance tags , diskTemplate :: T.DiskTemplate -- ^ The disk template of the instance + , spindleUsage :: Int -- ^ The numbers of used spindles } deriving (Show, Read, Eq) instance T.Element Instance where @@ -157,9 +158,10 @@ 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 -> T.InstanceStatus - -> [String] -> Bool -> T.Ndx -> T.Ndx -> T.DiskTemplate -> Instance + -> [String] -> Bool -> T.Ndx -> T.Ndx -> T.DiskTemplate -> Int + -> Instance create name_init mem_init dsk_init vcpus_init run_init tags_init - auto_balance_init pn sn dt = + auto_balance_init pn sn dt su = Instance { name = name_init , alias = name_init , mem = mem_init @@ -174,6 +176,7 @@ create name_init mem_init dsk_init vcpus_init run_init tags_init , movable = supportsMoves dt , autoBalance = auto_balance_init , diskTemplate = dt + , spindleUsage = su } -- | Changes the index. diff --git a/htools/Ganeti/HTools/Luxi.hs b/htools/Ganeti/HTools/Luxi.hs index 77d561472..c484223cc 100644 --- a/htools/Ganeti/HTools/Luxi.hs +++ b/htools/Ganeti/HTools/Luxi.hs @@ -163,7 +163,7 @@ parseInstance ktn [ name, disk, mem, vcpus xauto_balance <- convert "auto_balance" auto_balance xdt <- convert "disk_template" disk_template let inst = Instance.create xname xmem xdisk xvcpus - xrunning xtags xauto_balance xpnode snode xdt + xrunning xtags xauto_balance xpnode snode xdt 1 return (xname, inst) parseInstance _ v = fail ("Invalid instance query result: " ++ show v) diff --git a/htools/Ganeti/HTools/Program/Hspace.hs b/htools/Ganeti/HTools/Program/Hspace.hs index 9dcd3c8af..61c4eea5e 100644 --- a/htools/Ganeti/HTools/Program/Hspace.hs +++ b/htools/Ganeti/HTools/Program/Hspace.hs @@ -389,7 +389,7 @@ runAllocation cdata stop_allocation actual_result spec dt mode opts = do instFromSpec :: RSpec -> DiskTemplate -> Instance.Instance instFromSpec spx disk_template = Instance.create "new" (rspecMem spx) (rspecDsk spx) - (rspecCpu spx) Running [] True (-1) (-1) disk_template + (rspecCpu spx) Running [] True (-1) (-1) disk_template 1 -- | Main function. main :: Options -> [String] -> IO () diff --git a/htools/Ganeti/HTools/QC.hs b/htools/Ganeti/HTools/QC.hs index fb9d7e30e..e4cd394d0 100644 --- a/htools/Ganeti/HTools/QC.hs +++ b/htools/Ganeti/HTools/QC.hs @@ -175,7 +175,7 @@ setInstanceSmallerThanNode node inst = -- | Create an instance given its spec. createInstance mem dsk vcpus = Instance.create "inst-unnamed" mem dsk vcpus Types.Running [] True (-1) (-1) - Types.DTDrbd8 + Types.DTDrbd8 1 -- | Create a small cluster by repeating a node spec. makeSmallCluster :: Node.Node -> Int -> Node.List @@ -313,7 +313,7 @@ genInstanceSmallerThan lim_mem lim_dsk lim_cpu = do sn <- arbitrary vcpus <- choose (0, lim_cpu) return $ Instance.create name mem dsk vcpus run_st [] True pn sn - Types.DTDrbd8 + Types.DTDrbd8 1 -- | Generates an instance smaller than a node. genInstanceSmallerThanNode :: Node.Node -> Gen Instance.Instance diff --git a/htools/Ganeti/HTools/Rapi.hs b/htools/Ganeti/HTools/Rapi.hs index e9f82a310..bae15661d 100644 --- a/htools/Ganeti/HTools/Rapi.hs +++ b/htools/Ganeti/HTools/Rapi.hs @@ -124,7 +124,7 @@ parseInstance ktn a = do auto_balance <- extract "auto_balance" beparams dt <- extract "disk_template" a let inst = Instance.create name mem disk vcpus running tags - auto_balance pnode snode dt + auto_balance pnode snode dt 1 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 4c861fabe..fc943e996 100644 --- a/htools/Ganeti/HTools/Text.hs +++ b/htools/Ganeti/HTools/Text.hs @@ -226,7 +226,7 @@ loadInst ktn [ name, mem, dsk, vcpus, status, auto_bal, pnode, snode " has same primary and secondary node - " ++ pnode let vtags = commaSplit tags newinst = Instance.create name vmem vdsk vvcpus vstatus vtags - auto_balance pidx sidx disk_template + auto_balance pidx sidx disk_template 1 return (name, newinst) loadInst _ s = fail $ "Invalid/incomplete instance data: '" ++ show s ++ "'" -- GitLab