diff --git a/Ganeti/HTools/Rapi.hs b/Ganeti/HTools/Rapi.hs index fc6a46cb78c462c6624c5b0a6d506ddc93b8de4b..4a06c029c90cfcb34085d64d76cd33bd5907bc43 100644 --- a/Ganeti/HTools/Rapi.hs +++ b/Ganeti/HTools/Rapi.hs @@ -46,7 +46,10 @@ import qualified Ganeti.HTools.Instance as Instance getUrl :: (Monad m) => String -> IO (m String) getUrl url = do (code, body) <- curlGetString url [CurlSSLVerifyPeer False, - CurlSSLVerifyHost 0] + CurlSSLVerifyHost 0, + CurlTimeout (fromIntegral queryTimeout), + CurlConnectTimeout + (fromIntegral connTimeout)] return (case code of CurlOK -> return body _ -> fail $ printf "Curl error for '%s', error %s" diff --git a/Ganeti/HTools/Types.hs b/Ganeti/HTools/Types.hs index 4a009f449a20fd413c83a08e31a2f4678f928a71..8b082353f34f5674d823923e2457d4cd8f294a35 100644 --- a/Ganeti/HTools/Types.hs +++ b/Ganeti/HTools/Types.hs @@ -32,6 +32,8 @@ module Ganeti.HTools.Types , FailMode(..) , FailStats , OpResult(..) + , connTimeout + , queryTimeout ) where -- | The instance index type. @@ -43,6 +45,14 @@ type Ndx = Int -- | The type used to hold name-to-idx mappings. type NameAssoc = [(String, Int)] +-- | Connection timeout (when using non-file methods). +connTimeout :: Int +connTimeout = 15 + +-- | The default timeout for queries (when using non-file methods). +queryTimeout :: Int +queryTimeout = 60 + {-| This is similar to the JSON library Result type - *very* similar, but