On Tue, Sep 17, 2013 at 3:56 PM, Jose A. Lopes <[email protected]> wrote:
> Interdiff: > > * fix 'Ganeti.Runtime' after pulling fix for issue 575. > > * add extra logreason constants, namely, 'extraLogreasonAccess' and > 'extraLogreasonError', to the Haskell to Python constants > generation. In Haskell, these constants were moved to > 'Ganeti.Runtime', therefore, the Python couterparts must be updated > to fetch their values from the generated constants module. > > Signed-off-by: Jose A. Lopes <[email protected]> > --- > lib/constants.py | 4 ++-- > src/Ganeti/HsConstants.hs | 9 ++++++++- > src/Ganeti/Monitoring/Server.hs | 15 ++++++--------- > src/Ganeti/Runtime.hs | 19 +++++++------------ > 4 files changed, 23 insertions(+), 24 deletions(-) > > diff --git a/lib/constants.py b/lib/constants.py > index f7e83f2..1540a4c 100644 > --- a/lib/constants.py > +++ b/lib/constants.py > @@ -203,8 +203,8 @@ VALID_EXTRA_LOGREASONS = compat.UniqueFrozenset([ > # These are the extra logfiles, grouped by daemon > DAEMONS_EXTRA_LOGBASE = { > MOND: { > - EXTRA_LOGREASON_ACCESS: "monitoring-daemon-access", > - EXTRA_LOGREASON_ERROR: "monitoring-daemon-error", > + EXTRA_LOGREASON_ACCESS: _constants.EXTRA_LOGREASON_ACCESS, > + EXTRA_LOGREASON_ERROR: _constants.EXTRA_LOGREASON_ERROR, > } > } > > diff --git a/src/Ganeti/HsConstants.hs b/src/Ganeti/HsConstants.hs > index 84796bd..244f5f9 100644 > --- a/src/Ganeti/HsConstants.hs > +++ b/src/Ganeti/HsConstants.hs > @@ -42,7 +42,8 @@ import qualified Data.Map as Map (fromList) > import AutoConf > import Ganeti.ConstantUtils (FrozenSet, Protocol(..)) > import qualified Ganeti.ConstantUtils as ConstantUtils (mkSet, > exitFailure) > -import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..)) > +import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..), > + ExtraLogReason(..)) > import qualified Ganeti.Runtime as Runtime > > -- * Admin states > @@ -166,6 +167,12 @@ daemonsPorts = > (rapi, (Tcp, defaultRapiPort)), > (ssh, (Tcp, 22))] > > +extraLogreasonAccess :: String > +extraLogreasonAccess = Runtime.daemonsExtraLogbase GanetiMond AccessLog > + > +extraLogreasonError :: String > +extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog > + > Extreme nitpicking: Logreason is usually in camelcase in most other parts of the sourcecode, so why not calling these two functions "extraLogReasonAccess" and "extraLogReasonError"? -- * Possible values for NodeGroup.alloc_policy > > allocPolicyLastResort :: String > diff --git a/src/Ganeti/Monitoring/Server.hs > b/src/Ganeti/Monitoring/Server.hs > index 2cedbac..d30c7d1 100644 > --- a/src/Ganeti/Monitoring/Server.hs > +++ b/src/Ganeti/Monitoring/Server.hs > @@ -117,15 +117,12 @@ checkMain _ = return $ Right () > -- | Prepare function for monitoring agent. > prepMain :: PrepFn CheckResult PrepResult > prepMain opts _ = do > - mAccessLog <- daemonsExtraLogFile GanetiMond AccessLog > - mErrorLog <- daemonsExtraLogFile GanetiMond ErrorLog > - case (mAccessLog, mErrorLog) of > - (Just accessLog, Just errorLog) -> > - return $ > - setPort > - (maybe C.defaultMondPort fromIntegral (optPort opts)) > - (defaultHttpConf accessLog errorLog) > - _ -> fail "Failed to retrieve extra log filepaths for the monitoring > daemon" > + accessLog <- daemonsExtraLogFile GanetiMond AccessLog > + errorLog <- daemonsExtraLogFile GanetiMond ErrorLog > + return $ > + setPort > + (maybe C.defaultMondPort fromIntegral (optPort opts)) > + (defaultHttpConf accessLog errorLog) > > -- * Query answers > > diff --git a/src/Ganeti/Runtime.hs b/src/Ganeti/Runtime.hs > index 343b395..809c384 100644 > --- a/src/Ganeti/Runtime.hs > +++ b/src/Ganeti/Runtime.hs > @@ -35,6 +35,7 @@ module Ganeti.Runtime > , daemonGroup > , ExtraLogReason(..) > , daemonLogFile > + , daemonsExtraLogbase > , daemonsExtraLogFile > , daemonPidFile > , getEnts > @@ -125,14 +126,9 @@ daemonGroup (ExtraGroup AdminGroup) = > AutoConf.adminGroup > > data ExtraLogReason = AccessLog | ErrorLog > > -daemonsExtraLogbase :: GanetiDaemon -> ExtraLogReason -> Maybe String > -daemonsExtraLogbase GanetiMond AccessLog = > - Just C.daemonsExtraLogbaseGanetiMondAccess > - > -daemonsExtraLogbase GanetiMond ErrorLog = > - Just C.daemonsExtraLogbaseGanetiMondError > - > -daemonsExtraLogbase _ _ = Nothing > +daemonsExtraLogbase :: GanetiDaemon -> ExtraLogReason -> String > +daemonsExtraLogbase daemon AccessLog = daemonLogBase daemon ++ "access" > +daemonsExtraLogbase daemon ErrorLog = daemonLogBase daemon ++ "error" > > The two strings should be "-access" and "-error", to stay compatible with their current definition in the python constants. > -- | Returns the log file for a daemon. > daemonLogFile :: GanetiDaemon -> IO FilePath > @@ -140,12 +136,11 @@ daemonLogFile daemon = do > logDir <- Path.logDir > return $ logDir </> daemonLogBase daemon <.> "log" > > -daemonsExtraLogFile :: GanetiDaemon -> ExtraLogReason -> IO (Maybe > FilePath) > +-- | Returns the extra log files for a daemon. > +daemonsExtraLogFile :: GanetiDaemon -> ExtraLogReason -> IO FilePath > daemonsExtraLogFile daemon logreason = do > logDir <- Path.logDir > - case daemonsExtraLogbase daemon logreason of > - Nothing -> return Nothing > - Just logbase -> return . Just $ logDir </> logbase <.> "log" > + return $ logDir </> daemonsExtraLogbase daemon logreason <.> "log" > > -- | Returns the pid file name for a daemon. > daemonPidFile :: GanetiDaemon -> IO FilePath > -- > 1.8.4 > > Thanks, Michele -- Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
