Revision d6cf394e htools/Ganeti/HTools/IAlloc.hs
b/htools/Ganeti/HTools/IAlloc.hs | ||
---|---|---|
231 | 231 |
nodes' = map Node.name nodes |
232 | 232 |
in JSArray $ map (JSString . toJSString) nodes' |
233 | 233 |
|
234 |
-- | Formats the response into a valid IAllocator response message.
|
|
234 |
-- | Formats the result into a valid IAllocator response message.
|
|
235 | 235 |
formatResponse :: Bool -- ^ Whether the request was successful |
236 | 236 |
-> String -- ^ Information text |
237 |
-> RqType -- ^ Request type |
|
238 |
-> [Node.AllocElement] -- ^ The resulting allocations |
|
239 |
-> String -- ^ The JSON-formatted message |
|
240 |
formatResponse success info rq elems = |
|
237 |
-> JSValue -- ^ The JSON encoded result |
|
238 |
-> String -- ^ The full JSON-formatted message |
|
239 |
formatResponse success info result = |
|
241 | 240 |
let |
242 | 241 |
e_success = ("success", JSBool success) |
243 | 242 |
e_info = ("info", JSString . toJSString $ info) |
244 |
e_result = ("result", formatRVal rq elems)
|
|
243 |
e_result = ("result", result)
|
|
245 | 244 |
in encodeStrict $ makeObj [e_success, e_info, e_result] |
246 | 245 |
|
247 | 246 |
processResults :: (Monad m) => |
... | ... | |
302 | 301 |
intercalate ", " (Cluster.asLog as), |
303 | 302 |
Cluster.asSolutions as) |
304 | 303 |
Bad s -> (False, "Request failed: " ++ s, []) |
305 |
resp = formatResponse ok info rq rn |
|
304 |
result = formatRVal rq rn |
|
305 |
resp = formatResponse ok info result |
|
306 | 306 |
in resp |
Also available in: Unified diff