Revision e41f4ba0
b/Ganeti/HTools/IAlloc.hs | ||
---|---|---|
64 | 64 |
parseInstance ktn n a = do |
65 | 65 |
base <- parseBaseInstance n a |
66 | 66 |
nodes <- fromObj "nodes" a |
67 |
pnode <- readEitherString $ head nodes |
|
67 |
pnode <- if null nodes |
|
68 |
then Bad $ "empty node list for instance " ++ n |
|
69 |
else readEitherString $ head nodes |
|
68 | 70 |
pidx <- lookupNode ktn n pnode |
69 | 71 |
let snodes = tail nodes |
70 | 72 |
sidx <- (if null snodes then return Node.noSecondary |
... | ... | |
140 | 142 |
other -> fail ("Invalid request type '" ++ other ++ "'") |
141 | 143 |
return $ Request rqtype map_n map_i ptags csf |
142 | 144 |
|
143 |
formatRVal :: String -> RqType |
|
144 |
-> [Node.AllocElement] -> JSValue |
|
145 |
-- | Format the result |
|
146 |
formatRVal :: String -> RqType -> [Node.AllocElement] -> JSValue |
|
147 |
formatRVal _ _ [] = JSArray [] |
|
148 |
|
|
145 | 149 |
formatRVal csf (Evacuate _) elems = |
146 | 150 |
let sols = map (\(_, inst, nl) -> |
147 | 151 |
let names = Instance.name inst : map Node.name nl |
... | ... | |
154 | 158 |
nodes' = map ((++ csf) . Node.name) nodes |
155 | 159 |
in JSArray $ map (JSString . toJSString) nodes' |
156 | 160 |
|
157 |
|
|
158 | 161 |
-- | Formats the response into a valid IAllocator response message. |
159 | 162 |
formatResponse :: Bool -- ^ Whether the request was successful |
160 | 163 |
-> String -- ^ Information text |
Also available in: Unified diff