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.
return $ Allocate io req_nodes
"relocate" ->
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'
ex_nodes <- fromObj "relocate_from" request
let ex_nodes' = map (stripSuffix $ length csf) ex_nodes
ex_idex <- mapM (Container.findByName map_n) ex_nodes'
, checkData
, assignIndices
, lookupNode
, checkData
, assignIndices
, lookupNode
Nothing -> fail $ "Unknown node '" ++ node ++ "' for instance " ++ inst
Just idx -> return idx
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)])
assignIndices :: (Element a) =>
[(String, a)]
-> (NameAssoc, [(Int, a)])