Revision 1ca709c1 src/Ganeti/HTools/Backend/Rapi.hs
b/src/Ganeti/HTools/Backend/Rapi.hs | ||
---|---|---|
33 | 33 |
import Control.Exception |
34 | 34 |
import Data.List (isPrefixOf) |
35 | 35 |
import Data.Maybe (fromMaybe) |
36 |
#ifndef NO_CURL |
|
37 | 36 |
import Network.Curl |
38 | 37 |
import Network.Curl.Types () |
39 |
#endif |
|
40 | 38 |
import Control.Monad |
41 | 39 |
import Text.JSON (JSObject, fromJSObject, decodeStrict) |
42 | 40 |
import Text.JSON.Types (JSValue(..)) |
... | ... | |
61 | 59 |
-- | Read an URL via curl and return the body if successful. |
62 | 60 |
getUrl :: (Monad m) => String -> IO (m String) |
63 | 61 |
|
64 |
#ifdef NO_CURL |
|
65 |
getUrl _ = return $ fail "RAPI/curl backend disabled at compile time" |
|
66 |
|
|
67 |
#else |
|
68 |
|
|
69 | 62 |
-- | Connection timeout (when using non-file methods). |
70 | 63 |
connTimeout :: Long |
71 | 64 |
connTimeout = 15 |
... | ... | |
88 | 81 |
CurlOK -> return body |
89 | 82 |
_ -> fail $ printf "Curl error for '%s', error %s" |
90 | 83 |
url (show code)) |
91 |
#endif |
|
92 | 84 |
|
93 | 85 |
-- | Helper to convert I/O errors in 'Bad' values. |
94 | 86 |
ioErrToResult :: IO a -> IO (Result a) |
Also available in: Unified diff