Skip to content
Snippets Groups Projects
Commit 5a1edeb6 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add a separate function for looking up instances

Currently we (wrongly) use lookupNode to lookup instances, just because
the name assoc list has the same type. This patch adds a separate
function for it.
parent 608efcce
No related branches found
No related tags found
No related merge requests found
......@@ -108,7 +108,7 @@ parseData body = do
return $ Allocate io req_nodes
"relocate" ->
do
ridx <- lookupNode kti rname rname
ridx <- lookupInstance kti rname
ex_nodes <- fromObj "relocate_from" request
let ex_nodes' = map (stripSuffix $ length csf) ex_nodes
ex_idex <- mapM (Container.findByName map_n) ex_nodes'
......
......@@ -9,6 +9,7 @@ module Ganeti.HTools.Loader
, checkData
, assignIndices
, lookupNode
, lookupInstance
, stripSuffix
) where
......@@ -29,6 +30,14 @@ lookupNode ktn inst node =
Nothing -> fail $ "Unknown node '" ++ node ++ "' for instance " ++ inst
Just idx -> return idx
-- | Lookups an instance into an assoc list
lookupInstance :: (Monad m) => [(String, Idx)] -> String -> m Idx
lookupInstance kti inst =
case lookup inst kti of
Nothing -> fail $ "Unknown instance '" ++ inst ++ "'"
Just idx -> return idx
-- | Given a list of elements (and their names), assign indices to them
assignIndices :: (Element a) =>
[(String, a)]
-> (NameAssoc, [(Int, a)])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment