Revision 57587760

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
......
141 143
        other -> fail ("Invalid request type '" ++ other ++ "'")
142 144
  return $ Request rqtype map_n map_i ptags csf
143 145

  
144
formatRVal :: String -> RqType
145
           -> [Node.AllocElement] -> JSValue
146
-- | Format the result
147
formatRVal :: String -> RqType -> [Node.AllocElement] -> JSValue
148
formatRVal _ _ [] = JSArray []
149

  
146 150
formatRVal csf (Evacuate _) elems =
147 151
    let sols = map (\(_, inst, nl) ->
148 152
                        let names = Instance.name inst : map Node.name nl
......
155 159
        nodes' = map ((++ csf) . Node.name) nodes
156 160
    in JSArray $ map (JSString . toJSString) nodes'
157 161

  
158

  
159 162
-- | Formats the response into a valid IAllocator response message.
160 163
formatResponse :: Bool     -- ^ Whether the request was successful
161 164
               -> String   -- ^ Information text

Also available in: Unified diff