Commit 22e513e7 authored by Agata Murawska's avatar Agata Murawska

Initial commit for introducting hcheck tool

Introduce infrastructure required to add Hcheck and build it
successfuly.
Signed-off-by: default avatarAgata Murawska <agatamurawska@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 720ec33e
......@@ -356,7 +356,7 @@ docrst = \
doc/walkthrough.rst
HS_PROGS = htools/htools
HS_BIN_ROLES = hbal hscan hspace hinfo
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck
HS_ALL_PROGS = $(HS_PROGS) htools/test htools/hpc-htools htools/hconfd
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
......@@ -399,6 +399,7 @@ HS_LIB_SRCS = \
htools/Ganeti/HTools/Program.hs \
htools/Ganeti/HTools/Program/Hail.hs \
htools/Ganeti/HTools/Program/Hbal.hs \
htools/Ganeti/HTools/Program/Hcheck.hs \
htools/Ganeti/HTools/Program/Hinfo.hs \
htools/Ganeti/HTools/Program/Hscan.hs \
htools/Ganeti/HTools/Program/Hspace.hs \
......@@ -692,6 +693,7 @@ man_MANS = \
man/gnt-os.8 \
man/hail.1 \
man/hbal.1 \
man/hcheck.1 \
man/hinfo.1 \
man/hscan.1 \
man/hspace.1 \
......
......@@ -62,6 +62,7 @@ module Ganeti.HTools.CLI
, oMinGainLim
, oMinScore
, oNoHeaders
, oNoSimulation
, oNodeSim
, oOfflineNode
, oOutputDir
......@@ -133,6 +134,7 @@ data Options = Options
, optMinGainLim :: Score -- ^ Limit below which we apply mingain
, optMinScore :: Score -- ^ The minimum score we aim for
, optNoHeaders :: Bool -- ^ Do not show a header line
, optNoSimulation :: Bool -- ^ Skip the rebalancing dry-run
, optNodeSim :: [String] -- ^ Cluster simulation mode
, optOffline :: [String] -- ^ Names of offline nodes
, optOutPath :: FilePath -- ^ Path to the output directory
......@@ -175,6 +177,7 @@ defaultOptions = Options
, optMinGainLim = 1e-1
, optMinScore = 1e-9
, optNoHeaders = False
, optNoSimulation = False
, optNodeSim = []
, optOffline = []
, optOutPath = "."
......@@ -349,6 +352,11 @@ oNoHeaders = Option "" ["no-headers"]
(NoArg (\ opts -> Ok opts { optNoHeaders = True }))
"do not show a header line"
oNoSimulation :: OptType
oNoSimulation = Option "" ["no-simulation"]
(NoArg (\opts -> Ok opts {optNoSimulation = True}))
"do not perform rebalancing simulation"
oNodeSim :: OptType
oNodeSim = Option "" ["simulate"]
(ReqArg (\ f o -> Ok o { optNodeSim = f:optNodeSim o }) "SPEC")
......
......@@ -31,6 +31,7 @@ import Ganeti.HTools.CLI (OptType, Options)
import qualified Ganeti.HTools.Program.Hail as Hail
import qualified Ganeti.HTools.Program.Hbal as Hbal
import qualified Ganeti.HTools.Program.Hcheck as Hcheck
import qualified Ganeti.HTools.Program.Hscan as Hscan
import qualified Ganeti.HTools.Program.Hspace as Hspace
import qualified Ganeti.HTools.Program.Hinfo as Hinfo
......@@ -39,6 +40,7 @@ import qualified Ganeti.HTools.Program.Hinfo as Hinfo
personalities :: [(String, (Options -> [String] -> IO (), [OptType]))]
personalities = [ ("hail", (Hail.main, Hail.options))
, ("hbal", (Hbal.main, Hbal.options))
, ("hcheck", (Hcheck.main, Hcheck.options))
, ("hscan", (Hscan.main, Hscan.options))
, ("hspace", (Hspace.main, Hspace.options))
, ("hinfo", (Hinfo.main, Hinfo.options))
......
{-| Cluster checker.
-}
{-
Copyright (C) 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 Gene52al 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.Hcheck (main, options) where
import Control.Monad
import System.Exit
import System.IO
import Ganeti.HTools.CLI
-- | Options list and functions.
options :: [OptType]
options =
[ oDataFile
, oDiskMoves
, oDynuFile
, oEvacMode
, oExInst
, oExTags
, oIAllocSrc
, oInstMoves
, oLuxiSocket
, oMachineReadable
, oMaxCpu
, oMaxSolLength
, oMinDisk
, oMinGain
, oMinGainLim
, oMinScore
, oNoSimulation
, oOfflineNode
, oQuiet
, oRapiMaster
, oSelInst
, oShowHelp
, oShowVer
, oVerbose
]
-- | Main function.
main :: Options -> [String] -> IO ()
main _ args = do
unless (null args) $ do
hPutStrLn stderr "Error: this program doesn't take any arguments."
exitWith $ ExitFailure 1
......@@ -43,4 +43,8 @@ hinfo() {
HTOOLS=hinfo $HBINARY "$@"
}
ALL_ROLES="hbal hscan hail hspace hinfo"
hcheck() {
HTOOLS=hinfo $HBINARY "$@"
}
ALL_ROLES="hbal hscan hail hspace hinfo hcheck"
HCHECK(1) Ganeti | Version @GANETI_VERSION@
===========================================
NAME
----
hcheck \- Cluster checker
SYNOPSIS
--------
**hcheck** {backend options...} [algorithm options...] [reporting options...]
**hcheck** \--version
Backend options:
{ **-m** *cluster* | **-L[** *path* **] | **-t** *data-file* |
**-I** *path* }
Algorithm options:
**[ \--no-simulation ]**
**[ \--max-cpu *cpu-ratio* ]**
**[ \--min-disk *disk-ratio* ]**
**[ -l *limit* ]**
**[ -e *score* ]**
**[ -g *delta* ]** **[ \--min-gain-limit *threshold* ]**
**[ -O *name...* ]**
**[ \--no-disk-moves ]**
**[ \--no-instance-moves ]**
**[ -U *util-file* ]**
**[ \--evac-mode ]**
**[ \--select-instances *inst...* ]**
**[ \--exclude-instances *inst...* ]**
Reporting options:
**[\--machine-readable**[=*CHOICE*] **]**
**[ -p[ *fields* ] ]**
**[ \--print-instances ]**
**[ -v... | -q ]**
DESCRIPTION
-----------
hcheck is the cluster checker. It prints information about cluster's
health and checks whether a rebalance done using **hbal** would help.
This information can be presented in both human-readable and
machine-readable way.
Note that it does not take any action, only performs a rebalance
simulation if necessary.
For more information about the algorithm details check **hbal(1)**.
OPTIONS
-------
\--no-simulation
Only perform checks based on current cluster state, without trying
to simulate rebalancing.
For a detailed description about the options listed above have a look at
**htools(7)**, **hspace(1)** and **hbal(1)**.
.. vim: set textwidth=72 :
.. Local Variables:
.. mode: rst
.. fill-column: 72
.. End:
......@@ -12,6 +12,9 @@ SYNOPSIS
**hbal**
cluster balancer
**hcheck**
cluster checker
**hspace**
cluster capacity computation
......@@ -35,6 +38,9 @@ environment variable HTOOLS can be used to set the desired role.
Installed as ``hbal``, it computes and optionally executes a suite of
instance moves in order to balance the cluster.
Installed as ``hcheck``, it preforms cluster checks and optionally
simulates rebalancing with all the ``hbal`` options available.
Installed as ``hspace``, it computes how many additional instances can
be fit on a cluster, while maintaining N+1 status. It can run on models
of existing clusters or of simulated clusters.
......
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