-- | Command line options structure.
data Options = Options
- { optShowNodes :: Bool -- ^ Whether to show node status
+ { optShowNodes :: Maybe [String] -- ^ Whether to show node status
, optShowInsts :: Bool -- ^ Whether to show the instance map
, optShowCmds :: Maybe FilePath -- ^ Whether to show the command list
, optOneline :: Bool -- ^ Switch output to a single line
-- | Default values for the command line options.
defaultOptions :: Options
defaultOptions = Options
- { optShowNodes = False
+ { optShowNodes = Nothing
, optShowInsts = False
, optShowCmds = Nothing
, optOneline = False
oPrintNodes :: OptType
oPrintNodes = Option "p" ["print-nodes"]
- (NoArg (\ opts -> Ok opts { optShowNodes = True }))
+ (OptArg ((\ f opts ->
+ let splitted = sepSplit ',' f
+ in Ok opts { optShowNodes = Just splitted }) .
+ fromMaybe []) "FIELDS")
"print the final node list"
oPrintInsts :: OptType
unzip $ zipWith (printSolutionLine nl il nmlen imlen) sol [1..]
-- | Print the node list.
-printNodes :: Node.List -> String
-printNodes nl =
- let snl = sortBy (compare `on` Node.idx) (Container.elems nl)
- (header, isnum) = unzip $ map Node.showHeader Node.defaultFields
+printNodes :: Node.List -> [String] -> String
+printNodes nl fs =
+ let fields = if null fs
+ then Node.defaultFields
+ else fs
+ snl = sortBy (compare `on` Node.idx) (Container.elems nl)
+ (header, isnum) = unzip $ map Node.showHeader fields
in unlines . map ((:) ' ' . intercalate " ") $
- formatTable (header:map (Node.list Node.defaultFields) snl) isnum
+ formatTable (header:map (Node.list fields) snl) isnum
-- | Print the instance list.
printInsts :: Node.List -> Instance.List -> String
.TP
Reporting options:
.BI "[ -C[" file "] ]"
-.B "[ -p ]"
+.BI "[ -p[" fields "] ]"
.B "[ --print-instances ]"
.B "[ -o ]"
.B "[ -v... | -q ]"
Prints the before and after node status, in a format designed to allow
the user to understand the node's most important parameters.
-The node list will contain these informations:
+It is possible to customise the listed information by passing a
+comma-separated list of field names to this option (the field list is
+currently undocumented). By default, the node list will contain these
+informations:
.RS
.TP
.B F
let oneline = optOneline opts
verbose = optVerbose opts
+ shownodes = optShowNodes opts
(fixed_nl, il, csf) <- loadExternalData opts
putStrLn "Initial instance map:"
putStrLn $ Cluster.printInsts nl il
- when (optShowNodes opts) $
+ when (isJust shownodes) $
do
putStrLn "Initial cluster status:"
- putStrLn $ Cluster.printNodes nl
+ putStrLn $ Cluster.printNodes nl (fromJust shownodes)
let ini_cv = Cluster.compCV nl
ini_tbl = Cluster.Table nl il ini_cv []
putStrLn "Final instance map:"
putStr $ Cluster.printInsts fin_nl fin_il
- when (optShowNodes opts) $
+ when (isJust shownodes) $
do
let ini_cs = Cluster.totalResources nl
fin_cs = Cluster.totalResources fin_nl
putStrLn ""
putStrLn "Final cluster status:"
- putStrLn $ Cluster.printNodes fin_nl
+ putStrLn $ Cluster.printNodes fin_nl (fromJust shownodes)
when (verbose > 3) $
do
printf "Original: mem=%d disk=%d\n"
import Data.List
import Data.Function
+import Data.Maybe (isJust, fromJust)
import Monad
import System
import System.IO
let odir = optOutPath opts
nlen = maximum . map length $ clusters
+ shownodes = optShowNodes opts
unless (optNoHeaders opts) $
printf "%-*s %5s %5s %5s %5s %6s %6s %6s %6s %10s\n" nlen
let (nl, il, csf) = x
(_, fix_nl) = Loader.checkData nl il
putStrLn $ printCluster fix_nl il
- when (optShowNodes opts) $
- putStr $ Cluster.printNodes fix_nl
+ when (isJust shownodes) $
+ putStr $ Cluster.printNodes fix_nl (fromJust shownodes)
let ndata = serializeNodes csf nl
idata = serializeInstances csf nl il
oname = odir </> fixSlash name
.B "[backend options...]"
.B "[algorithm options...]"
.B "[request options..."]
-.B "[-p]"
+.BI "[ -p[" fields "] ]"
.B "[-v... | -q]"
.B hspace
Prints the before and after node status, in a format designed to allow
the user to understand the node's most important parameters.
-The node list will contain these informations:
+It is possible to customise the listed information by passing a
+comma-separated list of field names to this option (the field list is
+currently undocumented). By default, the node list will contain these
+informations:
.RS
.TP
.B F
import Data.Char (toUpper)
import Data.List
import Data.Function
+import Data.Maybe (isJust, fromJust)
import Monad
import System
import System.IO
let verbose = optVerbose opts
ispec = optISpec opts
+ shownodes = optShowNodes opts
(fixed_nl, il, csf) <- loadExternalData opts
when (length csf > 0 && verbose > 1) $
hPrintf stderr "Note: Stripping common suffix of '%s' from names\n" csf
- when (optShowNodes opts) $
+ when (isJust shownodes) $
do
hPutStrLn stderr "Initial cluster status:"
- hPutStrLn stderr $ Cluster.printNodes nl
+ hPutStrLn stderr $ Cluster.printNodes nl (fromJust shownodes)
let ini_cv = Cluster.compCV nl
ini_stats = Cluster.totalResources nl
formatTable (map (printInstance trl_nl) fin_trl_ixes)
[False, False, False, True, True, True]
- when (optShowNodes opts) $ do
+ when (isJust shownodes) $ do
hPutStrLn stderr ""
hPutStrLn stderr "Tiered allocation status:"
- hPutStrLn stderr $ Cluster.printNodes trl_nl
+ hPutStrLn stderr $ Cluster.printNodes trl_nl (fromJust shownodes)
printKeys $ printStats PTiered (Cluster.totalResources trl_nl)
printKeys [("TSPEC", intercalate " " spec_map')])
hPutStr stderr . unlines . map ((:) ' ' . intercalate " ") $
formatTable (map (printInstance fin_nl) fin_ixes)
[False, False, False, True, True, True]
- when (optShowNodes opts) $
+ when (isJust shownodes) $
do
hPutStrLn stderr ""
hPutStrLn stderr "Final cluster status:"
- hPutStrLn stderr $ Cluster.printNodes fin_nl
+ hPutStrLn stderr $ Cluster.printNodes fin_nl (fromJust shownodes)
printResults fin_nl num_instances allocs sreason