Commit 19e21a6c authored by Iustin Pop's avatar Iustin Pop

Add a very simple test rpc program

This only supports test delay for now, is not built by default (only
on demand), and is also not installed anywhere.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent de2a5704
......@@ -113,6 +113,7 @@
/htools/htools
/htools/hconfd
/htools/ganeti-confd
/htools/rpc-test
/htest/hpc-htools
/htest/test
/htools/*.prof*
......
......@@ -386,7 +386,13 @@ HS_PROGS = htools/htools
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck
HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
HS_ALL_PROGS = $(HS_PROGS) htest/test htest/hpc-htools htools/hconfd
HS_ALL_PROGS = \
$(HS_PROGS) \
htest/hpc-htools \
htest/test \
htools/hconfd \
htools/rpc-test
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=htest/%) htest/hail
......
{-| RPC test program.
-}
{-
Copyright (C) 2011, 2012 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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
-}
import System.Environment
import System.Exit
import System.IO
import Ganeti.Config
import Ganeti.Objects
import qualified Ganeti.Path as P
import Ganeti.Rpc
import Ganeti.Utils
-- | Show usage info and exit.
usage :: IO ()
usage = do
prog <- getProgName
hPutStrLn stderr $ "Usage: " ++ prog ++ " delay node..."
exitWith $ ExitFailure 1
main :: IO ()
main = do
args <- getArgs
(delay, nodes) <- case args of
[] -> usage >> return ("", []) -- workaround types...
_:[] -> usage >> return ("", [])
x:xs -> return (x, xs)
cfg <- loadConfig P.clusterConfFile >>=
exitIfBad "Can't load configuration"
let call = RpcCallTestDelay (read delay)
nodes' <- exitIfBad "Can't find node" $ mapM (getNode cfg) nodes
results <- executeRpcCall nodes' call
putStr $ printTable "" ["Node", "Result"]
(map (\(n, r) -> [nodeName n, show r]) results) [False, False]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment