diff --git a/htools/Ganeti/HTools/IAlloc.hs b/htools/Ganeti/HTools/IAlloc.hs index 9afb18171d8208132d69739c355dc1437ecae117..fa045d7492b010520c1c39b1ad67a9e8c838256a 100644 --- a/htools/Ganeti/HTools/IAlloc.hs +++ b/htools/Ganeti/HTools/IAlloc.hs @@ -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 diff --git a/htools/Ganeti/HTools/Loader.hs b/htools/Ganeti/HTools/Loader.hs index cb74ed3234b3a5f8c0607701df43c7c262a120c8..3747e971d7120bbac065841548a74f2985bf2744 100644 --- a/htools/Ganeti/HTools/Loader.hs +++ b/htools/Ganeti/HTools/Loader.hs @@ -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)