Commit 57f07ff2 authored by Iustin Pop's avatar Iustin Pop
Browse files

htools: add ChangeGroup to IAllocator types/loader



This patch updates the types and functions in IAllocator.hs and
Loader.hs to the new design changes (elimination of multi-relocate
mode and replacement with change-group).

It also removes an extra re-export of EvacMode from Loader.hs.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 8fd09137
......@@ -124,13 +124,6 @@ parseGroup u a = do
apol <- extract "alloc_policy"
return (u, Group.create name u apol)
parseTargetGroups :: JSRecord -- ^ The JSON object (request dict)
-> Group.List -- ^ The existing groups
-> Result [Gdx]
parseTargetGroups req map_g = do
group_uuids <- fromObjWithDefault req "target_groups" []
mapM (liftM Group.idx . Container.findByName map_g) group_uuids
-- | Top-level parser.
parseData :: String -- ^ The JSON message as received from Ganeti
-> Result Request -- ^ A (possible valid) request
......@@ -186,22 +179,15 @@ parseData body = do
ex_nodes <- mapM (Container.findByName map_n) ex_names
let ex_ndx = map Node.idx ex_nodes
return $ Evacuate ex_ndx
| optype == C.iallocatorModeMreloc ->
| optype == C.iallocatorModeChgGroup ->
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 "reloc_mode" of
Ok s | s == C.iallocatorMrelocKeep -> return KeepGroup
| s == C.iallocatorMrelocChange ->
do
tg_groups <- parseTargetGroups request map_g
return $ ChangeGroup tg_groups
| s == C.iallocatorMrelocAny -> return AnyGroup
| otherwise -> Bad $ "Invalid relocate mode " ++ s
Bad x -> Bad x
return $ MultiReloc rl_idx rl_mode
rl_insts <- mapM (liftM Instance.idx .
Container.findByName map_i) rl_names
gr_uuids <- extrReq "target_groups"
gr_idxes <- mapM (liftM Group.idx .
Container.findByName map_g) gr_uuids
return $ ChangeGroup rl_insts gr_idxes
| optype == C.iallocatorModeNodeEvac ->
do
rl_names <- extrReq "instances"
......@@ -276,7 +262,7 @@ processRequest request =
Cluster.tryMGReloc gl nl il idx reqn exnodes >>= formatAllocate
Evacuate exnodes ->
Cluster.tryMGEvac gl nl il exnodes >>= formatEvacuate
MultiReloc _ _ -> fail "multi-reloc not handled"
ChangeGroup _ _ -> fail "Request 'change-group' not implemented"
NodeEvacuate xi mode ->
Cluster.tryNodeEvac gl nl il mode xi >>= formatNodeEvac
......
......@@ -34,8 +34,6 @@ module Ganeti.HTools.Loader
, lookupInstance
, lookupGroup
, commonSuffix
, RelocMode(..)
, EvacMode(..)
, RqType(..)
, Request(..)
, ClusterData(..)
......@@ -67,12 +65,6 @@ exTagsPrefix = "htools:iextags:"
-- * Types
-- | The iallocator multi-evac group mode type.
data RelocMode = KeepGroup
| ChangeGroup [Gdx]
| AnyGroup
deriving (Show, Read)
{-| The iallocator request type.
This type denotes what request we got from Ganeti and also holds
......@@ -84,7 +76,7 @@ data RqType
| Relocate Idx Int [Ndx] -- ^ Move an instance to a new
-- secondary node
| Evacuate [Ndx] -- ^ Evacuate nodes
| MultiReloc [Idx] RelocMode -- ^ Multi-relocate mode
| ChangeGroup [Gdx] [Idx] -- ^ Multi-relocate mode
| NodeEvacuate [Idx] EvacMode -- ^ node-evacuate mode
deriving (Show, Read)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment