commit 458a286a97f9def5b6d7f0d34d6730860226ac66
Author: Iustin Pop <iustin@google.com>
Date:   Fri Jul 8 11:33:52 2011 +0200

    htools: switch hail to the generic binary
    
    This converts the first binary to the generic 'htools' binary.
    
    Signed-off-by: Iustin Pop <iustin@google.com>
    Reviewed-by: Guido Trotter <ultrotter@google.com>

diff --git a/.gitignore b/.gitignore
index cc6be7f..a2ef1c0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -100,7 +100,6 @@
 
 /htools/hbal
 /htools/hscan
-/htools/hail
 /htools/hspace
 /htools/htools
 /htools/test
diff --git a/Makefile.am b/Makefile.am
index 3e23032..9c7a33a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -46,7 +46,8 @@ docdir = $(datadir)/doc/$(PACKAGE)
 HTOOLS_DIRS = \
 	htools \
 	htools/Ganeti \
-	htools/Ganeti/HTools
+	htools/Ganeti/HTools \
+	htools/Ganeti/HTools/Program
 
 DIRS = \
 	autotools \
@@ -82,6 +83,7 @@ BUILDTIME_DIR_AUTOCREATE = \
 	$(APIDOC_PY_DIR) \
 	$(APIDOC_HS_DIR) \
 	$(APIDOC_HS_DIR)/Ganeti $(APIDOC_HS_DIR)/Ganeti/HTools \
+	$(APIDOC_HS_DIR)/Ganeti/HTools/Program \
 	$(COVERAGE_DIR) \
 	$(COVERAGE_PY_DIR) \
 	$(COVERAGE_HS_DIR) \
@@ -307,7 +309,6 @@ docrst = \
 HS_PROGS = \
 	htools/hbal \
 	htools/hscan \
-	htools/hail \
 	htools/hspace \
 	htools/htools
 
@@ -341,6 +342,7 @@ HS_LIB_SRCS = \
 	htools/Ganeti/HTools/Text.hs \
 	htools/Ganeti/HTools/Types.hs \
 	htools/Ganeti/HTools/Utils.hs \
+	htools/Ganeti/HTools/Program/Hail.hs \
 	htools/Ganeti/Jobs.hs \
 	htools/Ganeti/Luxi.hs \
 	htools/Ganeti/OpCodes.hs
@@ -447,10 +449,12 @@ qa_scripts = \
 	qa/qa_utils.py
 
 bin_SCRIPTS =
-iallocators_SCRIPTS =
 if WANT_HTOOLS
 bin_SCRIPTS += $(filter-out htools/hail,$(HS_PROGS))
