Commit 59881a0b authored by Petr Pudlak's avatar Petr Pudlak

Add the WConfD daemon itself

The daemon exposes the declared functions in Ganeti.WConfd.Core to RPC
clients (currently just 'echo').
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent fb0fa957
......@@ -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
......@@ -759,7 +762,8 @@ HS_LIB_SRCS = \
src/Ganeti/VCluster.hs \
src/Ganeti/WConfd/ConfigState.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 \
......@@ -1078,6 +1082,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
......
......@@ -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@"
;;
......
......@@ -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"
......
......@@ -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"
......
{-# 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.ConfigState
import Ganeti.WConfd.Core
import Ganeti.WConfd.Monad
handler :: DaemonHandle -> RpcServer WConfdMonadInt
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 mkConfigState
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) =
finally
(forever $ runWConfdMonadInt (listener (handler dh) server) dh)
(liftIO $ closeServer server)
-- | Options list and functions.
options :: [OptType]
options =
[ oNoDaemonize
, oNoUserChecks
, oDebug
, oSyslogUsage
]
{-| 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
......@@ -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"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment