Hi! On Tue, Oct 7, 2014 at 4:52 PM, 'Klaus Aehlig' via ganeti-devel < ganeti-devel@googlegroups.com> wrote:
> ....to avoid having magic names spread all over htools. > > Signed-off-by: Klaus Aehlig <aeh...@google.com> > --- > src/Ganeti/HTools/Program/Hsqueeze.hs | 15 ++++----------- > src/Ganeti/HTools/Tags.hs | 21 +++++++++++++++++++++ > 2 files changed, 25 insertions(+), 11 deletions(-) > > diff --git a/src/Ganeti/HTools/Program/Hsqueeze.hs > b/src/Ganeti/HTools/Program/Hsqueeze.hs > index 4275370..3fd8816 100644 > --- a/src/Ganeti/HTools/Program/Hsqueeze.hs > +++ b/src/Ganeti/HTools/Program/Hsqueeze.hs > @@ -57,6 +57,7 @@ import Ganeti.HTools.ExtLoader > import qualified Ganeti.HTools.Instance as Instance > import Ganeti.HTools.Loader > import qualified Ganeti.HTools.Node as Node > +import Ganeti.HTools.Tags (hasStandbyTag, standbyAuto) > import Ganeti.HTools.Types > import Ganeti.JQueue (currentTimestamp, reasonTrailTimestamp) > import Ganeti.JQueue.Objects (Timestamp) > @@ -99,15 +100,6 @@ annotateOpCode ts comment = > . setOpComment (comment ++ " " ++ version) > . wrapOpCode > > --- | The tag-prefix indicating that hsqueeze should consider a node > --- as being standby. > -standbyPrefix :: String > -standbyPrefix = "htools:standby:" > - > --- | Predicate of having a standby tag. > -hasStandbyTag :: Node.Node -> Bool > -hasStandbyTag = any (standbyPrefix `isPrefixOf`) . Node.nTags > - > -- | Within a cluster configuration, decide if the node hosts only > -- externally-mirrored instances. > onlyExternal :: (Node.List, Instance.List) -> Node.Node -> Bool > @@ -243,7 +235,7 @@ getMoveOpCodes nl il js = return $ zip (map opcodes > js) (map descr js) > getTagOpCodes :: [Node.Node] -> Result [([[OpCode]], String)] > getTagOpCodes nl = return $ zip (map opCode nl) (map descr nl) > where > - opCode node = [[Node.genAddTagsOpCode node ["htools:standby:auto"]]] > + opCode node = [[Node.genAddTagsOpCode node [standbyAuto]]] > descr node = "Tagging node " ++ Node.name node ++ " with standby" > > -- | Get opcodes for powering off nodes > @@ -319,7 +311,8 @@ main opts args = do > off_cmd = > Cluster.formatCmds off_jobs > ++ "\necho Tagging Commands\n" > - ++ (toOffline >>= printf " gnt-node add-tags %s > htools:standby:auto\n" > + ++ (toOffline >>= (printf " gnt-node add-tags %s %s\n" > + `flip` standbyAuto) > . Node.alias) > ++ "\necho Power Commands\n" > ++ (toOffline >>= printf " gnt-node power -f off %s\n" . > Node.alias) > diff --git a/src/Ganeti/HTools/Tags.hs b/src/Ganeti/HTools/Tags.hs > index b9b252d..263ba73 100644 > --- a/src/Ganeti/HTools/Tags.hs > +++ b/src/Ganeti/HTools/Tags.hs > @@ -36,11 +36,32 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > DAMAGE. > > module Ganeti.HTools.Tags > ( exTagsPrefix > + , standbyAuto > + , hasStandbyTag > ) where > > +import Data.List (isPrefixOf) > + > +import qualified Ganeti.HTools.Node as Node > + > -- * Constants > > -- | The exclusion tag prefix. > exTagsPrefix :: String > exTagsPrefix = "htools:iextags:" > > +-- | The tag-prefix indicating that hsqueeze should consider a node > +-- as being standby. > +standbyPrefix :: String > +standbyPrefix = "htools:standby:" > + > +-- | The tag to be added to nodes that were shutdown by hsqueeze. > +standbyAuto :: String > +standbyAuto = "htools:standby:auto" > + > +-- * Predicates > + > +-- | Predicate of having a standby tag. > +hasStandbyTag :: Node.Node -> Bool > +hasStandbyTag = any (standbyPrefix `isPrefixOf`) . Node.nTags > + > -- > 2.1.0.rc2.206.gedb03e5 > > LGTM, thanks -- Helga Velroyen | Software Engineer | hel...@google.com | Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores