Commit f4531f51 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add lookupGroup utility function



This will be used in the various backends similar to the lookupNode
function.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarBalazs Lecz <leczb@google.com>
parent 0dc1bf87
...@@ -32,6 +32,7 @@ module Ganeti.HTools.Loader ...@@ -32,6 +32,7 @@ module Ganeti.HTools.Loader
, assignIndices , assignIndices
, lookupNode , lookupNode
, lookupInstance , lookupInstance
, lookupGroup
, commonSuffix , commonSuffix
, RqType(..) , RqType(..)
, Request(..) , Request(..)
...@@ -88,6 +89,13 @@ lookupInstance kti inst = ...@@ -88,6 +89,13 @@ lookupInstance kti inst =
Nothing -> fail $ "Unknown instance '" ++ inst ++ "'" Nothing -> fail $ "Unknown instance '" ++ inst ++ "'"
Just idx -> return idx Just idx -> return idx
-- | Lookups a group into an assoc list.
lookupGroup :: (Monad m) => NameAssoc -> String -> String -> m Gdx
lookupGroup ktg nname gname =
case M.lookup gname ktg of
Nothing -> fail $ "Unknown group '" ++ gname ++ "' for node " ++ nname
Just idx -> return idx
-- | Given a list of elements (and their names), assign indices to them. -- | Given a list of elements (and their names), assign indices to them.
assignIndices :: (Element a) => assignIndices :: (Element a) =>
[(String, a)] [(String, a)]
......
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