Revision 3603605a htools/Ganeti/HTools/Luxi.hs
b/htools/Ganeti/HTools/Luxi.hs | ||
---|---|---|
41 | 41 |
import Ganeti.HTools.Utils (fromJVal, annotateResult, tryFromObj, asJSObject, |
42 | 42 |
fromObj) |
43 | 43 |
|
44 |
{-# ANN module "HLint: ignore Eta reduce" #-} |
|
45 |
|
|
44 | 46 |
-- * Utility functions |
45 | 47 |
|
46 | 48 |
-- | Get values behind \"data\" part of the result. |
... | ... | |
148 | 150 |
xname <- annotateResult "Parsing new instance" (fromJValWithStatus name) |
149 | 151 |
let convert a = genericConvert "Instance" xname a |
150 | 152 |
xdisk <- convert "disk_usage" disk |
151 |
xmem <- (case oram of -- FIXME: remove the "guessing"
|
|
152 |
(_, JSRational _ _) -> convert "oper_ram" oram
|
|
153 |
_ -> convert "be/memory" mem)
|
|
153 |
xmem <- case oram of -- FIXME: remove the "guessing" |
|
154 |
(_, JSRational _ _) -> convert "oper_ram" oram |
|
155 |
_ -> convert "be/memory" mem
|
|
154 | 156 |
xvcpus <- convert "be/vcpus" vcpus |
155 | 157 |
xpnode <- convert "pnode" pnode >>= lookupNode ktn xname |
156 | 158 |
xsnodes <- convert "snodes" snodes::Result [JSString] |
157 |
snode <- (if null xsnodes then return Node.noSecondary |
|
158 |
else lookupNode ktn xname (fromJSString $ head xsnodes)) |
|
159 |
snode <- if null xsnodes |
|
160 |
then return Node.noSecondary |
|
161 |
else lookupNode ktn xname (fromJSString $ head xsnodes) |
|
159 | 162 |
xrunning <- convert "status" status |
160 | 163 |
xtags <- convert "tags" tags |
161 | 164 |
xauto_balance <- convert "auto_balance" auto_balance |
... | ... | |
181 | 184 |
xdrained <- convert "drained" drained |
182 | 185 |
xvm_capable <- convert "vm_capable" vm_capable |
183 | 186 |
xgdx <- convert "group.uuid" g_uuid >>= lookupGroup ktg xname |
184 |
node <- (if xoffline || xdrained || not xvm_capable
|
|
185 |
then return $ Node.create xname 0 0 0 0 0 0 True xgdx |
|
186 |
else do |
|
187 |
xmtotal <- convert "mtotal" mtotal |
|
188 |
xmnode <- convert "mnode" mnode |
|
189 |
xmfree <- convert "mfree" mfree |
|
190 |
xdtotal <- convert "dtotal" dtotal |
|
191 |
xdfree <- convert "dfree" dfree |
|
192 |
xctotal <- convert "ctotal" ctotal |
|
193 |
return $ Node.create xname xmtotal xmnode xmfree |
|
194 |
xdtotal xdfree xctotal False xgdx)
|
|
187 |
node <- if xoffline || xdrained || not xvm_capable |
|
188 |
then return $ Node.create xname 0 0 0 0 0 0 True xgdx
|
|
189 |
else do
|
|
190 |
xmtotal <- convert "mtotal" mtotal
|
|
191 |
xmnode <- convert "mnode" mnode
|
|
192 |
xmfree <- convert "mfree" mfree
|
|
193 |
xdtotal <- convert "dtotal" dtotal
|
|
194 |
xdfree <- convert "dfree" dfree
|
|
195 |
xctotal <- convert "ctotal" ctotal
|
|
196 |
return $ Node.create xname xmtotal xmnode xmfree
|
|
197 |
xdtotal xdfree xctotal False xgdx
|
|
195 | 198 |
return (xname, node) |
196 | 199 |
|
197 | 200 |
parseNode _ v = fail ("Invalid node query result: " ++ show v) |
Also available in: Unified diff