Fix parsing of absolute job dependencies
[ganeti-local] / htools / Ganeti / Rpc.hs
index 7654a15..4ab9d7e 100644 (file)
@@ -59,7 +59,6 @@ module Ganeti.Rpc
   , RpcCallVersion(..)
   , RpcResultVersion(..)
 
-  , StorageType(..)
   , StorageField(..)
   , RpcCallStorageList(..)
   , RpcResultStorageList(..)
@@ -73,7 +72,6 @@ module Ganeti.Rpc
 import Control.Arrow (second)
 import qualified Text.JSON as J
 import Text.JSON.Pretty (pp_value)
-import Text.JSON (makeObj)
 
 #ifndef NO_CURL
 import Network.Curl
@@ -83,8 +81,8 @@ import qualified Ganeti.Path as P
 import qualified Ganeti.Constants as C
 import Ganeti.Objects
 import Ganeti.THH
+import Ganeti.Types
 import Ganeti.Compat
-import Ganeti.JSON
 
 -- * Base RPC functionality and types
 
@@ -92,13 +90,10 @@ import Ganeti.JSON
 -- | The curl options used for RPC.
 curlOpts :: [CurlOption]
 curlOpts = [ CurlFollowLocation False
-           , CurlCAInfo P.nodedCertFile
            , CurlSSLVerifyHost 0
            , CurlSSLVerifyPeer True
            , CurlSSLCertType "PEM"
-           , CurlSSLCert P.nodedCertFile
            , CurlSSLKeyType "PEM"
-           , CurlSSLKey P.nodedCertFile
            , CurlConnectTimeout (fromIntegral C.rpcConnectTimeout)
            ]
 #endif
@@ -171,8 +166,12 @@ executeHttpRequest _ (Left rpc_err) = return $ Left rpc_err
 executeHttpRequest _ _ = return $ Left CurlDisabledError
 #else
 executeHttpRequest node (Right request) = do
+  cert_file <- P.nodedCertFile
   let reqOpts = [ CurlTimeout (fromIntegral $ requestTimeout request)
                 , CurlPostFields [requestPostData request]
+                , CurlSSLCert cert_file
+                , CurlSSLKey cert_file
+                , CurlCAInfo cert_file
                 ]
       url = requestUrl request
   -- FIXME: This is very similar to getUrl in Htools/Rapi.hs
@@ -387,7 +386,7 @@ instance Rpc RpcCallNodeInfo RpcResultNodeInfo where
 -- Query node version.
 -- Note: We can't use THH as it does not know what to do with empty dict
 data RpcCallVersion = RpcCallVersion {}
-  deriving (Show, Read, Eq)
+  deriving (Show, Eq)
 
 instance J.JSON RpcCallVersion where
   showJSON _ = J.JSNull
@@ -410,14 +409,6 @@ instance Rpc RpcCallVersion RpcResultVersion where
 -- ** StorageList
 
 -- | StorageList
--- Get list of storage units.
--- FIXME: This may be moved to Objects
-$(declareSADT "StorageType"
-  [ ( "STLvmPv", 'C.stLvmPv )
-  , ( "STFile",  'C.stFile )
-  , ( "STLvmVg", 'C.stLvmVg )
-  ])
-$(makeJSONInstance ''StorageType)
 
 -- FIXME: This may be moved to Objects
 $(declareSADT "StorageField"