Revision 7f58ff5d src/Ganeti/Query/Cluster.hs
b/src/Ganeti/Query/Cluster.hs | ||
---|---|---|
25 | 25 |
|
26 | 26 |
module Ganeti.Query.Cluster |
27 | 27 |
( clusterMasterNodeName |
28 |
, isWatcherPaused |
|
28 | 29 |
) where |
29 | 30 |
|
31 |
import Control.Exception (try) |
|
30 | 32 |
import Control.Monad (liftM) |
33 |
import Data.Char (isSpace) |
|
34 |
import Numeric (readDec) |
|
31 | 35 |
|
32 |
import Ganeti.Objects |
|
33 | 36 |
import Ganeti.Config |
34 | 37 |
import Ganeti.Errors |
38 |
import Ganeti.Logging |
|
39 |
import Ganeti.Objects |
|
40 |
import Ganeti.Path |
|
41 |
import Ganeti.Utils (getCurrentTime) |
|
35 | 42 |
|
36 | 43 |
-- | Get master node name. |
37 | 44 |
clusterMasterNodeName :: ConfigData -> ErrorResult String |
... | ... | |
39 | 46 |
let cluster = configCluster cfg |
40 | 47 |
masterNodeUuid = clusterMasterNode cluster |
41 | 48 |
in liftM nodeName $ getNode cfg masterNodeUuid |
49 |
|
|
50 |
isWatcherPaused :: IO (Maybe Integer) |
|
51 |
isWatcherPaused = do |
|
52 |
logDebug "Checking if the watcher is paused" |
|
53 |
wfile <- watcherPauseFile |
|
54 |
contents <- try $ readFile wfile :: IO (Either IOError String) |
|
55 |
case contents of |
|
56 |
Left _ -> return Nothing |
|
57 |
Right s -> case readDec (dropWhile isSpace s) of |
|
58 |
[(n, rest)] | all isSpace rest -> do |
|
59 |
now <- getCurrentTime |
|
60 |
return $ if n > now then Just n else Nothing |
|
61 |
_ -> do |
|
62 |
logWarning $ "Watcher pause file contents '" ++ s |
|
63 |
++ "' not parsable as int" |
|
64 |
return Nothing |
Also available in: Unified diff