Improve mon-collector drbd CLI handling
[ganeti-local] / htools / Ganeti / Luxi.hs
index a59bd9b..9e5b337 100644 (file)
@@ -55,7 +55,9 @@ module Ganeti.Luxi
 import Control.Exception (catch)
 import Data.IORef
 import qualified Data.ByteString as B
+import qualified Data.ByteString.Lazy as BL
 import qualified Data.ByteString.UTF8 as UTF8
+import qualified Data.ByteString.Lazy.UTF8 as UTF8L
 import Data.Word (Word8)
 import Control.Monad
 import Text.JSON (encodeStrict, decodeStrict)
@@ -72,7 +74,6 @@ import Ganeti.BasicTypes
 import Ganeti.Constants
 import Ganeti.Errors
 import Ganeti.JSON
-import Ganeti.Jobs (JobStatus)
 import Ganeti.OpParams (pTagsObject)
 import Ganeti.OpCodes
 import qualified Ganeti.Query.Language as Qlang
@@ -246,9 +247,9 @@ closeClient = hClose . socket
 -- | Sends a message over a luxi transport.
 sendMsg :: Client -> String -> IO ()
 sendMsg s buf = withTimeout luxiDefRwto "sending luxi message" $ do
-  let encoded = UTF8.fromString buf
+  let encoded = UTF8L.fromString buf
       handle = socket s
-  B.hPut handle encoded
+  BL.hPut handle encoded
   B.hPut handle bEOM
   hFlush handle
 
@@ -325,8 +326,10 @@ decodeCall (LuxiCall call args) =
   case call of
     ReqQueryJobs -> do
               (jids, jargs) <- fromJVal args
-              let rargs = map fromJSString jargs
-              return $ QueryJobs jids rargs
+              jids' <- case jids of
+                         JSNull -> return []
+                         _ -> fromJVal jids
+              return $ QueryJobs jids' jargs
     ReqQueryInstances -> do
               (names, fields, locking) <- fromJVal args
               return $ QueryInstances names fields locking