Revision 9f8b97ce htools/Ganeti/HTools/Types.hs
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