I'd like to include this interdiff. It removes the commented-out code and
reflects changes in Ganeti.Wconfd.Monad
diff --git a/src/Ganeti/WConfd/Server.hs b/src/Ganeti/WConfd/Server.hs
index 37380b2..5b54022 100644
--- a/src/Ganeti/WConfd/Server.hs
+++ b/src/Ganeti/WConfd/Server.hs
@@ -45,7 +45,7 @@ import Ganeti.Runtime
import Ganeti.WConfd.Core
import Ganeti.WConfd.Monad
-handler :: DaemonHandle -> RpcServer WConfdMonadInternal
+handler :: DaemonHandle -> RpcServer WConfdMonadInt
handler ch = $( mkRpcM exportedFunctions )
@@ -66,7 +66,7 @@ prepMain _ _ = do
-- TODO: Lock the configuration file so that running the daemon twice
fails?
conf_file <- Path.clusterConfFile
- dhOpt <- runResultT $ mkDaemonHandle conf_file ConfigState LockingState
+ dhOpt <- runResultT $ mkDaemonHandle conf_file ConfigState
dh <- withError (strMsg . ("Initialization of the daemon failed" ++) .
show)
dhOpt
@@ -77,12 +77,9 @@ connectConfig = ConnectConfig GanetiLuxid 60 60
-- | Main function.
main :: MainFn () PrepResult
-main _ _ (server, dh) = -- do
- --initConfigReader id cref
- --let creader = readIORef cref
-
+main _ _ (server, dh) =
finally
- (forever $ runWConfdMonadInternal (listener (handler dh) server) dh)
+ (forever $ runWConfdMonadInt (listener (handler dh) server) dh)
(liftIO $ closeServer server)
On Thu, Feb 13, 2014 at 2:19 PM, Petr Pudlak <[email protected]> wrote:
> The daemon exposes the declared functions in Ganeti.WConfd.Core to RPC
> clients (currently just 'echo').
>
> Signed-off-by: Petr Pudlak <[email protected]>
> ---
> Makefile.am | 7 ++-
> daemons/daemon-util.in | 5 ++
> lib/pathutils.py | 2 +
> src/Ganeti/Path.hs | 5 ++
> src/Ganeti/WConfd/Server.hs | 96
> +++++++++++++++++++++++++++++++++++++++
> src/ganeti-wconfd.hs | 47 +++++++++++++++++++
> test/py/daemon-util_unittest.bash | 4 +-
> 7 files changed, 163 insertions(+), 3 deletions(-)
> create mode 100644 src/Ganeti/WConfd/Server.hs
> create mode 100644 src/ganeti-wconfd.hs
>
> diff --git a/Makefile.am b/Makefile.am
> index 288c9e4..82b5748 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -131,6 +131,7 @@ HS_DIRS = \
> src/Ganeti/Storage/Drbd \
> src/Ganeti/Storage/Lvm \
> src/Ganeti/THH \
> + src/Ganeti/WConfd \
> test/hs \
> test/hs/Test \
> test/hs/Test/Ganeti \
> @@ -272,6 +273,7 @@ CLEANFILES = \
> $(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
> $(HS_BUILT_TEST_HELPERS) \
> src/ganeti-confd \
> + src/ganeti-wconfd \
> src/ganeti-luxid \
> src/ganeti-mond \
> .hpc/*.mix src/*.tix test/hs/*.tix *.tix \
> @@ -601,6 +603,7 @@ HS_COMPILE_PROGS= \
> src/ganeti-metad \
> src/ganeti-mond \
> src/hconfd \
> + src/ganeti-wconfd \
> src/hluxid \
> src/hs2py \
> src/rpc-test
> @@ -758,7 +761,8 @@ HS_LIB_SRCS = \
> src/Ganeti/Utils.hs \
> src/Ganeti/VCluster.hs \
> src/Ganeti/WConfd/Core.hs \
> - src/Ganeti/WConfd/Monad.hs
> + src/Ganeti/WConfd/Monad.hs \
> + src/Ganeti/WConfd/Server.hs
>
> HS_TEST_SRCS = \
> test/hs/Test/AutoConf.hs \
> @@ -1077,6 +1081,7 @@ src/ganeti-luxid: src/hluxid
> cp -f $< $@
>
> nodist_sbin_SCRIPTS += src/ganeti-confd
> +nodist_sbin_SCRIPTS += src/ganeti-wconfd
> nodist_sbin_SCRIPTS += src/ganeti-luxid
> nodist_sbin_SCRIPTS += src/ganeti-kvmd
> nodist_sbin_SCRIPTS += src/ganeti-metad
> diff --git a/daemons/daemon-util.in b/daemons/daemon-util.in
> index f925174..ca72480 100644
> --- a/daemons/daemon-util.in
> +++ b/daemons/daemon-util.in
> @@ -28,6 +28,7 @@ readonly defaults_file="$SYSCONFDIR/default/ganeti"
> # order is important as there are dependencies between them. On shutdown,
> # they're stopped in reverse order.
> DAEMONS=(
> + ganeti-wconfd
> ganeti-noded
> ganeti-masterd
> ganeti-rapi
> @@ -53,6 +54,7 @@ fi
> NODED_ARGS=
> MASTERD_ARGS=
> CONFD_ARGS=
> +WCONFD_ARGS=
> LUXID_ARGS=
> RAPI_ARGS=
> MOND_ARGS=
> @@ -84,6 +86,9 @@ _daemon_usergroup() {
> confd)
> echo "@GNTCONFDUSER@:@GNTCONFDGROUP@"
> ;;
> + wconfd)
> + echo "@GNTWCONFDUSER@:@GNTWCONFDGROUP@"
> + ;;
> luxid)
> echo "@GNTLUXIDUSER@:@GNTLUXIDGROUP@"
> ;;
> diff --git a/lib/pathutils.py b/lib/pathutils.py
> index db860ff..d7b1d6e 100644
> --- a/lib/pathutils.py
> +++ b/lib/pathutils.py
> @@ -137,6 +137,8 @@ EXTERNAL_MASTER_SETUP_SCRIPT = USER_SCRIPTS_DIR +
> "/master-ip-setup"
> MASTER_SOCKET = SOCKET_DIR + "/ganeti-master"
> #: LUXI socket used for queries only
> QUERY_SOCKET = SOCKET_DIR + "/ganeti-query"
> +#: WConfD socket
> +WCONFD_SOCKET = SOCKET_DIR + "/ganeti-wconfd"
>
> LOG_OS_DIR = LOG_DIR + "/os"
> LOG_ES_DIR = LOG_DIR + "/extstorage"
> diff --git a/src/Ganeti/Path.hs b/src/Ganeti/Path.hs
> index ce59400..4a18e39 100644
> --- a/src/Ganeti/Path.hs
> +++ b/src/Ganeti/Path.hs
> @@ -30,6 +30,7 @@ module Ganeti.Path
> , socketDir
> , defaultMasterSocket
> , defaultQuerySocket
> + , defaultWConfdSocket
> , confdHmacKey
> , clusterConfFile
> , watcherPauseFile
> @@ -94,6 +95,10 @@ defaultMasterSocket = socketDir `pjoin` "ganeti-master"
> defaultQuerySocket :: IO FilePath
> defaultQuerySocket = socketDir `pjoin` "ganeti-query"
>
> +-- | The default WConfD socket for queries.
> +defaultWConfdSocket :: IO FilePath
> +defaultWConfdSocket = socketDir `pjoin` "ganeti-wconfd"
> +
> -- | Path to file containing confd's HMAC key.
> confdHmacKey :: IO FilePath
> confdHmacKey = dataDirP "hmac.key"
> diff --git a/src/Ganeti/WConfd/Server.hs b/src/Ganeti/WConfd/Server.hs
> new file mode 100644
> index 0000000..37380b2
> --- /dev/null
> +++ b/src/Ganeti/WConfd/Server.hs
> @@ -0,0 +1,96 @@
> +{-# LANGUAGE TemplateHaskell #-}
> +
> +{-| The implementation of Ganeti WConfd daemon server.
> +
> +As TemplateHaskell require that splices be defined in a separate
> +module, we combine all the TemplateHaskell functionality that HTools
> +needs in this module (except the one for unittests).
> +
> +-}
> +
> +{-
> +
> +Copyright (C) 2013 Google Inc.
> +
> +This program is free software; you can redistribute it and/or modify
> +it under the terms of the GNU General Public License as published by
> +the Free Software Foundation; either version 2 of the License, or
> +(at your option) any later version.
> +
> +This program is distributed in the hope that it will be useful, but
> +WITHOUT ANY WARRANTY; without even the implied warranty of
> +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> +General Public License for more details.
> +
> +You should have received a copy of the GNU General Public License
> +along with this program; if not, write to the Free Software
> +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> +02110-1301, USA.
> +
> +-}
> +
> +module Ganeti.WConfd.Server where
> +
> +import Control.Exception
> +import Control.Monad
> +import Control.Monad.Error
> +
> +import Ganeti.BasicTypes
> +import Ganeti.Daemon
> +import qualified Ganeti.Path as Path
> +import Ganeti.THH.RPC
> +import Ganeti.UDSServer
> +
> +import Ganeti.Runtime
> +import Ganeti.WConfd.Core
> +import Ganeti.WConfd.Monad
> +
> +handler :: DaemonHandle -> RpcServer WConfdMonadInternal
> +handler ch = $( mkRpcM exportedFunctions )
> +
> +
> +-- | Type alias for prepMain results
> +type PrepResult = (Server, DaemonHandle)
> +
> +-- | Check function for luxid.
> +checkMain :: CheckFn ()
> +checkMain _ = return $ Right ()
> +
> +-- | Prepare function for luxid.
> +prepMain :: PrepFn () PrepResult
> +prepMain _ _ = do
> + socket_path <- Path.defaultWConfdSocket
> + cleanupSocket socket_path
> + s <- describeError "binding to the socket" Nothing (Just socket_path)
> + $ connectServer connectConfig True socket_path
> + -- TODO: Lock the configuration file so that running the daemon twice
> fails?
> + conf_file <- Path.clusterConfFile
> +
> + dhOpt <- runResultT $ mkDaemonHandle conf_file ConfigState LockingState
> + dh <- withError (strMsg . ("Initialization of the daemon failed" ++) .
> show)
> + dhOpt
> +
> + return (s, dh)
> +
> +connectConfig :: ConnectConfig
> +connectConfig = ConnectConfig GanetiLuxid 60 60
> +
> +-- | Main function.
> +main :: MainFn () PrepResult
> +main _ _ (server, dh) = -- do
> + --initConfigReader id cref
> + --let creader = readIORef cref
> +
> + finally
> + (forever $ runWConfdMonadInternal (listener (handler dh) server) dh)
> + (liftIO $ closeServer server)
> +
> +
> +-- | Options list and functions.
> +options :: [OptType]
> +options =
> + [ oNoDaemonize
> + , oNoUserChecks
> + , oDebug
> + , oSyslogUsage
> + ]
> diff --git a/src/ganeti-wconfd.hs b/src/ganeti-wconfd.hs
> new file mode 100644
> index 0000000..8be010d
> --- /dev/null
> +++ b/src/ganeti-wconfd.hs
> @@ -0,0 +1,47 @@
> +{-| Ganeti WConfD (config writer) daemon
> +
> +-}
> +
> +{-
> +
> +Copyright (C) 2013 Google Inc.
> +
> +This program is free software; you can redistribute it and/or modify
> +it under the terms of the GNU General Public License as published by
> +the Free Software Foundation; either version 2 of the License, or
> +(at your option) any later version.
> +
> +This program is distributed in the hope that it will be useful, but
> +WITHOUT ANY WARRANTY; without even the implied warranty of
> +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> +General Public License for more details.
> +
> +You should have received a copy of the GNU General Public License
> +along with this program; if not, write to the Free Software
> +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> +02110-1301, USA.
> +
> +-}
> +
> +module Main (main) where
> +
> +import qualified Ganeti.WConfd.Server
> +import Ganeti.Daemon
> +import Ganeti.Runtime
> +
> +-- | Options list and functions.
> +options :: [OptType]
> +options =
> + [ oNoDaemonize
> + , oNoUserChecks
> + , oDebug
> + , oSyslogUsage
> + ]
> +
> +-- | Main function.
> +main :: IO ()
> +main =
> + genericMain GanetiWConfd options
> + Ganeti.WConfd.Server.checkMain
> + Ganeti.WConfd.Server.prepMain
> + Ganeti.WConfd.Server.main
> diff --git a/test/py/daemon-util_unittest.bash
> b/test/py/daemon-util_unittest.bash
> index f5b98f0..a31c3c6 100755
> --- a/test/py/daemon-util_unittest.bash
> +++ b/test/py/daemon-util_unittest.bash
> @@ -36,8 +36,8 @@ if ! grep -q '^ENABLE_MOND = ' lib/_constants.py; then
> err "Please update $0, mond enable feature is missing"
> fi
>
> -DAEMONS_LIST="noded masterd rapi luxid"
> -STOPDAEMONS_LIST="luxid rapi masterd noded"
> +DAEMONS_LIST="wconfd noded masterd rapi luxid"
> +STOPDAEMONS_LIST="luxid rapi masterd noded wconfd"
>
> if grep -q '^ENABLE_CONFD = True' lib/_constants.py; then
> DAEMONS_LIST="$DAEMONS_LIST confd"
> --
> 1.9.0.rc1.175.g0b1dcb5
>
>