Signed-off-by: Dato Simó <[email protected]>
---
 Makefile.am                        |  3 +-
 src/Ganeti/HTools/Program/Harep.hs | 61 ++++++++++++++++++++++++++++++++++++++
 src/Ganeti/HTools/Program/Main.hs  |  4 +++
 3 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100644 src/Ganeti/HTools/Program/Harep.hs

diff --git a/Makefile.am b/Makefile.am
index 792c526..fd29892 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -436,7 +436,7 @@ HS_COMPILE_PROGS= \
 # All Haskell non-test programs to be compiled but not automatically installed
 HS_PROGS = $(HS_BIN_PROGS) $(HS_MYEXECLIB_PROGS)
 
-HS_BIN_ROLES = hbal hscan hspace hinfo hcheck hroller
+HS_BIN_ROLES = harep hbal hscan hspace hinfo hcheck hroller
 HS_HTOOLS_PROGS = $(HS_BIN_ROLES) hail
 
 HS_ALL_PROGS = \
@@ -505,6 +505,7 @@ HS_LIB_SRCS = \
        src/Ganeti/HTools/Node.hs \
        src/Ganeti/HTools/PeerMap.hs \
        src/Ganeti/HTools/Program/Hail.hs \
+       src/Ganeti/HTools/Program/Harep.hs \
        src/Ganeti/HTools/Program/Hbal.hs \
        src/Ganeti/HTools/Program/Hcheck.hs \
        src/Ganeti/HTools/Program/Hinfo.hs \
diff --git a/src/Ganeti/HTools/Program/Harep.hs 
b/src/Ganeti/HTools/Program/Harep.hs
new file mode 100644
index 0000000..d8274bc
--- /dev/null
+++ b/src/Ganeti/HTools/Program/Harep.hs
@@ -0,0 +1,61 @@
+{-| Auto-repair tool for Ganeti.
+
+-}
+
+{-
+
+Copyright (C) 2013 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.Harep
+  (main
+  , arguments
+  , options) where
+
+import Control.Monad
+import Data.Maybe
+
+import Ganeti.Common
+import Ganeti.Utils
+
+import Ganeti.HTools.CLI
+
+-- | Options list and functions.
+options :: IO [OptType]
+options = do
+  luxi <- oLuxiSocket
+  return
+    [ luxi
+    ]
+
+arguments :: [ArgCompletion]
+arguments = []
+
+-- | Main function.
+main :: Options -> [String] -> IO ()
+main opts args = do
+  unless (null args) $
+    exitErr "this program doesn't take any arguments."
+
+  let lsock = optLuxi opts
+
+  when (isNothing lsock) $
+    exitErr "Luxi socket (-L) required to execute jobs."
+
+  return ()
diff --git a/src/Ganeti/HTools/Program/Main.hs 
b/src/Ganeti/HTools/Program/Main.hs
index c36e4cf..499c6e4 100644
--- a/src/Ganeti/HTools/Program/Main.hs
+++ b/src/Ganeti/HTools/Program/Main.hs
@@ -38,6 +38,7 @@ import System.IO.Error (isDoesNotExistError)
 import Ganeti.Common (formatCommands, PersonalityList)
 import Ganeti.HTools.CLI (Options, parseOpts, genericOpts)
 import qualified Ganeti.HTools.Program.Hail as Hail
+import qualified Ganeti.HTools.Program.Harep as Harep
 import qualified Ganeti.HTools.Program.Hbal as Hbal
 import qualified Ganeti.HTools.Program.Hcheck as Hcheck
 import qualified Ganeti.HTools.Program.Hscan as Hscan
@@ -53,6 +54,9 @@ personalities =
                  "Ganeti IAllocator plugin that implements the instance\
                  \ placement and movement using the same algorithm as\
                  \ hbal(1)"))
+  , ("harep",   (Harep.main,   Harep.options,   Harep.arguments,
+                 "auto-repair tool that detects certain kind of problems\
+                 \ with instances and applies the allowed set of solutions"))
   , ("hbal",    (Hbal.main,    Hbal.options,    Hbal.arguments,
                  "cluster balancer that looks at the current state of\
                  \ the cluster and computes a series of steps designed\
-- 
1.8.0.2-x20-1

Reply via email to