root / htools / Ganeti / Path.hs @ 37904802
History | View | Annotate | Download (2.1 kB)
1 |
{-| Path-related helper functions. |
---|---|
2 |
|
3 |
-} |
4 |
|
5 |
{- |
6 |
|
7 |
Copyright (C) 2012 Google Inc. |
8 |
|
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. |
13 |
|
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. |
18 |
|
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 |
22 |
02110-1301, USA. |
23 |
|
24 |
-} |
25 |
|
26 |
module Ganeti.Path where |
27 |
|
28 |
import qualified Ganeti.Constants as C |
29 |
import System.FilePath |
30 |
import System.Posix.Env (getEnvDefault) |
31 |
import System.IO.Unsafe |
32 |
|
33 |
{-# NOINLINE getRootDir #-} |
34 |
getRootDir :: FilePath |
35 |
getRootDir = unsafePerformIO $ getEnvDefault "GANETI_ROOTDIR" "" |
36 |
|
37 |
-- | Prefixes a path with the current root directory |
38 |
addNodePrefix :: FilePath -> FilePath |
39 |
addNodePrefix path = getRootDir ++ path |
40 |
|
41 |
-- | Directory for data |
42 |
dataDir :: FilePath |
43 |
dataDir = addNodePrefix $ C.autoconfLocalstatedir </> "lib" </> "ganeti" |
44 |
|
45 |
-- | Directory for runtime files |
46 |
runDir :: FilePath |
47 |
runDir = addNodePrefix $ C.autoconfLocalstatedir </> "run" </> "ganeti" |
48 |
|
49 |
-- | Directory for log files |
50 |
logDir :: FilePath |
51 |
logDir = addNodePrefix $ C.autoconfLocalstatedir </> "log" </> "ganeti" |
52 |
|
53 |
-- | Directory for Unix sockets |
54 |
socketDir :: FilePath |
55 |
socketDir = runDir </> "socket" |
56 |
|
57 |
-- | The default LUXI socket path. |
58 |
defaultLuxiSocket :: FilePath |
59 |
defaultLuxiSocket = socketDir </> "ganeti-master" |
60 |
|
61 |
-- | The default LUXI socket for queries. |
62 |
defaultQuerySocket :: FilePath |
63 |
defaultQuerySocket = socketDir </> "ganeti-query" |
64 |
|
65 |
-- | Path to file containing confd's HMAC key |
66 |
confdHmacKey :: FilePath |
67 |
confdHmacKey = dataDir </> "hmac.key" |
68 |
|
69 |
-- | Path to cluster configuration file |
70 |
clusterConfFile :: FilePath |
71 |
clusterConfFile = dataDir </> "config.data" |
72 |
|
73 |
-- | Path |
74 |
nodedCertFile :: FilePath |
75 |
nodedCertFile = dataDir </> "server.pem" |