Revision 8bc34c7b htools/Ganeti/HTools/Luxi.hs
b/htools/Ganeti/HTools/Luxi.hs | ||
---|---|---|
4 | 4 |
|
5 | 5 |
{- |
6 | 6 |
|
7 |
Copyright (C) 2009, 2010, 2011 Google Inc. |
|
7 |
Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
|
|
8 | 8 |
|
9 | 9 |
This program is free software; you can redistribute it and/or modify |
10 | 10 |
it under the terms of the GNU General Public License as published by |
... | ... | |
99 | 99 |
queryNodesMsg = |
100 | 100 |
L.Query L.QRNode ["name", "mtotal", "mnode", "mfree", "dtotal", "dfree", |
101 | 101 |
"ctotal", "offline", "drained", "vm_capable", |
102 |
"group.uuid"] () |
|
102 |
"ndp/spindle_count", "group.uuid"] ()
|
|
103 | 103 |
|
104 | 104 |
-- | The input data for instance query. |
105 | 105 |
queryInstancesMsg :: L.LuxiOp |
... | ... | |
175 | 175 |
-- | Construct a node from a JSON object. |
176 | 176 |
parseNode :: NameAssoc -> [(JSValue, JSValue)] -> Result (String, Node.Node) |
177 | 177 |
parseNode ktg [ name, mtotal, mnode, mfree, dtotal, dfree |
178 |
, ctotal, offline, drained, vm_capable, g_uuid ] |
|
178 |
, ctotal, offline, drained, vm_capable, spindles, g_uuid ]
|
|
179 | 179 |
= do |
180 | 180 |
xname <- annotateResult "Parsing new node" (fromJValWithStatus name) |
181 | 181 |
let convert a = genericConvert "Node" xname a |
182 | 182 |
xoffline <- convert "offline" offline |
183 | 183 |
xdrained <- convert "drained" drained |
184 | 184 |
xvm_capable <- convert "vm_capable" vm_capable |
185 |
xspindles <- convert "spindles" spindles |
|
185 | 186 |
xgdx <- convert "group.uuid" g_uuid >>= lookupGroup ktg xname |
186 | 187 |
node <- if xoffline || xdrained || not xvm_capable |
187 |
then return $ Node.create xname 0 0 0 0 0 0 True xgdx |
|
188 |
then return $ Node.create xname 0 0 0 0 0 0 True xspindles xgdx
|
|
188 | 189 |
else do |
189 | 190 |
xmtotal <- convert "mtotal" mtotal |
190 | 191 |
xmnode <- convert "mnode" mnode |
... | ... | |
193 | 194 |
xdfree <- convert "dfree" dfree |
194 | 195 |
xctotal <- convert "ctotal" ctotal |
195 | 196 |
return $ Node.create xname xmtotal xmnode xmfree |
196 |
xdtotal xdfree xctotal False xgdx |
|
197 |
xdtotal xdfree xctotal False xspindles xgdx
|
|
197 | 198 |
return (xname, node) |
198 | 199 |
|
199 | 200 |
parseNode _ v = fail ("Invalid node query result: " ++ show v) |
Also available in: Unified diff