Revision c352b0a9
b/htools/Ganeti/HTools/IAlloc.hs | ||
---|---|---|
57 | 57 |
vcpus <- extract "vcpus" |
58 | 58 |
tags <- extract "tags" |
59 | 59 |
let running = "running" |
60 |
return (n, Instance.create n mem disk vcpus running tags 0 0) |
|
60 |
return (n, Instance.create n mem disk vcpus running tags True 0 0)
|
|
61 | 61 |
|
62 | 62 |
-- | Parses an instance as found in the cluster instance listg. |
63 | 63 |
parseInstance :: NameAssoc -- ^ The node name-to-index association list |
b/htools/Ganeti/HTools/Instance.hs | ||
---|---|---|
7 | 7 |
|
8 | 8 |
{- |
9 | 9 |
|
10 |
Copyright (C) 2009, 2010 Google Inc. |
|
10 |
Copyright (C) 2009, 2010, 2011 Google Inc.
|
|
11 | 11 |
|
12 | 12 |
This program is free software; you can redistribute it and/or modify |
13 | 13 |
it under the terms of the GNU General Public License as published by |
... | ... | |
49 | 49 |
-- * Type declarations |
50 | 50 |
|
51 | 51 |
-- | The instance type |
52 |
data Instance = Instance { name :: String -- ^ The instance name |
|
53 |
, alias :: String -- ^ The shortened name |
|
54 |
, mem :: Int -- ^ Memory of the instance |
|
55 |
, dsk :: Int -- ^ Disk size of instance |
|
56 |
, vcpus :: Int -- ^ Number of VCPUs |
|
57 |
, running :: Bool -- ^ Is the instance running? |
|
58 |
, runSt :: String -- ^ Original (text) run status |
|
59 |
, pNode :: T.Ndx -- ^ Original primary node |
|
60 |
, sNode :: T.Ndx -- ^ Original secondary node |
|
61 |
, idx :: T.Idx -- ^ Internal index |
|
62 |
, util :: T.DynUtil -- ^ Dynamic resource usage |
|
63 |
, movable :: Bool -- ^ Can the instance be moved? |
|
64 |
, tags :: [String] -- ^ List of instance tags |
|
65 |
} deriving (Show, Read) |
|
52 |
data Instance = Instance |
|
53 |
{ name :: String -- ^ The instance name |
|
54 |
, alias :: String -- ^ The shortened name |
|
55 |
, mem :: Int -- ^ Memory of the instance |
|
56 |
, dsk :: Int -- ^ Disk size of instance |
|
57 |
, vcpus :: Int -- ^ Number of VCPUs |
|
58 |
, running :: Bool -- ^ Is the instance running? |
|
59 |
, runSt :: String -- ^ Original (text) run status |
|
60 |
, pNode :: T.Ndx -- ^ Original primary node |
|
61 |
, sNode :: T.Ndx -- ^ Original secondary node |
|
62 |
, idx :: T.Idx -- ^ Internal index |
|
63 |
, util :: T.DynUtil -- ^ Dynamic resource usage |
|
64 |
, movable :: Bool -- ^ Can the instance be moved? |
|
65 |
, auto_balance :: Bool -- ^ Is the instance auto-balanced? |
|
66 |
, tags :: [String] -- ^ List of instance tags |
|
67 |
} deriving (Show, Read) |
|
66 | 68 |
|
67 | 69 |
instance T.Element Instance where |
68 | 70 |
nameOf = name |
... | ... | |
88 | 90 |
-- Some parameters are not initialized by function, and must be set |
89 | 91 |
-- later (via 'setIdx' for example). |
90 | 92 |
create :: String -> Int -> Int -> Int -> String |
91 |
-> [String] -> T.Ndx -> T.Ndx -> Instance |
|
92 |
create name_init mem_init dsk_init vcpus_init run_init tags_init pn sn = |
|
93 |
-> [String] -> Bool -> T.Ndx -> T.Ndx -> Instance |
|
94 |
create name_init mem_init dsk_init vcpus_init run_init tags_init |
|
95 |
auto_balance_init pn sn = |
|
93 | 96 |
Instance { name = name_init |
94 | 97 |
, alias = name_init |
95 | 98 |
, mem = mem_init |
... | ... | |
103 | 106 |
, util = T.baseUtil |
104 | 107 |
, tags = tags_init |
105 | 108 |
, movable = True |
109 |
, auto_balance = auto_balance_init |
|
106 | 110 |
} |
107 | 111 |
|
108 | 112 |
-- | Changes the index. |
b/htools/Ganeti/HTools/Luxi.hs | ||
---|---|---|
127 | 127 |
xrunning <- convert "status" status |
128 | 128 |
xtags <- convert "tags" tags |
129 | 129 |
let inst = Instance.create xname xmem xdisk xvcpus |
130 |
xrunning xtags xpnode snode |
|
130 |
xrunning xtags True xpnode snode
|
|
131 | 131 |
return (xname, inst) |
132 | 132 |
|
133 | 133 |
parseInstance _ v = fail ("Invalid instance query result: " ++ show v) |
b/htools/Ganeti/HTools/QC.hs | ||
---|---|---|
106 | 106 |
|
107 | 107 |
-- | Create an instance given its spec |
108 | 108 |
createInstance mem dsk vcpus = |
109 |
Instance.create "inst-unnamed" mem dsk vcpus "running" [] (-1) (-1) |
|
109 |
Instance.create "inst-unnamed" mem dsk vcpus "running" [] True (-1) (-1)
|
|
110 | 110 |
|
111 | 111 |
-- | Create a small cluster by repeating a node spec |
112 | 112 |
makeSmallCluster :: Node.Node -> Int -> Node.List |
... | ... | |
184 | 184 |
pn <- arbitrary |
185 | 185 |
sn <- arbitrary |
186 | 186 |
vcpus <- choose (0, maxCpu) |
187 |
return $ Instance.create name mem dsk vcpus run_st [] pn sn |
|
187 |
return $ Instance.create name mem dsk vcpus run_st [] True pn sn
|
|
188 | 188 |
|
189 | 189 |
-- and a random node |
190 | 190 |
instance Arbitrary Node.Node where |
b/htools/Ganeti/HTools/Rapi.hs | ||
---|---|---|
122 | 122 |
else readEitherString (head snodes) >>= lookupNode ktn name) |
123 | 123 |
running <- extract "status" a |
124 | 124 |
tags <- extract "tags" a |
125 |
let inst = Instance.create name mem disk vcpus running tags pnode snode |
|
125 |
let inst = Instance.create name mem disk vcpus running tags True pnode snode
|
|
126 | 126 |
return (name, inst) |
127 | 127 |
|
128 | 128 |
-- | Construct a node from a JSON object. |
b/htools/Ganeti/HTools/Text.hs | ||
---|---|---|
144 | 144 |
when (sidx == pidx) $ fail $ "Instance " ++ name ++ |
145 | 145 |
" has same primary and secondary node - " ++ pnode |
146 | 146 |
let vtags = sepSplit ',' tags |
147 |
newinst = Instance.create name vmem vdsk vvcpus status vtags pidx sidx |
|
147 |
newinst = Instance.create name vmem vdsk vvcpus status vtags |
|
148 |
True pidx sidx |
|
148 | 149 |
return (name, newinst) |
149 | 150 |
loadInst _ s = fail $ "Invalid/incomplete instance data: '" ++ show s ++ "'" |
150 | 151 |
|
b/htools/hspace.hs | ||
---|---|---|
280 | 280 |
|
281 | 281 |
-- utility functions |
282 | 282 |
let iofspec spx = Instance.create "new" (rspecMem spx) (rspecDsk spx) |
283 |
(rspecCpu spx) "running" [] (-1) (-1) |
|
283 |
(rspecCpu spx) "running" [] True (-1) (-1)
|
|
284 | 284 |
exitifbad val = (case val of |
285 | 285 |
Bad s -> do |
286 | 286 |
hPrintf stderr "Failure: %s\n" s :: IO () |
Also available in: Unified diff