Revision c478f837

b/Makefile.am
1046 1046
	ln -s ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
1047 1047
	set -e ; \
1048 1048
	cd htools; \
1049
	if [ "$(HTOOLS_NOCURL)" ]; \
1050
	then OPTGHC="--optghc=$(HTOOLS_NOCURL)"; \
1051
	else OPTGHC=""; \
1052
	fi; \
1049 1053
	RELSRCS="$(HS_LIB_SRCS:htools/%=%)"; \
1050 1054
	for file in $$RELSRCS; do \
1051 1055
		hfile=`echo $$file|sed 's/\\.hs$$//'`.html; \
......
1055 1059
		-t ganeti-htools -p haddock-prologue \
1056 1060
		--source-module="%{MODULE/.//}.html" \
1057 1061
		--source-entity="%{MODULE/.//}.html#%{NAME}" \
1062
		$$OPTGHC \
1058 1063
		$(filter-out Ganeti/HTools/ExtLoader.hs,$(HS_LIB_SRCS:htools/%=%))
1059 1064

  
1060 1065
.PHONY: TAGS
b/htools/Ganeti/HTools/ExtLoader.hs
1
{-# LANGUAGE CPP #-}
2

  
3 1
{-| External data loader
4 2

  
5 3
This module holds the external data loading, and thus is the only one
......
10 8

  
11 9
{-
12 10

  
13
Copyright (C) 2009, 2010 Google Inc.
11
Copyright (C) 2009, 2010, 2011 Google Inc.
14 12

  
15 13
This program is free software; you can redistribute it and/or modify
16 14
it under the terms of the GNU General Public License as published by
......
43 41
import Text.Printf (printf, hPrintf)
44 42

  
45 43
import qualified Ganeti.HTools.Luxi as Luxi
46
#ifndef NO_CURL
47 44
import qualified Ganeti.HTools.Rapi as Rapi
48
#endif
49 45
import qualified Ganeti.HTools.Simu as Simu
50 46
import qualified Ganeti.HTools.Text as Text
51 47
import Ganeti.HTools.Loader (mergeData, checkData, ClusterData(..)
......
109 105
                     exitWith $ ExitFailure 1)
110 106
  input_data <-
111 107
      case () of
112
        _ | setRapi ->
113
#ifdef NO_CURL
114
              return $ Bad "RAPI/curl backend disabled at compile time"
115
#else
116
              wrapIO $ Rapi.loadData mhost
117
#endif
108
        _ | setRapi -> wrapIO $ Rapi.loadData mhost
118 109
          | setLuxi -> wrapIO $ Luxi.loadData $ fromJust lsock
119 110
          | setSim -> Simu.loadData simdata
120 111
          | setFile -> wrapIO $ Text.loadData $ fromJust tfile
b/htools/Ganeti/HTools/QC.hs
58 58
import qualified Ganeti.HTools.Node as Node
59 59
import qualified Ganeti.HTools.Group as Group
60 60
import qualified Ganeti.HTools.PeerMap as PeerMap
61
import qualified Ganeti.HTools.Rapi
61 62
import qualified Ganeti.HTools.Simu
62 63
import qualified Ganeti.HTools.Text as Text
63 64
import qualified Ganeti.HTools.Types as Types
b/htools/Ganeti/HTools/Rapi.hs
23 23

  
24 24
-}
25 25

  
26
{-# LANGUAGE BangPatterns #-}
26
{-# LANGUAGE BangPatterns, CPP #-}
27 27

  
28 28
module Ganeti.HTools.Rapi
29 29
    (
......
32 32
    ) where
33 33

  
34 34
import Data.Maybe (fromMaybe)
35
#ifndef NO_CURL
35 36
import Network.Curl
36 37
import Network.Curl.Types ()
38
#endif
37 39
import Control.Monad
38 40
import Text.JSON (JSObject, JSValue, fromJSObject, decodeStrict)
39 41
import Text.JSON.Types (JSValue(..))
......
46 48
import qualified Ganeti.HTools.Node as Node
47 49
import qualified Ganeti.HTools.Instance as Instance
48 50

  
51
-- | Read an URL via curl and return the body if successful.
52
getUrl :: (Monad m) => String -> IO (m String)
53

  
54
#ifdef NO_CURL
55
getUrl _ = return $ fail "RAPI/curl backend disabled at compile time"
56

  
57
#else
58

  
49 59
-- | The curl options we use
50 60
curlOpts :: [CurlOption]
51 61
curlOpts = [ CurlSSLVerifyPeer False
......
54 64
           , CurlConnectTimeout (fromIntegral connTimeout)
55 65
           ]
56 66

  
57
-- | Read an URL via curl and return the body if successful.
58
getUrl :: (Monad m) => String -> IO (m String)
59 67
getUrl url = do
60 68
  (code, !body) <- curlGetString url curlOpts
61 69
  return (case code of
62 70
            CurlOK -> return body
63 71
            _ -> fail $ printf "Curl error for '%s', error %s"
64 72
                 url (show code))
73
#endif
65 74

  
66 75
-- | Append the default port if not passed in.
67 76
formatHost :: String -> String
b/htools/hscan.hs
1
{-# LANGUAGE CPP #-}
2

  
3 1
{-| Scan clusters via RAPI or LUXI and write state data files.
4 2

  
5 3
-}
......
40 38
import qualified Ganeti.HTools.Cluster as Cluster
41 39
import qualified Ganeti.HTools.Node as Node
42 40
import qualified Ganeti.HTools.Instance as Instance
43
#ifndef NO_CURL
44 41
import qualified Ganeti.HTools.Rapi as Rapi
45
#endif
46 42
import qualified Ganeti.HTools.Luxi as Luxi
47 43
import Ganeti.HTools.Loader (checkData, mergeData, ClusterData(..))
48 44
import Ganeti.HTools.Text (serializeCluster)
......
155 151
         result <- writeData nlen name opts input_data
156 152
         unless result $ exitWith $ ExitFailure 2
157 153

  
158
#ifndef NO_CURL
159 154
  results <- mapM (\name -> Rapi.loadData name >>= writeData nlen name opts)
160 155
             clusters
161 156
  unless (all id results) $ exitWith (ExitFailure 2)
162
#else
163
  when (not $ null clusters) $ do
164
    putStrLn "RAPI/curl backend disabled at compile time, cannot scan clusters"
165
    exitWith $ ExitFailure 1
166
#endif

Also available in: Unified diff