Revision 9f8b97ce

b/htools/Ganeti/HTools/IAlloc.hs
184 184
                rl_names <- extrReq "instances"
185 185
                rl_insts <- mapM (Container.findByName map_i) rl_names
186 186
                let rl_idx = map Instance.idx rl_insts
187
                rl_mode <-
188
                   case extrReq "evac_mode" of
189
                     Ok s | s == C.iallocatorNevacAll -> return ChangeAll
190
                          | s == C.iallocatorNevacPri -> return ChangePrimary
191
                          | s == C.iallocatorNevacSec -> return ChangeSecondary
192
                          | otherwise -> Bad $ "Invalid evacuate mode " ++ s
193
                     Bad x -> Bad x
187
                rl_mode <- extrReq "evac_mode"
194 188
                return $ NodeEvacuate rl_idx rl_mode
195 189

  
196 190
          | otherwise -> fail ("Invalid request type '" ++ optype ++ "'")
b/htools/Ganeti/HTools/Types.hs
342 342
              | ChangeSecondary
343 343
              | ChangeAll
344 344
                deriving (Show, Read)
345

  
346
instance JSON.JSON EvacMode where
347
    showJSON mode = case mode of
348
                      ChangeAll       -> JSON.showJSON C.iallocatorNevacAll
349
                      ChangePrimary   -> JSON.showJSON C.iallocatorNevacPri
350
                      ChangeSecondary -> JSON.showJSON C.iallocatorNevacSec
351
    readJSON v =
352
        case JSON.readJSON v of
353
          JSON.Ok s | s == C.iallocatorNevacAll -> return ChangeAll
354
                    | s == C.iallocatorNevacPri -> return ChangePrimary
355
                    | s == C.iallocatorNevacSec -> return ChangeSecondary
356
                    | otherwise -> fail $ "Invalid evacuate mode " ++ s
357
          JSON.Error e -> JSON.Error $
358
                          "Can't parse evacuate mode as string: " ++ e

Also available in: Unified diff