**[ -O *name...* ]**
+**[ --node-tags** *tag,..* **]**
+
Reporting options:
**[ -v... | -q ]**
For a description of the standard options check **htools**\(7) and
**hbal**\(1).
+\--node-tags *tag,...*
+ Restrict to nodes having at least one of the given tags.
+
\--force
Do not fail, even if the master node cannot be determined.
, oNoHeaders
, oNoSimulation
, oNodeSim
+ , oNodeTags
, oOfflineNode
, oOutputDir
, oPrintCommands
, optNoHeaders :: Bool -- ^ Do not show a header line
, optNoSimulation :: Bool -- ^ Skip the rebalancing dry-run
, optNodeSim :: [String] -- ^ Cluster simulation mode
+ , optNodeTags :: Maybe [String] -- ^ List of node tags to restrict to
, optOffline :: [String] -- ^ Names of offline nodes
, optOutPath :: FilePath -- ^ Path to the output directory
, optSaveCluster :: Maybe FilePath -- ^ Save cluster state to this file
, optNoHeaders = False
, optNoSimulation = False
, optNodeSim = []
+ , optNodeTags = Nothing
, optOffline = []
, optOutPath = "."
, optSaveCluster = Nothing
\ 'alloc_policy,num_nodes,disk,ram,cpu'",
OptComplString)
+oNodeTags :: OptType
+oNodeTags =
+ (Option "" ["node-tags"]
+ (ReqArg (\ f opts -> Ok opts { optNodeTags = Just $ sepSplit ',' f })
+ "TAG,...") "Restrict to nodes with the given tags",
+ OptComplString)
+
oOfflineNode :: OptType
oOfflineNode =
(Option "O" ["offline"]
, oVerbose
, oQuiet
, oNoHeaders
+ , oNodeTags
, oSaveCluster
, oGroup
, oForce
hasGroup Nothing _ = True
hasGroup (Just grp) node = Node.group node == Group.idx grp
+-- | Predicate of having at least one tag in a given set.
+hasTag :: Maybe [String] -> Node.Node -> Bool
+hasTag Nothing _ = True
+hasTag (Just tags) node = not . null $ Node.nTags node `intersect` tags
+
-- | Put the master node last.
-- Reorder a list of lists of nodes such that the master node (if present)
-- is the last node of the last group.
Nothing -> exitErr "Cannot find target group."
Just grp -> return (Just grp)
- let nodes = IntMap.filter
- (liftA2 (&&) (not . Node.offline) (hasGroup wantedGroup))
+ let nodes = IntMap.filter (foldl (liftA2 (&&)) (const True)
+ [ (not . Node.offline)
+ , (hasTag $ optNodeTags opts)
+ , hasGroup wantedGroup ])
nlf
-- TODO: fail if instances are running (with option to warn only)