From 4e84ca27d8ba2a58af51207d85d6f93593cb7e05 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 30 Jun 2011 12:05:21 +0200
Subject: [PATCH] htools: add parsing of input node-evac messages

This is a lot of duplication with modeMreloc, which will get sorted
out once we convert mreloc to change-group.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 htools/Ganeti/HTools/IAlloc.hs | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/htools/Ganeti/HTools/IAlloc.hs b/htools/Ganeti/HTools/IAlloc.hs
index 8801949f5..6888a3108 100644
--- a/htools/Ganeti/HTools/IAlloc.hs
+++ b/htools/Ganeti/HTools/IAlloc.hs
@@ -192,6 +192,19 @@ parseData body = do
                           | otherwise -> Bad $ "Invalid relocate mode " ++ s
                      Bad x -> Bad x
                 return $ MultiReloc rl_idx rl_mode
+          | optype == C.iallocatorModeNodeEvac ->
+              do
+                rl_names <- extrReq "instances"
+                rl_insts <- mapM (Container.findByName map_i) rl_names
+                let rl_idx = map Instance.idx rl_insts
+                rl_mode <-
+                   case extrReq "evac_mode" of
+                     Ok s | s == C.iallocatorNevacAll -> return ChangeAll
+                          | s == C.iallocatorNevacPri -> return ChangePrimary
+                          | s == C.iallocatorNevacSec -> return ChangeSecondary
+                          | otherwise -> Bad $ "Invalid evacuate mode " ++ s
+                     Bad x -> Bad x
+                return $ NodeEvacuate rl_idx rl_mode
 
           | otherwise -> fail ("Invalid request type '" ++ optype ++ "'")
   return $ Request rqtype cdata
-- 
GitLab