Revision 9eeb0aa5
b/Makefile.am | ||
---|---|---|
429 | 429 |
htools/Ganeti/Luxi.hs \ |
430 | 430 |
htools/Ganeti/Objects.hs \ |
431 | 431 |
htools/Ganeti/OpCodes.hs \ |
432 |
htools/Ganeti/Path.hs \ |
|
432 | 433 |
htools/Ganeti/Query/Common.hs \ |
433 | 434 |
htools/Ganeti/Query/Filter.hs \ |
434 | 435 |
htools/Ganeti/Query/Language.hs \ |
b/autotools/convert-constants | ||
---|---|---|
29 | 29 |
from ganeti import constants |
30 | 30 |
from ganeti import luxi |
31 | 31 |
from ganeti import qlang |
32 |
from ganeti import _autoconf |
|
33 |
|
|
32 | 34 |
|
33 | 35 |
#: Constant name regex |
34 | 36 |
CONSTANT_RE = re.compile("^[A-Z][A-Z0-9_-]+$") |
... | ... | |
46 | 48 |
# have strings instead of easily looked-up names. |
47 | 49 |
IGNORED_DECL_NAMES = ["DEFAULT_ENABLED_HYPERVISOR"] |
48 | 50 |
|
51 |
|
|
49 | 52 |
def NameRules(name): |
50 | 53 |
"""Converts the upper-cased Python name to Haskell camelCase. |
51 | 54 |
|
... | ... | |
289 | 292 |
print Convert(constants, "") |
290 | 293 |
print Convert(luxi, "luxi") |
291 | 294 |
print Convert(qlang, "qlang") |
295 |
print Convert(_autoconf, "autoconf") |
|
292 | 296 |
|
293 | 297 |
|
294 | 298 |
if __name__ == "__main__": |
b/htools/Ganeti/Confd/Server.hs | ||
---|---|---|
55 | 55 |
import Ganeti.Hash |
56 | 56 |
import Ganeti.Logging |
57 | 57 |
import qualified Ganeti.Constants as C |
58 |
import qualified Ganeti.Path as Path |
|
58 | 59 |
import Ganeti.Query.Server (runQueryD) |
59 | 60 |
|
60 | 61 |
-- * Types and constants definitions |
... | ... | |
503 | 504 |
hmac <- getClusterHmac |
504 | 505 |
-- Inotify setup |
505 | 506 |
inotify <- initINotify |
506 |
let inotiaction = addNotifier inotify C.clusterConfFile cref statemvar
|
|
507 |
let inotiaction = addNotifier inotify Path.clusterConfFile cref statemvar
|
|
507 | 508 |
-- fork the timeout timer |
508 |
_ <- forkIO $ onTimeoutTimer inotiaction C.clusterConfFile cref statemvar
|
|
509 |
_ <- forkIO $ onTimeoutTimer inotiaction Path.clusterConfFile cref statemvar
|
|
509 | 510 |
-- fork the polling timer |
510 |
_ <- forkIO $ onReloadTimer inotiaction C.clusterConfFile cref statemvar
|
|
511 |
_ <- forkIO $ onReloadTimer inotiaction Path.clusterConfFile cref statemvar
|
|
511 | 512 |
-- launch the queryd listener |
512 | 513 |
_ <- forkIO $ runQueryD Nothing (configReader cref) |
513 | 514 |
-- and finally enter the responder loop |
b/htools/Ganeti/Confd/Utils.hs | ||
---|---|---|
40 | 40 |
import Ganeti.Confd |
41 | 41 |
import Ganeti.Hash |
42 | 42 |
import qualified Ganeti.Constants as C |
43 |
import qualified Ganeti.Path as Path |
|
43 | 44 |
import Ganeti.JSON |
44 | 45 |
import Ganeti.HTools.Utils |
45 | 46 |
|
46 | 47 |
-- | Returns the HMAC key. |
47 | 48 |
getClusterHmac :: IO HashKey |
48 |
getClusterHmac = fmap B.unpack $ B.readFile C.confdHmacKey
|
|
49 |
getClusterHmac = fmap B.unpack $ B.readFile Path.confdHmacKey
|
|
49 | 50 |
|
50 | 51 |
-- | Parses a signed request. |
51 | 52 |
parseRequest :: HashKey -> String -> Result (String, String, ConfdRequest) |
b/htools/Ganeti/HTools/CLI.hs | ||
---|---|---|
36 | 36 |
, parseYesNo |
37 | 37 |
, parseISpecString |
38 | 38 |
, shTemplate |
39 |
, defaultLuxiSocket |
|
40 | 39 |
, maybePrintNodes |
41 | 40 |
, maybePrintInsts |
42 | 41 |
, maybeShowWarnings |
... | ... | |
92 | 91 |
|
93 | 92 |
import qualified Ganeti.HTools.Container as Container |
94 | 93 |
import qualified Ganeti.HTools.Node as Node |
95 |
import qualified Ganeti.Constants as C
|
|
94 |
import qualified Ganeti.Path as Path
|
|
96 | 95 |
import Ganeti.HTools.Types |
97 | 96 |
import Ganeti.HTools.Utils |
98 | 97 |
import Ganeti.BasicTypes |
99 | 98 |
import Ganeti.Common as Common |
100 | 99 |
|
101 |
-- * Constants |
|
102 |
|
|
103 |
-- | The default value for the luxi socket. |
|
104 |
-- |
|
105 |
-- This is re-exported from the "Ganeti.Constants" module. |
|
106 |
defaultLuxiSocket :: FilePath |
|
107 |
defaultLuxiSocket = C.masterSocket |
|
108 |
|
|
109 | 100 |
-- * Data types |
110 | 101 |
|
111 | 102 |
-- | Command line options structure. |
... | ... | |
301 | 292 |
oLuxiSocket :: OptType |
302 | 293 |
oLuxiSocket = Option "L" ["luxi"] |
303 | 294 |
(OptArg ((\ f opts -> Ok opts { optLuxi = Just f }) . |
304 |
fromMaybe defaultLuxiSocket) "SOCKET") |
|
295 |
fromMaybe Path.defaultLuxiSocket) "SOCKET")
|
|
305 | 296 |
"collect data via Luxi, optionally using the given SOCKET path" |
306 | 297 |
|
307 | 298 |
oMachineReadable :: OptType |
b/htools/Ganeti/HTools/Program/Hscan.hs | ||
---|---|---|
39 | 39 |
import qualified Ganeti.HTools.Instance as Instance |
40 | 40 |
import qualified Ganeti.HTools.Rapi as Rapi |
41 | 41 |
import qualified Ganeti.HTools.Luxi as Luxi |
42 |
import qualified Ganeti.Path as Path |
|
42 | 43 |
import Ganeti.HTools.Loader (checkData, mergeData, ClusterData(..)) |
43 | 44 |
import Ganeti.HTools.Text (serializeCluster) |
44 | 45 |
|
... | ... | |
138 | 139 |
"t_disk" "f_disk" "Score" |
139 | 140 |
|
140 | 141 |
when (null clusters) $ do |
141 |
let lsock = fromMaybe defaultLuxiSocket (optLuxi opts) |
|
142 |
let lsock = fromMaybe Path.defaultLuxiSocket (optLuxi opts)
|
|
142 | 143 |
let name = local |
143 | 144 |
input_data <- Luxi.loadData lsock |
144 | 145 |
result <- writeData nlen name opts input_data |
b/htools/Ganeti/Path.hs | ||
---|---|---|
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 |
|
27 |
( defaultLuxiSocket |
|
28 |
, defaultQuerySocket |
|
29 |
, dataDir |
|
30 |
, logDir |
|
31 |
, runDir |
|
32 |
, confdHmacKey |
|
33 |
, clusterConfFile |
|
34 |
) where |
|
35 |
|
|
36 |
import qualified Ganeti.Constants as C |
|
37 |
import System.FilePath |
|
38 |
|
|
39 |
|
|
40 |
-- | Directory for data |
|
41 |
dataDir :: FilePath |
|
42 |
dataDir = C.autoconfLocalstatedir </> "lib" </> "ganeti" |
|
43 |
|
|
44 |
-- | Directory for runtime files |
|
45 |
runDir :: FilePath |
|
46 |
runDir = C.autoconfLocalstatedir </> "run" </> "ganeti" |
|
47 |
|
|
48 |
-- | Directory for log files |
|
49 |
logDir :: FilePath |
|
50 |
logDir = C.autoconfLocalstatedir </> "log" </> "ganeti" |
|
51 |
|
|
52 |
-- | Directory for Unix sockets |
|
53 |
socketDir :: FilePath |
|
54 |
socketDir = runDir </> "socket" |
|
55 |
|
|
56 |
-- | The default LUXI socket path. |
|
57 |
defaultLuxiSocket :: FilePath |
|
58 |
defaultLuxiSocket = socketDir </> "ganeti-master" |
|
59 |
|
|
60 |
-- | The default LUXI socket for queries. |
|
61 |
defaultQuerySocket :: FilePath |
|
62 |
defaultQuerySocket = socketDir </> "ganeti-query" |
|
63 |
|
|
64 |
-- | Path to file containing confd's HMAC key |
|
65 |
confdHmacKey :: FilePath |
|
66 |
confdHmacKey = dataDir </> "hmac.key" |
|
67 |
|
|
68 |
-- | Path to cluster configuration file |
|
69 |
clusterConfFile :: FilePath |
|
70 |
clusterConfFile = dataDir </> "config.data" |
b/htools/Ganeti/Query/Server.hs | ||
---|---|---|
42 | 42 |
import System.Info (arch) |
43 | 43 |
|
44 | 44 |
import qualified Ganeti.Constants as C |
45 |
import qualified Ganeti.Path as Path |
|
45 | 46 |
import Ganeti.Daemon |
46 | 47 |
import Ganeti.Objects |
47 | 48 |
import qualified Ganeti.Config as Config |
... | ... | |
197 | 198 |
-- only one exposed from this module. |
198 | 199 |
runQueryD :: Maybe FilePath -> ConfigReader -> IO () |
199 | 200 |
runQueryD fpath creader = do |
200 |
let socket_path = fromMaybe C.querySocket fpath
|
|
201 |
let socket_path = fromMaybe Path.defaultQuerySocket fpath
|
|
201 | 202 |
cleanupSocket socket_path |
202 | 203 |
bracket |
203 | 204 |
(getServer socket_path) |
b/htools/Ganeti/Runtime.hs | ||
---|---|---|
49 | 49 |
import Text.Printf |
50 | 50 |
|
51 | 51 |
import qualified Ganeti.Constants as C |
52 |
import qualified Ganeti.Path as Path |
|
52 | 53 |
import Ganeti.BasicTypes |
53 | 54 |
|
54 | 55 |
data GanetiDaemon = GanetiMasterd |
... | ... | |
92 | 93 |
|
93 | 94 |
-- | Returns the log file for a daemon. |
94 | 95 |
daemonLogFile :: GanetiDaemon -> FilePath |
95 |
daemonLogFile daemon = C.logDir </> daemonName daemon <.> "log"
|
|
96 |
daemonLogFile daemon = Path.logDir </> daemonName daemon <.> "log"
|
|
96 | 97 |
|
97 | 98 |
-- | Returns the pid file name for a daemon. |
98 | 99 |
daemonPidFile :: GanetiDaemon -> FilePath |
99 |
daemonPidFile daemon = C.runDir </> daemonName daemon <.> "pid"
|
|
100 |
daemonPidFile daemon = Path.runDir </> daemonName daemon <.> "pid"
|
|
100 | 101 |
|
101 | 102 |
-- | All groups list. A bit hacking, as we can't enforce it's complete |
102 | 103 |
-- at compile time. |
b/htools/Ganeti/Ssconf.hs | ||
---|---|---|
46 | 46 |
import System.IO.Error (isDoesNotExistError) |
47 | 47 |
|
48 | 48 |
import qualified Ganeti.Constants as C |
49 |
import qualified Ganeti.Path as Path |
|
49 | 50 |
import Ganeti.BasicTypes |
50 | 51 |
import Ganeti.HTools.Utils |
51 | 52 |
|
... | ... | |
86 | 87 |
keyToFilename :: Maybe FilePath -- ^ Optional config path override |
87 | 88 |
-> SSKey -- ^ ssconf key |
88 | 89 |
-> FilePath |
89 |
keyToFilename optpath key = fromMaybe C.dataDir optpath </>
|
|
90 |
keyToFilename optpath key = fromMaybe Path.dataDir optpath </>
|
|
90 | 91 |
sSFilePrefix ++ sSKeyToRaw key |
91 | 92 |
|
92 | 93 |
-- | Runs an IO action while transforming any error into 'Bad' |
Also available in: Unified diff