Add function to fetch the list of master candidates
authorMichele Tartara <mtartara@google.com>
Tue, 18 Dec 2012 14:51:09 +0000 (14:51 +0000)
committerMichele Tartara <mtartara@google.com>
Thu, 20 Dec 2012 16:17:20 +0000 (17:17 +0100)
This commits adds to the Haskell codebase a function to fetch the list of
IPs of the master candidates from the SSConf database.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

htools/Ganeti/Ssconf.hs

index 20cfeb3..ed0dbbd 100644 (file)
@@ -30,6 +30,7 @@ module Ganeti.Ssconf
   , sSKeyToRaw
   , sSKeyFromRaw
   , getPrimaryIPFamily
+  , getMasterCandidatesIps
   , keyToFilename
   , sSFilePrefix
   ) where
@@ -127,3 +128,9 @@ getPrimaryIPFamily optpath = do
   result <- readSSConfFile optpath (Just (show C.ip4Family)) SSPrimaryIpFamily
   return (liftM rStripSpace result >>=
           tryRead "Parsing af_family" >>= parseIPFamily)
+
+-- | Read the list of IP addresses of the master candidates of the cluster.
+getMasterCandidatesIps :: Maybe FilePath -> IO (Result [String])
+getMasterCandidatesIps optPath = do
+  result <- readSSConfFile optPath Nothing SSMasterCandidatesIps
+  return $ liftM lines result