From 20c891d0cb7c99cf6ef4e240b172ad89cd059f21 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 16 Feb 2010 13:30:57 +0100 Subject: [PATCH] IAllocator: move some keys into per-request data Since not all structures will have these keys in the future, we move them into per-structure keys. Signed-off-by: Iustin Pop <iustin@google.com> --- Ganeti/HTools/IAlloc.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Ganeti/HTools/IAlloc.hs b/Ganeti/HTools/IAlloc.hs index 819021c8a..2d20a4f7c 100644 --- a/Ganeti/HTools/IAlloc.hs +++ b/Ganeti/HTools/IAlloc.hs @@ -99,7 +99,6 @@ parseData body = do let obj = fromJSObject decoded -- request parser request <- liftM fromJSObject (fromObj "request" obj) - rname <- fromObj "name" request -- existing node parsing nlist <- liftM fromJSObject (fromObj "nodes" obj) nobj <- mapM (\(x,y) -> asJSObject y >>= parseNode x . fromJSObject) nlist @@ -113,18 +112,21 @@ parseData body = do -- cluster tags ctags <- fromObj "cluster_tags" obj (map_n, map_i, ptags, csf) <- mergeData [] [] (nl, il, ctags) - req_nodes <- fromObj "required_nodes" request optype <- fromObj "type" request rqtype <- case optype of "allocate" -> do + rname <- fromObj "name" request + req_nodes <- fromObj "required_nodes" request inew <- parseBaseInstance rname request let io = snd inew return $ Allocate io req_nodes "relocate" -> do + rname <- fromObj "name" request ridx <- lookupInstance kti rname + req_nodes <- fromObj "required_nodes" request ex_nodes <- fromObj "relocate_from" request let ex_nodes' = map (stripSuffix $ length csf) ex_nodes ex_idex <- mapM (Container.findByName map_n) ex_nodes' -- GitLab