35 |
35 |
import qualified Ganeti.HTools.Container as Container
|
36 |
36 |
import qualified Ganeti.HTools.Cluster as Cluster
|
37 |
37 |
import qualified Ganeti.HTools.Node as Node
|
|
38 |
import qualified Ganeti.HTools.Group as Group
|
38 |
39 |
import qualified Ganeti.HTools.Instance as Instance
|
39 |
40 |
|
|
41 |
import Ganeti.HTools.Utils
|
40 |
42 |
import Ganeti.HTools.CLI
|
41 |
43 |
import Ganeti.HTools.ExtLoader
|
42 |
44 |
import Ganeti.HTools.Loader
|
... | ... | |
56 |
58 |
, oShowHelp
|
57 |
59 |
]
|
58 |
60 |
|
59 |
|
-- | Do a few checks on the cluster data.
|
60 |
|
checkCluster :: Int -> Node.List -> Instance.List -> IO ()
|
61 |
|
checkCluster verbose nl il = do
|
62 |
|
-- nothing to do on an empty cluster
|
63 |
|
when (Container.null il) $ do
|
64 |
|
printf "Cluster is empty, exiting.\n"::IO ()
|
65 |
|
exitWith ExitSuccess
|
66 |
|
|
67 |
|
-- hbal doesn't currently handle split clusters
|
|
61 |
-- | Gather and print split instances
|
|
62 |
splitInstancesInfo :: Int -> Node.List -> Instance.List -> IO ()
|
|
63 |
splitInstancesInfo verbose nl il = do
|
68 |
64 |
let split_insts = Cluster.findSplitInstances nl il
|
69 |
|
unless (null split_insts) $ do
|
70 |
|
hPutStrLn stderr "Found instances belonging to multiple node groups:"
|
71 |
|
mapM_ (\i -> hPutStrLn stderr $ " " ++ Instance.name i) split_insts
|
72 |
|
hPutStrLn stderr "Aborting."
|
73 |
|
exitWith $ ExitFailure 1
|
74 |
|
|
75 |
|
printf "Loaded %d nodes, %d instances\n"
|
76 |
|
(Container.size nl)
|
77 |
|
(Container.size il)::IO ()
|
|
65 |
if (null split_insts)
|
|
66 |
then
|
|
67 |
when (verbose > 1) $ do
|
|
68 |
putStrLn "No split instances found"::IO ()
|
|
69 |
else do
|
|
70 |
putStrLn "Found instances belonging to multiple node groups:"
|
|
71 |
mapM_ (\i -> hPutStrLn stderr $ " " ++ Instance.name i) split_insts
|
|
72 |
|
|
73 |
-- | Print common (interesting) information
|
|
74 |
commonInfo :: Int -> Group.List -> Node.List -> Instance.List -> IO ()
|
|
75 |
commonInfo verbose gl nl il = do
|
|
76 |
when (Container.null il && verbose > 1) $ do
|
|
77 |
printf "Cluster is empty.\n"::IO ()
|
|
78 |
|
|
79 |
let nl_size = (Container.size nl)
|
|
80 |
il_size = (Container.size il)
|
|
81 |
gl_size = (Container.size gl)
|
|
82 |
printf "Loaded %d %s, %d %s, %d %s\n"
|
|
83 |
nl_size (plural nl_size "node" "nodes")
|
|
84 |
il_size (plural il_size "instance" "instances")
|
|
85 |
gl_size (plural gl_size "node group" "node groups")::IO ()
|
78 |
86 |
|
79 |
87 |
let csf = commonSuffix nl il
|
80 |
88 |
when (not (null csf) && verbose > 1) $
|
... | ... | |
99 |
107 |
putStrLn $ "Loaded node groups: " ++ show gl
|
100 |
108 |
|
101 |
109 |
nlf <- setNodeStatus opts fixed_nl
|
102 |
|
checkCluster verbose nlf ilf
|
103 |
110 |
|
104 |
|
printf "Cluster has %d node group(s)\n" (Container.size gl)::IO ()
|
|
111 |
commonInfo verbose gl nlf ilf
|
|
112 |
|
|
113 |
splitInstancesInfo verbose nlf ilf
|
105 |
114 |
|
106 |
115 |
maybePrintInsts showinsts "Instances" (Cluster.printInsts nlf ilf)
|
107 |
116 |
|