module Ganeti.Path
( dataDir
, runDir
, logDir
, socketDir
, luxidMessageDir
, livelockDir
, livelockFile
, defaultQuerySocket
, defaultWConfdSocket
, defaultMetadSocket
, confdHmacKey
, clusterConfFile
, lockStatusFile
, tempResStatusFile
, watcherPauseFile
, nodedCertFile
, nodedClientCertFile
, queueDir
, jobQueueSerialFile
, jobQueueLockFile
, jobQueueDrainFile
, jobQueueArchiveSubDir
, instanceReasonDir
, getInstReasonFilename
, jqueueExecutorPy
, kvmPidDir
) where
import System.FilePath
import System.Posix.Env (getEnvDefault)
import AutoConf
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 $ AutoConf.localstatedir </> "lib" </> "ganeti"
dataDirP :: FilePath -> IO FilePath
dataDirP = (dataDir `pjoin`)
runDir :: IO FilePath
runDir = addNodePrefix $ AutoConf.localstatedir </> "run" </> "ganeti"
logDir :: IO FilePath
logDir = addNodePrefix $ AutoConf.localstatedir </> "log" </> "ganeti"
socketDir :: IO FilePath
socketDir = runDir `pjoin` "socket"
livelockDir :: IO FilePath
livelockDir = runDir `pjoin` "livelocks"
luxidMessageDir :: IO FilePath
luxidMessageDir = runDir `pjoin` "luxidmessages"
livelockFile :: FilePath -> IO FilePath
livelockFile = pjoin livelockDir
defaultQuerySocket :: IO FilePath
defaultQuerySocket = socketDir `pjoin` "ganeti-query"
defaultWConfdSocket :: IO FilePath
defaultWConfdSocket = socketDir `pjoin` "ganeti-wconfd"
defaultMetadSocket :: IO FilePath
defaultMetadSocket = socketDir `pjoin` "ganeti-metad"
confdHmacKey :: IO FilePath
confdHmacKey = dataDirP "hmac.key"
clusterConfFile :: IO FilePath
clusterConfFile = dataDirP "config.data"
lockStatusFile :: IO FilePath
lockStatusFile = dataDirP "locks.data"
tempResStatusFile :: IO FilePath
tempResStatusFile = dataDirP "tempres.data"
watcherPauseFile :: IO FilePath
watcherPauseFile = dataDirP "watcher.pause"
nodedCertFile :: IO FilePath
nodedCertFile = dataDirP "server.pem"
nodedClientCertFile :: IO FilePath
nodedClientCertFile = dataDirP "client.pem"
queueDir :: IO FilePath
queueDir = dataDirP "queue"
jobQueueSerialFile :: IO FilePath
jobQueueSerialFile = queueDir `pjoin` "serial"
jobQueueLockFile :: IO FilePath
jobQueueLockFile = queueDir `pjoin` "lock"
jobQueueDrainFile :: IO FilePath
jobQueueDrainFile = queueDir `pjoin` "drain"
jobQueueArchiveSubDir :: FilePath
jobQueueArchiveSubDir = "archive"
instanceReasonDir :: IO FilePath
instanceReasonDir = runDir `pjoin` "instance-reason"
getInstReasonFilename :: String -> IO FilePath
getInstReasonFilename instName = instanceReasonDir `pjoin` instName
jqueueExecutorPy :: IO FilePath
jqueueExecutorPy = return $ versionedsharedir
</> "ganeti" </> "jqueue" </> "exec.py"
kvmPidDir :: IO FilePath
kvmPidDir = runDir `pjoin` "kvm-hypervisor" `pjoin` "pid"