OK, my previous small fix was not good. There is another issue: haddoc
(the documentation generator) needs to pass the same compiler options
(i.e. in our case, -DNO_CURL) to ghc. But in case of no curl, then it
shouldn't scan at all the RAPI library, as that is not used in our
builds.
Clearly, this is not a nice thing. So this patch changes from
including/excluding RAPI conditionally (in two places, the
ExtLoader.hs module and in hscan.hs), to always include RAPI, and
moves the curl/no curl login to RAPI itself, where it belongs.
Together with passing --optghc to haddock, this makes the builds
consistent both with and without RAPI. I also undo the removal of RAPI
from QC.hs.
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
ln -s ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
set -e ; \
cd htools; \
ln -s ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
set -e ; \
cd htools; \
+ if [ "$(HTOOLS_NOCURL)" ]; \
+ then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
+ else OPTGHC=""; \
+ fi; \
RELSRCS="$(HS_LIB_SRCS:htools/%=%)"; \
for file in $$RELSRCS; do \
hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
RELSRCS="$(HS_LIB_SRCS:htools/%=%)"; \
for file in $$RELSRCS; do \
hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
-t ganeti-htools -p haddock-prologue \
--source-module="%{MODULE/.//}.html" \
--source-entity="%{MODULE/.//}.html#%{NAME}" \
-t ganeti-htools -p haddock-prologue \
--source-module="%{MODULE/.//}.html" \
--source-entity="%{MODULE/.//}.html#%{NAME}" \
$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
.PHONY: TAGS
$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
.PHONY: TAGS
{-| External data loader
This module holds the external data loading, and thus is the only one
{-| External data loader
This module holds the external data loading, and thus is the only one
-Copyright (C) 2009, 2010 Google Inc.
+Copyright (C) 2009, 2010, 2011 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
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
import Text.Printf (printf, hPrintf)
import qualified Ganeti.HTools.Luxi as Luxi
import Text.Printf (printf, hPrintf)
import qualified Ganeti.HTools.Luxi as Luxi
import qualified Ganeti.HTools.Rapi as Rapi
import qualified Ganeti.HTools.Rapi as Rapi
import qualified Ganeti.HTools.Simu as Simu
import qualified Ganeti.HTools.Text as Text
import Ganeti.HTools.Loader (mergeData, checkData, ClusterData(..)
import qualified Ganeti.HTools.Simu as Simu
import qualified Ganeti.HTools.Text as Text
import Ganeti.HTools.Loader (mergeData, checkData, ClusterData(..)
exitWith $ ExitFailure 1)
input_data <-
case () of
exitWith $ ExitFailure 1)
input_data <-
case () of
- _ | setRapi ->
-#ifdef NO_CURL
- return $ Bad "RAPI/curl backend disabled at compile time"
-#else
- wrapIO $ Rapi.loadData mhost
-#endif
+ _ | setRapi -> wrapIO $ Rapi.loadData mhost
| setLuxi -> wrapIO $ Luxi.loadData $ fromJust lsock
| setSim -> Simu.loadData simdata
| setFile -> wrapIO $ Text.loadData $ fromJust tfile
| setLuxi -> wrapIO $ Luxi.loadData $ fromJust lsock
| setSim -> Simu.loadData simdata
| setFile -> wrapIO $ Text.loadData $ fromJust tfile
import qualified Ganeti.HTools.Node as Node
import qualified Ganeti.HTools.Group as Group
import qualified Ganeti.HTools.PeerMap as PeerMap
import qualified Ganeti.HTools.Node as Node
import qualified Ganeti.HTools.Group as Group
import qualified Ganeti.HTools.PeerMap as PeerMap
+import qualified Ganeti.HTools.Rapi
import qualified Ganeti.HTools.Simu
import qualified Ganeti.HTools.Text as Text
import qualified Ganeti.HTools.Types as Types
import qualified Ganeti.HTools.Simu
import qualified Ganeti.HTools.Text as Text
import qualified Ganeti.HTools.Types as Types
-{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE BangPatterns, CPP #-}
module Ganeti.HTools.Rapi
(
module Ganeti.HTools.Rapi
(
) where
import Data.Maybe (fromMaybe)
) where
import Data.Maybe (fromMaybe)
import Network.Curl
import Network.Curl.Types ()
import Network.Curl
import Network.Curl.Types ()
import Control.Monad
import Text.JSON (JSObject, JSValue, fromJSObject, decodeStrict)
import Text.JSON.Types (JSValue(..))
import Control.Monad
import Text.JSON (JSObject, JSValue, fromJSObject, decodeStrict)
import Text.JSON.Types (JSValue(..))
import qualified Ganeti.HTools.Node as Node
import qualified Ganeti.HTools.Instance as Instance
import qualified Ganeti.HTools.Node as Node
import qualified Ganeti.HTools.Instance as Instance
+-- | Read an URL via curl and return the body if successful.
+getUrl :: (Monad m) => String -> IO (m String)
+
+#ifdef NO_CURL
+getUrl _ = return $ fail "RAPI/curl backend disabled at compile time"
+
+#else
+
-- | The curl options we use
curlOpts :: [CurlOption]
curlOpts = [ CurlSSLVerifyPeer False
-- | The curl options we use
curlOpts :: [CurlOption]
curlOpts = [ CurlSSLVerifyPeer False
, CurlConnectTimeout (fromIntegral connTimeout)
]
, CurlConnectTimeout (fromIntegral connTimeout)
]
--- | Read an URL via curl and return the body if successful.
-getUrl :: (Monad m) => String -> IO (m String)
getUrl url = do
(code, !body) <- curlGetString url curlOpts
return (case code of
CurlOK -> return body
_ -> fail $ printf "Curl error for '%s', error %s"
url (show code))
getUrl url = do
(code, !body) <- curlGetString url curlOpts
return (case code of
CurlOK -> return body
_ -> fail $ printf "Curl error for '%s', error %s"
url (show code))
-- | Append the default port if not passed in.
formatHost :: String -> String
-- | Append the default port if not passed in.
formatHost :: String -> String
{-| Scan clusters via RAPI or LUXI and write state data files.
-}
{-| Scan clusters via RAPI or LUXI and write state data files.
-}
import qualified Ganeti.HTools.Cluster as Cluster
import qualified Ganeti.HTools.Node as Node
import qualified Ganeti.HTools.Instance as Instance
import qualified Ganeti.HTools.Cluster as Cluster
import qualified Ganeti.HTools.Node as Node
import qualified Ganeti.HTools.Instance as Instance
import qualified Ganeti.HTools.Rapi as Rapi
import qualified Ganeti.HTools.Rapi as Rapi
import qualified Ganeti.HTools.Luxi as Luxi
import Ganeti.HTools.Loader (checkData, mergeData, ClusterData(..))
import Ganeti.HTools.Text (serializeCluster)
import qualified Ganeti.HTools.Luxi as Luxi
import Ganeti.HTools.Loader (checkData, mergeData, ClusterData(..))
import Ganeti.HTools.Text (serializeCluster)
result <- writeData nlen name opts input_data
unless result $ exitWith $ ExitFailure 2
result <- writeData nlen name opts input_data
unless result $ exitWith $ ExitFailure 2
results <- mapM (\name -> Rapi.loadData name >>= writeData nlen name opts)
clusters
unless (all id results) $ exitWith (ExitFailure 2)
results <- mapM (\name -> Rapi.loadData name >>= writeData nlen name opts)
clusters
unless (all id results) $ exitWith (ExitFailure 2)
-#else
- when (not $ null clusters) $ do
- putStrLn "RAPI/curl backend disabled at compile time, cannot scan clusters"
- exitWith $ ExitFailure 1
-#endif