From b790839a0ca0a74370432154f75b9af46bbb02c8 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 30 May 2011 10:43:50 +0200
Subject: [PATCH] hail: add option for displaying the parsed request

This can be used for debugging.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 htools/hail.hs | 8 ++++++++
 man/hail.rst   | 8 +++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/htools/hail.hs b/htools/hail.hs
index 646cdcf26..a497b4642 100644
--- a/htools/hail.hs
+++ b/htools/hail.hs
@@ -46,6 +46,7 @@ options =
     [ oPrintNodes
     , oDataFile
     , oNodeSim
+    , oVerbose
     , oShowVer
     , oShowHelp
     ]
@@ -103,11 +104,18 @@ main = do
   (opts, args) <- parseOpts cmd_args "hail" options
 
   let shownodes = optShowNodes opts
+      verbose = optVerbose opts
 
   request <- readRequest opts args
 
   let Request rq cdata = request
 
+  when (verbose > 1) $
+       hPutStrLn stderr $ "Received request: " ++ show rq
+
+  when (verbose > 2) $
+       hPutStrLn stderr $ "Received cluster data: " ++ show cdata
+
   when (isJust shownodes) $ do
          hPutStrLn stderr "Initial cluster status:"
          hPutStrLn stderr $ Cluster.printNodes (cdNodes cdata)
diff --git a/man/hail.rst b/man/hail.rst
index c4f7fb75c..33b2787e1 100644
--- a/man/hail.rst
+++ b/man/hail.rst
@@ -9,7 +9,7 @@ hail - Ganeti IAllocator plugin
 SYNOPSIS
 --------
 
-**hail** [ **-t** *datafile* | **--simulate** *spec* ] *input-file*
+**hail** [ **-t** *file* | **--simulate** *spec* ] [options...] *input-file*
 
 **hail** --version
 
@@ -68,6 +68,12 @@ The options that can be passed to the program are as follows:
   data with a simulated cluster. For details about the description,
   see the man page **hspace**(1).
 
+-v
+  This option increases verbosity and can be used for debugging in order
+  to understand how the IAllocator request is parsed; it can be passed
+  multiple times for successively more information.
+
+
 CONFIGURATION
 -------------
 
-- 
GitLab