1 {-| Path-related helper functions.
7 Copyright (C) 2012 Google Inc.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 module Ganeti.Path where
28 import qualified Ganeti.Constants as C
29 import System.FilePath
30 import System.Posix.Env (getEnvDefault)
31 import System.IO.Unsafe
33 {-# NOINLINE getRootDir #-}
34 getRootDir :: FilePath
35 getRootDir = unsafePerformIO $ getEnvDefault "GANETI_ROOTDIR" ""
37 -- | Prefixes a path with the current root directory
38 addNodePrefix :: FilePath -> FilePath
39 addNodePrefix path = getRootDir ++ path
41 -- | Directory for data
43 dataDir = addNodePrefix $ C.autoconfLocalstatedir </> "lib" </> "ganeti"
45 -- | Directory for runtime files
47 runDir = addNodePrefix $ C.autoconfLocalstatedir </> "run" </> "ganeti"
49 -- | Directory for log files
51 logDir = addNodePrefix $ C.autoconfLocalstatedir </> "log" </> "ganeti"
53 -- | Directory for Unix sockets
55 socketDir = runDir </> "socket"
57 -- | The default LUXI socket path.
58 defaultLuxiSocket :: FilePath
59 defaultLuxiSocket = socketDir </> "ganeti-master"
61 -- | The default LUXI socket for queries.
62 defaultQuerySocket :: FilePath
63 defaultQuerySocket = socketDir </> "ganeti-query"
65 -- | Path to file containing confd's HMAC key
66 confdHmacKey :: FilePath
67 confdHmacKey = dataDir </> "hmac.key"
69 -- | Path to cluster configuration file
70 clusterConfFile :: FilePath
71 clusterConfFile = dataDir </> "config.data"
74 nodedCertFile :: FilePath
75 nodedCertFile = dataDir </> "server.pem"