Commit 981bb5cf authored by René Nussbaumer's avatar René Nussbaumer
Browse files

htools: Adding spindle usage to Instance



For now we just pass in "1" as spindle usage and adapt the backend
later.
Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 37b918c2
......@@ -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
......
......@@ -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.
......
......@@ -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)
......
......@@ -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 ()
......
......@@ -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
......
......@@ -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.
......
......@@ -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 ++ "'"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment