root / src / Ganeti / Path.hs @ bc820a01
History | View | Annotate | Download (4.2 kB)
1 | 9eeb0aa5 | Michael Hanselmann | {-| Path-related helper functions. |
---|---|---|---|
2 | 9eeb0aa5 | Michael Hanselmann | |
3 | 9eeb0aa5 | Michael Hanselmann | -} |
4 | 9eeb0aa5 | Michael Hanselmann | |
5 | 9eeb0aa5 | Michael Hanselmann | {- |
6 | 9eeb0aa5 | Michael Hanselmann | |
7 | 582bfaf6 | Jose A. Lopes | Copyright (C) 2012, 2014 Google Inc. |
8 | 9eeb0aa5 | Michael Hanselmann | |
9 | 9eeb0aa5 | Michael Hanselmann | This program is free software; you can redistribute it and/or modify |
10 | 9eeb0aa5 | Michael Hanselmann | it under the terms of the GNU General Public License as published by |
11 | 9eeb0aa5 | Michael Hanselmann | the Free Software Foundation; either version 2 of the License, or |
12 | 9eeb0aa5 | Michael Hanselmann | (at your option) any later version. |
13 | 9eeb0aa5 | Michael Hanselmann | |
14 | 9eeb0aa5 | Michael Hanselmann | This program is distributed in the hope that it will be useful, but |
15 | 9eeb0aa5 | Michael Hanselmann | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | 9eeb0aa5 | Michael Hanselmann | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 | 9eeb0aa5 | Michael Hanselmann | General Public License for more details. |
18 | 9eeb0aa5 | Michael Hanselmann | |
19 | 9eeb0aa5 | Michael Hanselmann | You should have received a copy of the GNU General Public License |
20 | 9eeb0aa5 | Michael Hanselmann | along with this program; if not, write to the Free Software |
21 | 9eeb0aa5 | Michael Hanselmann | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
22 | 9eeb0aa5 | Michael Hanselmann | 02110-1301, USA. |
23 | 9eeb0aa5 | Michael Hanselmann | |
24 | 9eeb0aa5 | Michael Hanselmann | -} |
25 | 9eeb0aa5 | Michael Hanselmann | |
26 | 29a30533 | Iustin Pop | module Ganeti.Path |
27 | 29a30533 | Iustin Pop | ( dataDir |
28 | 29a30533 | Iustin Pop | , runDir |
29 | 29a30533 | Iustin Pop | , logDir |
30 | 29a30533 | Iustin Pop | , socketDir |
31 | 9d049fb4 | Klaus Aehlig | , defaultMasterSocket |
32 | 29a30533 | Iustin Pop | , defaultQuerySocket |
33 | 59881a0b | Petr Pudlak | , defaultWConfdSocket |
34 | 29a30533 | Iustin Pop | , confdHmacKey |
35 | 29a30533 | Iustin Pop | , clusterConfFile |
36 | f3eb4bfd | Klaus Aehlig | , lockStatusFile |
37 | 4b7863cb | Klaus Aehlig | , watcherPauseFile |
38 | 29a30533 | Iustin Pop | , nodedCertFile |
39 | b3cc1646 | Helga Velroyen | , nodedClientCertFile |
40 | 1db32048 | Iustin Pop | , queueDir |
41 | 1db32048 | Iustin Pop | , jobQueueSerialFile |
42 | 582bfaf6 | Jose A. Lopes | , jobQueueLockFile |
43 | 582bfaf6 | Jose A. Lopes | , jobQueueDrainFile |
44 | 1db32048 | Iustin Pop | , jobQueueArchiveSubDir |
45 | 74b25887 | Michele Tartara | , instanceReasonDir |
46 | 74b25887 | Michele Tartara | , getInstReasonFilename |
47 | 29a30533 | Iustin Pop | ) where |
48 | 9eeb0aa5 | Michael Hanselmann | |
49 | 9eeb0aa5 | Michael Hanselmann | import System.FilePath |
50 | 2f441f72 | Michael Hanselmann | import System.Posix.Env (getEnvDefault) |
51 | 2f441f72 | Michael Hanselmann | |
52 | f81d41cc | Jose A. Lopes | import AutoConf |
53 | 9eeb0aa5 | Michael Hanselmann | |
54 | 29a30533 | Iustin Pop | -- | Simple helper to concat two paths. |
55 | 29a30533 | Iustin Pop | pjoin :: IO String -> String -> IO String |
56 | 29a30533 | Iustin Pop | pjoin a b = do |
57 | 29a30533 | Iustin Pop | a' <- a |
58 | 29a30533 | Iustin Pop | return $ a' </> b |
59 | 29a30533 | Iustin Pop | |
60 | 29a30533 | Iustin Pop | -- | Returns the root directory, which can be either the real root or |
61 | 29a30533 | Iustin Pop | -- the virtual root. |
62 | 29a30533 | Iustin Pop | getRootDir :: IO FilePath |
63 | 29a30533 | Iustin Pop | getRootDir = getEnvDefault "GANETI_ROOTDIR" "" |
64 | 29a30533 | Iustin Pop | |
65 | 29a30533 | Iustin Pop | -- | Prefixes a path with the current root directory. |
66 | 29a30533 | Iustin Pop | addNodePrefix :: FilePath -> IO FilePath |
67 | 29a30533 | Iustin Pop | addNodePrefix path = do |
68 | 29a30533 | Iustin Pop | root <- getRootDir |
69 | 29a30533 | Iustin Pop | return $ root ++ path |
70 | 29a30533 | Iustin Pop | |
71 | 29a30533 | Iustin Pop | -- | Directory for data. |
72 | 29a30533 | Iustin Pop | dataDir :: IO FilePath |
73 | f81d41cc | Jose A. Lopes | dataDir = addNodePrefix $ AutoConf.localstatedir </> "lib" </> "ganeti" |
74 | 9eeb0aa5 | Michael Hanselmann | |
75 | 1db32048 | Iustin Pop | -- | Helper for building on top of dataDir (internal). |
76 | 1db32048 | Iustin Pop | dataDirP :: FilePath -> IO FilePath |
77 | 1db32048 | Iustin Pop | dataDirP = (dataDir `pjoin`) |
78 | 1db32048 | Iustin Pop | |
79 | 29a30533 | Iustin Pop | -- | Directory for runtime files. |
80 | 29a30533 | Iustin Pop | runDir :: IO FilePath |
81 | f81d41cc | Jose A. Lopes | runDir = addNodePrefix $ AutoConf.localstatedir </> "run" </> "ganeti" |
82 | 9eeb0aa5 | Michael Hanselmann | |
83 | 29a30533 | Iustin Pop | -- | Directory for log files. |
84 | 29a30533 | Iustin Pop | logDir :: IO FilePath |
85 | f81d41cc | Jose A. Lopes | logDir = addNodePrefix $ AutoConf.localstatedir </> "log" </> "ganeti" |
86 | 9eeb0aa5 | Michael Hanselmann | |
87 | 29a30533 | Iustin Pop | -- | Directory for Unix sockets. |
88 | 29a30533 | Iustin Pop | socketDir :: IO FilePath |
89 | 29a30533 | Iustin Pop | socketDir = runDir `pjoin` "socket" |
90 | 9eeb0aa5 | Michael Hanselmann | |
91 | 9d049fb4 | Klaus Aehlig | -- | The default path for the master-daemon LUXI socket. |
92 | 9d049fb4 | Klaus Aehlig | defaultMasterSocket :: IO FilePath |
93 | 9d049fb4 | Klaus Aehlig | defaultMasterSocket = socketDir `pjoin` "ganeti-master" |
94 | 9eeb0aa5 | Michael Hanselmann | |
95 | 9eeb0aa5 | Michael Hanselmann | -- | The default LUXI socket for queries. |
96 | 29a30533 | Iustin Pop | defaultQuerySocket :: IO FilePath |
97 | 29a30533 | Iustin Pop | defaultQuerySocket = socketDir `pjoin` "ganeti-query" |
98 | 9eeb0aa5 | Michael Hanselmann | |
99 | 59881a0b | Petr Pudlak | -- | The default WConfD socket for queries. |
100 | 59881a0b | Petr Pudlak | defaultWConfdSocket :: IO FilePath |
101 | 59881a0b | Petr Pudlak | defaultWConfdSocket = socketDir `pjoin` "ganeti-wconfd" |
102 | 59881a0b | Petr Pudlak | |
103 | 29a30533 | Iustin Pop | -- | Path to file containing confd's HMAC key. |
104 | 29a30533 | Iustin Pop | confdHmacKey :: IO FilePath |
105 | 1db32048 | Iustin Pop | confdHmacKey = dataDirP "hmac.key" |
106 | 9eeb0aa5 | Michael Hanselmann | |
107 | 29a30533 | Iustin Pop | -- | Path to cluster configuration file. |
108 | 29a30533 | Iustin Pop | clusterConfFile :: IO FilePath |
109 | 1db32048 | Iustin Pop | clusterConfFile = dataDirP "config.data" |
110 | 7766de33 | Agata Murawska | |
111 | f3eb4bfd | Klaus Aehlig | -- | Path to the file representing the lock status. |
112 | f3eb4bfd | Klaus Aehlig | lockStatusFile :: IO FilePath |
113 | f3eb4bfd | Klaus Aehlig | lockStatusFile = dataDirP "locks.data" |
114 | f3eb4bfd | Klaus Aehlig | |
115 | 4b7863cb | Klaus Aehlig | -- | Path to the watcher pause file. |
116 | 4b7863cb | Klaus Aehlig | watcherPauseFile :: IO FilePath |
117 | 4b7863cb | Klaus Aehlig | watcherPauseFile = dataDirP "watcher.pause" |
118 | 4b7863cb | Klaus Aehlig | |
119 | 29a30533 | Iustin Pop | -- | Path to the noded certificate. |
120 | 1db32048 | Iustin Pop | nodedCertFile :: IO FilePath |
121 | 1db32048 | Iustin Pop | nodedCertFile = dataDirP "server.pem" |
122 | 1db32048 | Iustin Pop | |
123 | b3cc1646 | Helga Velroyen | -- | Path to the noded client certificate. |
124 | b3cc1646 | Helga Velroyen | nodedClientCertFile :: IO FilePath |
125 | b3cc1646 | Helga Velroyen | nodedClientCertFile = dataDirP "client.pem" |
126 | b3cc1646 | Helga Velroyen | |
127 | 1db32048 | Iustin Pop | -- | Job queue directory. |
128 | 1db32048 | Iustin Pop | queueDir :: IO FilePath |
129 | 1db32048 | Iustin Pop | queueDir = dataDirP "queue" |
130 | 1db32048 | Iustin Pop | |
131 | 1db32048 | Iustin Pop | -- | Job queue serial file. |
132 | 1db32048 | Iustin Pop | jobQueueSerialFile :: IO FilePath |
133 | 6fe0f9a6 | Klaus Aehlig | jobQueueSerialFile = queueDir `pjoin` "serial" |
134 | 1db32048 | Iustin Pop | |
135 | 02926b4b | Klaus Aehlig | -- | Job queue lock file |
136 | 02926b4b | Klaus Aehlig | jobQueueLockFile :: IO FilePath |
137 | 02926b4b | Klaus Aehlig | jobQueueLockFile = queueDir `pjoin` "lock" |
138 | 02926b4b | Klaus Aehlig | |
139 | e773a018 | Klaus Aehlig | -- | Job queue drain file |
140 | e773a018 | Klaus Aehlig | jobQueueDrainFile :: IO FilePath |
141 | e773a018 | Klaus Aehlig | jobQueueDrainFile = queueDir `pjoin` "drain" |
142 | e773a018 | Klaus Aehlig | |
143 | 1db32048 | Iustin Pop | -- | Job queue archive directory. |
144 | 1db32048 | Iustin Pop | jobQueueArchiveSubDir :: FilePath |
145 | 1db32048 | Iustin Pop | jobQueueArchiveSubDir = "archive" |
146 | 74b25887 | Michele Tartara | |
147 | 74b25887 | Michele Tartara | -- | Directory containing the reason trails for the last change of status of |
148 | 74b25887 | Michele Tartara | -- instances. |
149 | 74b25887 | Michele Tartara | instanceReasonDir :: IO FilePath |
150 | 74b25887 | Michele Tartara | instanceReasonDir = runDir `pjoin` "instance-reason" |
151 | 74b25887 | Michele Tartara | |
152 | 74b25887 | Michele Tartara | -- | The path of the file containing the reason trail for an instance, given the |
153 | 74b25887 | Michele Tartara | -- instance name. |
154 | 74b25887 | Michele Tartara | getInstReasonFilename :: String -> IO FilePath |
155 | 74b25887 | Michele Tartara | getInstReasonFilename instName = instanceReasonDir `pjoin` instName |