LGTM, thanks.
On Mon, Oct 7, 2013 at 4:37 PM, Jose A. Lopes <[email protected]> wrote: > Add RPC timeout related constants to the Haskell to Python constant > generation. The Haskell data type 'RpcTimeout' is moved from > 'Ganeti.Rpc' to 'Ganeti.Types' so it can be used by > 'Ganeti.HsConstants' without causing circularity problems with > 'Ganeti.Rpc'. > > Signed-off-by: Jose A. Lopes <[email protected]> > --- > lib/constants.py | 19 ++++++++----------- > src/Ganeti/HsConstants.hs | 34 ++++++++++++++++++++++++++++++++++ > src/Ganeti/Rpc.hs | 12 ------------ > src/Ganeti/Types.hs | 13 +++++++++++++ > 4 files changed, 55 insertions(+), 23 deletions(-) > > diff --git a/lib/constants.py b/lib/constants.py > index f8bc699..8319124 100644 > --- a/lib/constants.py > +++ b/lib/constants.py > @@ -629,6 +629,14 @@ DISK_TRANSFER_CONNECT_TIMEOUT = 60 > DISK_SEPARATOR = _constants.DISK_SEPARATOR > IP_COMMAND_PATH = _constants.IP_COMMAND_PATH > > +RPC_TMO_URGENT = _constants.RPC_TMO_URGENT > +RPC_TMO_FAST = _constants.RPC_TMO_FAST > +RPC_TMO_NORMAL = _constants.RPC_TMO_NORMAL > +RPC_TMO_SLOW = _constants.RPC_TMO_SLOW > +RPC_TMO_4HRS = _constants.RPC_TMO_4HRS > +RPC_TMO_1DAY = _constants.RPC_TMO_1DAY > +RPC_CONNECT_TIMEOUT = _constants.RPC_CONNECT_TIMEOUT > + > #: Key for job IDs in opcode result > JOB_IDS_KEY = "jobs" > > @@ -647,17 +655,6 @@ RUNPARTS_STATUS = compat.UniqueFrozenset([ > (RPC_ENCODING_NONE, > RPC_ENCODING_ZLIB_BASE64) = range(2) > > -# Various time constants for the timeout table > -RPC_TMO_URGENT = 60 # one minute > -RPC_TMO_FAST = 5 * 60 # five minutes > -RPC_TMO_NORMAL = 15 * 60 # 15 minutes > -RPC_TMO_SLOW = 3600 # one hour > -RPC_TMO_4HRS = 4 * 3600 > -RPC_TMO_1DAY = 86400 > - > -# Timeout for connecting to nodes (seconds) > -RPC_CONNECT_TIMEOUT = 5 > - > # os related constants > OS_SCRIPT_CREATE = "create" > OS_SCRIPT_IMPORT = "import" > diff --git a/src/Ganeti/HsConstants.hs b/src/Ganeti/HsConstants.hs > index 440d2e0..195bc2f 100644 > --- a/src/Ganeti/HsConstants.hs > +++ b/src/Ganeti/HsConstants.hs > @@ -55,6 +55,8 @@ import Ganeti.Confd.Types (ConfdRequestType(..), > ConfdReqField(..), > ConfdErrorType(..)) > import qualified Ganeti.Confd.Types as Types > > +{-# ANN module "HLint: ignore Use camelCase" #-} > + > -- * 'autoconf' constants for Python only > ('autotools/build-bash-completion') > > htoolsProgs :: [String] > @@ -630,6 +632,38 @@ nodeMaxClockSkew = 150 > diskSeparator :: String > diskSeparator = AutoConf.diskSeparator > > +-- * Timeout table > +-- > +-- Various time constants for the timeout table > + > +rpcTmoUrgent :: Int > +rpcTmoUrgent = Types.rpcTimeoutToRaw Urgent > + > +rpcTmoFast :: Int > +rpcTmoFast = Types.rpcTimeoutToRaw Fast > + > +rpcTmoNormal :: Int > +rpcTmoNormal = Types.rpcTimeoutToRaw Normal > + > +rpcTmoSlow :: Int > +rpcTmoSlow = Types.rpcTimeoutToRaw Slow > + > +-- | 'rpcTmo_4hrs' contains an underscore to circumvent a limitation > +-- in the 'Ganeti.THH.deCamelCase' function and generate the correct > +-- Python name. > +rpcTmo_4hrs :: Int > +rpcTmo_4hrs = Types.rpcTimeoutToRaw FourHours > + > +-- | 'rpcTmo_1day' contains an underscore to circumvent a limitation > +-- in the 'Ganeti.THH.deCamelCase' function and generate the correct > +-- Python name. > +rpcTmo_1day :: Int > +rpcTmo_1day = Types.rpcTimeoutToRaw OneDay > + > +-- | Timeout for connecting to nodes (seconds) > +rpcConnectTimeout :: Int > +rpcConnectTimeout = 5 > + > ipCommandPath :: String > ipCommandPath = AutoConf.ipPath > > diff --git a/src/Ganeti/Rpc.hs b/src/Ganeti/Rpc.hs > index a311b21..d69c9b7 100644 > --- a/src/Ganeti/Rpc.hs > +++ b/src/Ganeti/Rpc.hs > @@ -68,8 +68,6 @@ module Ganeti.Rpc > > , RpcCallExportList(..) > , RpcResultExportList(..) > - > - , rpcTimeoutFromRaw -- FIXME: Not used anywhere > ) where > > import Control.Arrow (second) > @@ -123,16 +121,6 @@ explainRpcError OfflineNodeError = > > type ERpcError = Either RpcError > > --- | Basic timeouts for RPC calls. > -$(declareIADT "RpcTimeout" > - [ ( "Urgent", 'C.rpcTmoUrgent ) > - , ( "Fast", 'C.rpcTmoFast ) > - , ( "Normal", 'C.rpcTmoNormal ) > - , ( "Slow", 'C.rpcTmoSlow ) > - , ( "FourHours", 'C.rpcTmo4hrs ) > - , ( "OneDay", 'C.rpcTmo1day ) > - ]) > - > -- | A generic class for RPC calls. > class (J.JSON a) => RpcCall a where > -- | Give the (Python) name of the procedure. > diff --git a/src/Ganeti/Types.hs b/src/Ganeti/Types.hs > index 5a788be..e737065 100644 > --- a/src/Ganeti/Types.hs > +++ b/src/Ganeti/Types.hs > @@ -145,6 +145,9 @@ module Ganeti.Types > , diskAccessModeToRaw > , ReplaceDisksMode(..) > , replaceDisksModeToRaw > + , RpcTimeout(..) > + , rpcTimeoutFromRaw -- FIXME: no used anywhere > + , rpcTimeoutToRaw > ) where > > import Control.Monad (liftM) > @@ -793,3 +796,13 @@ $(THH.declareLADT ''String "ReplaceDisksMode" > , ("ReplaceAuto", "replace_auto") > ]) > $(THH.makeJSONInstance ''ReplaceDisksMode) > + > +-- | Basic timeouts for RPC calls. > +$(THH.declareILADT "RpcTimeout" > + [ ("Urgent", 60) -- 1 minute > + , ("Fast", 5 * 60) -- 5 minutes > + , ("Normal", 15 * 60) -- 15 minutes > + , ("Slow", 3600) -- 1 hour > + , ("FourHours", 4 * 3600) -- 4 hours > + , ("OneDay", 86400) -- 1 day > + ]) > -- > 1.8.4 > > -- Thomas Thrainer | Software Engineer | [email protected] | 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
