root / src / Ganeti / WConfd / Core.hs @ 84640a93
History | View | Annotate | Download (1.8 kB)
1 |
{-# LANGUAGE TemplateHaskell #-} |
---|---|
2 |
|
3 |
{-| The Ganeti WConfd core functions. |
4 |
|
5 |
As TemplateHaskell require that splices be defined in a separate |
6 |
module, we combine all the TemplateHaskell functionality that HTools |
7 |
needs in this module (except the one for unittests). |
8 |
|
9 |
-} |
10 |
|
11 |
{- |
12 |
|
13 |
Copyright (C) 2013 Google Inc. |
14 |
|
15 |
This program is free software; you can redistribute it and/or modify |
16 |
it under the terms of the GNU General Public License as published by |
17 |
the Free Software Foundation; either version 2 of the License, or |
18 |
(at your option) any later version. |
19 |
|
20 |
This program is distributed in the hope that it will be useful, but |
21 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
22 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
23 |
General Public License for more details. |
24 |
|
25 |
You should have received a copy of the GNU General Public License |
26 |
along with this program; if not, write to the Free Software |
27 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
28 |
02110-1301, USA. |
29 |
|
30 |
-} |
31 |
|
32 |
module Ganeti.WConfd.Core where |
33 |
|
34 |
import qualified Data.Map as M |
35 |
import Language.Haskell.TH (Name) |
36 |
|
37 |
import qualified Ganeti.Locking.Allocation as L |
38 |
import Ganeti.Locking.Locks (GanetiLocks) |
39 |
import Ganeti.Types (JobId) |
40 |
import Ganeti.WConfd.Monad |
41 |
import Ganeti.WConfd.ConfigWriter |
42 |
|
43 |
-- * Functions available to the RPC module |
44 |
|
45 |
-- Just a test function |
46 |
echo :: String -> WConfdMonad String |
47 |
echo = return |
48 |
|
49 |
-- ** Configuration related functions |
50 |
|
51 |
-- ** Locking related functions |
52 |
|
53 |
-- | List the locks of a given owner (i.e., a job-id lockfile pair). |
54 |
listLocks :: JobId -> FilePath -> WConfdMonad [(GanetiLocks, L.OwnerState)] |
55 |
listLocks jid fpath = |
56 |
liftM (M.toList . L.listLocks (jid, fpath)) readLockAllocation |
57 |
|
58 |
-- * The list of all functions exported to RPC. |
59 |
|
60 |
exportedFunctions :: [Name] |
61 |
exportedFunctions = [ 'echo, 'readConfig, 'writeConfig, 'listLocks] |