-iallocators_SCRIPTS += $(filter htools/hail,$(HS_PROGS))
+install-exec-hook:
+	@mkdir_p@ $(DESTDIR)$(iallocatorsdir)
+	$(LN_S) -f $(DESTDIR)$(bindir)/htools \
+		   $(DESTDIR)$(iallocatorsdir)/hail
 endif
 
 $(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
@@ -1108,7 +1112,7 @@ hs-apidoc: $(HS_BUILT_SRCS)
 	@test -n "$(HADDOCK)" || \
 	    { echo 'haddock' not found during configure; exit 1; }
 	rm -rf $(APIDOC_HS_DIR)/*
-	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools
+	@mkdir_p@ $(APIDOC_HS_DIR)/Ganeti/HTools/Program
 	$(HSCOLOUR) -print-css > $(APIDOC_HS_DIR)/Ganeti/hscolour.css
 	ln -s ../hscolour.css $(APIDOC_HS_DIR)/Ganeti/HTools/hscolour.css
 	set -e ; \
diff --git a/htools/Ganeti/HTools/Program/Hail.hs b/htools/Ganeti/HTools/Program/Hail.hs
new file mode 100644
index 0000000..ad7c775
--- /dev/null
+++ b/htools/Ganeti/HTools/Program/Hail.hs
@@ -0,0 +1,83 @@
+{-| IAllocator plugin for Ganeti.
+
+-}
+
+{-
+
+Copyright (C) 2009, 2010, 2011 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.
+
+-}
+
+module Ganeti.HTools.Program.Hail (main) where
+
+import Control.Monad
+import System.IO
+import qualified System
+
+import qualified Ganeti.HTools.Cluster as Cluster
+
+import Ganeti.HTools.CLI
+import Ganeti.HTools.IAlloc
+import Ganeti.HTools.Loader (Request(..), ClusterData(..))
+import Ganeti.HTools.ExtLoader (maybeSaveData)
+
+-- | Options list and functions
+options :: [OptType]
+options =
+    [ oPrintNodes
+    , oSaveCluster
+    , oDataFile
+    , oNodeSim
+    , oVerbose
+    , oShowVer
+    , oShowHelp
+    ]
+
+-- | Main function.
+main :: IO ()
+main = do
+  cmd_args <- System.getArgs
+  (opts, args) <- parseOpts cmd_args "hail" options
+
+  let shownodes = optShowNodes opts
+      verbose = optVerbose opts
+      savecluster = optSaveCluster 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
+
+  maybePrintNodes shownodes "Initial cluster"
+       (Cluster.printNodes (cdNodes cdata))
+
+  maybeSaveData savecluster "pre-ialloc" "before iallocator run" cdata
+
+  let (maybe_ni, resp) = runIAllocator request
+      (fin_nl, fin_il) = maybe (cdNodes cdata, cdInstances cdata) id maybe_ni
+  putStrLn resp
+
+  maybePrintNodes shownodes "Final cluster" (Cluster.printNodes fin_nl)
+
+  maybeSaveData savecluster "post-ialloc" "after iallocator run"
+       (cdata { cdNodes = fin_nl, cdInstances = fin_il})
diff --git a/htools/hail.hs b/htools/hail.hs
deleted file mode 100644
index 089e233..0000000
--- a/htools/hail.hs
+++ /dev/null
@@ -1,83 +0,0 @@
-{-| IAllocator plugin for Ganeti.
-
--}
-
-{-
-
-Copyright (C) 2009, 2010, 2011 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.
-
--}
-
-module Main (main) where
-
-import Control.Monad
-import System.IO
-import qualified System
-
-import qualified Ganeti.HTools.Cluster as Cluster
-
-import Ganeti.HTools.CLI
-import Ganeti.HTools.IAlloc
-import Ganeti.HTools.Loader (Request(..), ClusterData(..))
-import Ganeti.HTools.ExtLoader (maybeSaveData)
-
--- | Options list and functions
-options :: [OptType]
-options =
-    [ oPrintNodes
-    , oSaveCluster
-    , oDataFile
-    , oNodeSim
-    , oVerbose
-    , oShowVer
-    , oShowHelp
-    ]
-
--- | Main function.
-main :: IO ()
-main = do
-  cmd_args <- System.getArgs
-  (opts, args) <- parseOpts cmd_args "hail" options
-
-  let shownodes = optShowNodes opts
-      verbose = optVerbose opts
-      savecluster = optSaveCluster 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
-
-  maybePrintNodes shownodes "Initial cluster"
-       (Cluster.printNodes (cdNodes cdata))
-
-  maybeSaveData savecluster "pre-ialloc" "before iallocator run" cdata
-
-  let (maybe_ni, resp) = runIAllocator request
-      (fin_nl, fin_il) = maybe (cdNodes cdata, cdInstances cdata) id maybe_ni
-  putStrLn resp
-
-  maybePrintNodes shownodes "Final cluster" (Cluster.printNodes fin_nl)
-
-  maybeSaveData savecluster "post-ialloc" "after iallocator run"
-       (cdata { cdNodes = fin_nl, cdInstances = fin_il})
diff --git a/htools/htools.hs b/htools/htools.hs
index bd3803d..527e409 100644
--- a/htools/htools.hs
+++ b/htools/htools.hs
@@ -30,10 +30,12 @@ import System
 import System.IO
 
 import Ganeti.HTools.Utils
+import qualified Ganeti.HTools.Program.Hail as Hail
 
 -- | Supported binaries.
 personalities :: [(String, IO ())]
-personalities = []
+personalities = [ ("hail", Hail.main)
+                ]
 
 -- | Display usage and exit.
 usage :: String -> IO ()
