From 2207220d953ae6a8b7b8bca00cbc1f95e69086d5 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig <aehlig@google.com> Date: Mon, 6 May 2013 15:51:20 +0200 Subject: [PATCH] Add option --one-step-only to hroller Add a new option to hroller to only output information about the first reboot group. Together with the option --node-tags this allows for the following work flow. First tag all nodes; then repeatedly compute the first node group, handle these nodes and remove the tags. In between these steps, other operations can be carried out on the cluster. Signed-off-by: Klaus Aehlig <aehlig@google.com> Reviewed-by: Thomas Thrainer <thomasth@google.com> --- man/hroller.rst | 4 ++++ src/Ganeti/HTools/CLI.hs | 10 ++++++++++ src/Ganeti/HTools/Program/Hroller.hs | 16 +++++++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/man/hroller.rst b/man/hroller.rst index b55a68727..1caaf7be8 100644 --- a/man/hroller.rst +++ b/man/hroller.rst @@ -33,6 +33,7 @@ Reporting options: **[ -v... | -q ]** **[ -S *file* ]** +**[ --one-step-only ]** DESCRIPTION ----------- @@ -65,6 +66,9 @@ For a description of the standard options check **htools**\(7) and \--node-tags *tag,...* Restrict to nodes having at least one of the given tags. +\--one-step-only + Restrict to the first reboot group. Output the group one node per line. + \--force Do not fail, even if the master node cannot be determined. diff --git a/src/Ganeti/HTools/CLI.hs b/src/Ganeti/HTools/CLI.hs index 80fa89f64..c0687233d 100644 --- a/src/Ganeti/HTools/CLI.hs +++ b/src/Ganeti/HTools/CLI.hs @@ -71,6 +71,7 @@ module Ganeti.HTools.CLI , oNodeSim , oNodeTags , oOfflineNode + , oOneStepOnly , oOutputDir , oPrintCommands , oPrintInsts @@ -138,6 +139,7 @@ data Options = Options , optNodeSim :: [String] -- ^ Cluster simulation mode , optNodeTags :: Maybe [String] -- ^ List of node tags to restrict to , optOffline :: [String] -- ^ Names of offline nodes + , optOneStepOnly :: Bool -- ^ Only do the first step , optOutPath :: FilePath -- ^ Path to the output directory , optSaveCluster :: Maybe FilePath -- ^ Save cluster state to this file , optShowCmds :: Maybe FilePath -- ^ Whether to show the command list @@ -186,6 +188,7 @@ defaultOptions = Options , optNodeSim = [] , optNodeTags = Nothing , optOffline = [] + , optOneStepOnly = False , optOutPath = "." , optSaveCluster = Nothing , optShowCmds = Nothing @@ -469,6 +472,13 @@ oOfflineNode = "set node as offline", OptComplOneNode) +oOneStepOnly :: OptType +oOneStepOnly = + (Option "" ["one-step-only"] + (NoArg (\ opts -> Ok opts {optOneStepOnly = True})) + "Only do the first step", + OptComplNone) + oOutputDir :: OptType oOutputDir = (Option "d" ["output-dir"] diff --git a/src/Ganeti/HTools/Program/Hroller.hs b/src/Ganeti/HTools/Program/Hroller.hs index 882bece8b..576ffb85f 100644 --- a/src/Ganeti/HTools/Program/Hroller.hs +++ b/src/Ganeti/HTools/Program/Hroller.hs @@ -65,6 +65,7 @@ options = do , oSaveCluster , oGroup , oForce + , oOneStepOnly ] -- | The list of arguments supported by the program. @@ -169,6 +170,15 @@ main opts args = do when (verbose > 1) . putStrLn $ getStats colorings - unless (optNoHeaders opts) $ - putStrLn "'Node Reboot Groups'" - mapM_ (putStrLn . commaJoin) outputRebootNames + if optOneStepOnly opts + then do + unless (optNoHeaders opts) $ + putStrLn "'First Reboot Group'" + case outputRebootNames of + [] -> return () + y : _ -> mapM_ putStrLn y + else do + unless (optNoHeaders opts) $ + putStrLn "'Node Reboot Groups'" + mapM_ (putStrLn . commaJoin) outputRebootNames + -- GitLab