module Ganeti.Path
( dataDir
, runDir
, logDir
, socketDir
, defaultLuxiSocket
, defaultQuerySocket
, confdHmacKey
, clusterConfFile
, nodedCertFile
, queueDir
, jobQueueSerialFile
, jobQueueArchiveSubDir
) where
import System.FilePath
import System.Posix.Env (getEnvDefault)
import qualified Ganeti.Constants as C
pjoin :: IO String -> String -> IO String
pjoin a b = do
a' <- a
return $ a' </> b
getRootDir :: IO FilePath
getRootDir = getEnvDefault "GANETI_ROOTDIR" ""
addNodePrefix :: FilePath -> IO FilePath
addNodePrefix path = do
root <- getRootDir
return $ root ++ path
dataDir :: IO FilePath
dataDir = addNodePrefix $ C.autoconfLocalstatedir </> "lib" </> "ganeti"
dataDirP :: FilePath -> IO FilePath
dataDirP = (dataDir `pjoin`)
runDir :: IO FilePath
runDir = addNodePrefix $ C.autoconfLocalstatedir </> "run" </> "ganeti"
logDir :: IO FilePath
logDir = addNodePrefix $ C.autoconfLocalstatedir </> "log" </> "ganeti"
socketDir :: IO FilePath
socketDir = runDir `pjoin` "socket"
defaultLuxiSocket :: IO FilePath
defaultLuxiSocket = socketDir `pjoin` "ganeti-master"
defaultQuerySocket :: IO FilePath
defaultQuerySocket = socketDir `pjoin` "ganeti-query"
confdHmacKey :: IO FilePath
confdHmacKey = dataDirP "hmac.key"
clusterConfFile :: IO FilePath
clusterConfFile = dataDirP "config.data"
nodedCertFile :: IO FilePath
nodedCertFile = dataDirP "server.pem"
queueDir :: IO FilePath
queueDir = dataDirP "queue"
jobQueueSerialFile :: IO FilePath
jobQueueSerialFile = dataDirP "serial"
jobQueueArchiveSubDir :: FilePath
jobQueueArchiveSubDir = "archive"