Commit d25643d1 authored by Iustin Pop's avatar Iustin Pop
Browse files

htools: add DiskTemplate to instance definition



Currently always fixed to DRBD8, as that is what we assume already.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 3c002a13
......@@ -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
......
......@@ -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.
......
......@@ -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)
......
......@@ -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
......
......@@ -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.
......
......@@ -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 ++ "'"
......
......@@ -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 ()
......
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