Revision f5b553da Ganeti/HTools/Cluster.hs
b/Ganeti/HTools/Cluster.hs | ||
---|---|---|
81 | 81 |
data Table = Table Node.List Instance.List Score [Placement] |
82 | 82 |
deriving (Show) |
83 | 83 |
|
84 |
data CStats = CStats { cs_fmem :: Int -- ^ Cluster free mem
|
|
85 |
, cs_fdsk :: Int -- ^ Cluster free disk
|
|
86 |
, cs_amem :: Int -- ^ Cluster allocatable mem
|
|
87 |
, cs_adsk :: Int -- ^ Cluster allocatable disk
|
|
88 |
, cs_acpu :: Int -- ^ Cluster allocatable cpus
|
|
89 |
, cs_mmem :: Int -- ^ Max node allocatable mem
|
|
90 |
, cs_mdsk :: Int -- ^ Max node allocatable disk
|
|
91 |
, cs_mcpu :: Int -- ^ Max node allocatable cpu
|
|
92 |
, cs_imem :: Int -- ^ Instance used mem
|
|
93 |
, cs_idsk :: Int -- ^ Instance used disk
|
|
94 |
, cs_icpu :: Int -- ^ Instance used cpu
|
|
95 |
, cs_tmem :: Double -- ^ Cluster total mem
|
|
96 |
, cs_tdsk :: Double -- ^ Cluster total disk
|
|
97 |
, cs_tcpu :: Double -- ^ Cluster total cpus
|
|
98 |
, cs_xmem :: Int -- ^ Unnacounted for mem
|
|
99 |
, cs_nmem :: Int -- ^ Node own memory
|
|
100 |
, cs_score :: Score -- ^ The cluster score
|
|
101 |
, cs_ninst :: Int -- ^ The total number of instances
|
|
84 |
data CStats = CStats { csFmem :: Int -- ^ Cluster free mem
|
|
85 |
, csFdsk :: Int -- ^ Cluster free disk
|
|
86 |
, csAmem :: Int -- ^ Cluster allocatable mem
|
|
87 |
, csAdsk :: Int -- ^ Cluster allocatable disk
|
|
88 |
, csAcpu :: Int -- ^ Cluster allocatable cpus
|
|
89 |
, csMmem :: Int -- ^ Max node allocatable mem
|
|
90 |
, csMdsk :: Int -- ^ Max node allocatable disk
|
|
91 |
, csMcpu :: Int -- ^ Max node allocatable cpu
|
|
92 |
, csImem :: Int -- ^ Instance used mem
|
|
93 |
, csIdsk :: Int -- ^ Instance used disk
|
|
94 |
, csIcpu :: Int -- ^ Instance used cpu
|
|
95 |
, csTmem :: Double -- ^ Cluster total mem
|
|
96 |
, csTdsk :: Double -- ^ Cluster total disk
|
|
97 |
, csTcpu :: Double -- ^ Cluster total cpus
|
|
98 |
, csXmem :: Int -- ^ Unnacounted for mem
|
|
99 |
, csNmem :: Int -- ^ Node own memory
|
|
100 |
, csScore :: Score -- ^ The cluster score
|
|
101 |
, csNinst :: Int -- ^ The total number of instances
|
|
102 | 102 |
} |
103 | 103 |
|
104 | 104 |
-- * Utility functions |
... | ... | |
125 | 125 |
(bad_nodes, bad_instances) |
126 | 126 |
|
127 | 127 |
emptyCStats :: CStats |
128 |
emptyCStats = CStats { cs_fmem = 0
|
|
129 |
, cs_fdsk = 0
|
|
130 |
, cs_amem = 0
|
|
131 |
, cs_adsk = 0
|
|
132 |
, cs_acpu = 0
|
|
133 |
, cs_mmem = 0
|
|
134 |
, cs_mdsk = 0
|
|
135 |
, cs_mcpu = 0
|
|
136 |
, cs_imem = 0
|
|
137 |
, cs_idsk = 0
|
|
138 |
, cs_icpu = 0
|
|
139 |
, cs_tmem = 0
|
|
140 |
, cs_tdsk = 0
|
|
141 |
, cs_tcpu = 0
|
|
142 |
, cs_xmem = 0
|
|
143 |
, cs_nmem = 0
|
|
144 |
, cs_score = 0
|
|
145 |
, cs_ninst = 0
|
|
128 |
emptyCStats = CStats { csFmem = 0
|
|
129 |
, csFdsk = 0
|
|
130 |
, csAmem = 0
|
|
131 |
, csAdsk = 0
|
|
132 |
, csAcpu = 0
|
|
133 |
, csMmem = 0
|
|
134 |
, csMdsk = 0
|
|
135 |
, csMcpu = 0
|
|
136 |
, csImem = 0
|
|
137 |
, csIdsk = 0
|
|
138 |
, csIcpu = 0
|
|
139 |
, csTmem = 0
|
|
140 |
, csTdsk = 0
|
|
141 |
, csTcpu = 0
|
|
142 |
, csXmem = 0
|
|
143 |
, csNmem = 0
|
|
144 |
, csScore = 0
|
|
145 |
, csNinst = 0
|
|
146 | 146 |
} |
147 | 147 |
|
148 | 148 |
updateCStats :: CStats -> Node.Node -> CStats |
149 | 149 |
updateCStats cs node = |
150 |
let CStats { cs_fmem = x_fmem, cs_fdsk = x_fdsk,
|
|
151 |
cs_amem = x_amem, cs_acpu = x_acpu, cs_adsk = x_adsk,
|
|
152 |
cs_mmem = x_mmem, cs_mdsk = x_mdsk, cs_mcpu = x_mcpu,
|
|
153 |
cs_imem = x_imem, cs_idsk = x_idsk, cs_icpu = x_icpu,
|
|
154 |
cs_tmem = x_tmem, cs_tdsk = x_tdsk, cs_tcpu = x_tcpu,
|
|
155 |
cs_xmem = x_xmem, cs_nmem = x_nmem, cs_ninst = x_ninst
|
|
150 |
let CStats { csFmem = x_fmem, csFdsk = x_fdsk,
|
|
151 |
csAmem = x_amem, csAcpu = x_acpu, csAdsk = x_adsk,
|
|
152 |
csMmem = x_mmem, csMdsk = x_mdsk, csMcpu = x_mcpu,
|
|
153 |
csImem = x_imem, csIdsk = x_idsk, csIcpu = x_icpu,
|
|
154 |
csTmem = x_tmem, csTdsk = x_tdsk, csTcpu = x_tcpu,
|
|
155 |
csXmem = x_xmem, csNmem = x_nmem, csNinst = x_ninst
|
|
156 | 156 |
} |
157 | 157 |
= cs |
158 | 158 |
inc_amem = Node.fMem node - Node.rMem node |
... | ... | |
163 | 163 |
inc_icpu = Node.uCpu node |
164 | 164 |
inc_idsk = truncate (Node.tDsk node) - Node.fDsk node |
165 | 165 |
|
166 |
in cs { cs_fmem = x_fmem + Node.fMem node
|
|
167 |
, cs_fdsk = x_fdsk + Node.fDsk node
|
|
168 |
, cs_amem = x_amem + inc_amem'
|
|
169 |
, cs_adsk = x_adsk + inc_adsk
|
|
170 |
, cs_acpu = x_acpu
|
|
171 |
, cs_mmem = max x_mmem inc_amem'
|
|
172 |
, cs_mdsk = max x_mdsk inc_adsk
|
|
173 |
, cs_mcpu = x_mcpu
|
|
174 |
, cs_imem = x_imem + inc_imem
|
|
175 |
, cs_idsk = x_idsk + inc_idsk
|
|
176 |
, cs_icpu = x_icpu + inc_icpu
|
|
177 |
, cs_tmem = x_tmem + Node.tMem node
|
|
178 |
, cs_tdsk = x_tdsk + Node.tDsk node
|
|
179 |
, cs_tcpu = x_tcpu + Node.tCpu node
|
|
180 |
, cs_xmem = x_xmem + Node.xMem node
|
|
181 |
, cs_nmem = x_nmem + Node.nMem node
|
|
182 |
, cs_ninst = x_ninst + length (Node.pList node)
|
|
166 |
in cs { csFmem = x_fmem + Node.fMem node
|
|
167 |
, csFdsk = x_fdsk + Node.fDsk node
|
|
168 |
, csAmem = x_amem + inc_amem'
|
|
169 |
, csAdsk = x_adsk + inc_adsk
|
|
170 |
, csAcpu = x_acpu
|
|
171 |
, csMmem = max x_mmem inc_amem'
|
|
172 |
, csMdsk = max x_mdsk inc_adsk
|
|
173 |
, csMcpu = x_mcpu
|
|
174 |
, csImem = x_imem + inc_imem
|
|
175 |
, csIdsk = x_idsk + inc_idsk
|
|
176 |
, csIcpu = x_icpu + inc_icpu
|
|
177 |
, csTmem = x_tmem + Node.tMem node
|
|
178 |
, csTdsk = x_tdsk + Node.tDsk node
|
|
179 |
, csTcpu = x_tcpu + Node.tCpu node
|
|
180 |
, csXmem = x_xmem + Node.xMem node
|
|
181 |
, csNmem = x_nmem + Node.nMem node
|
|
182 |
, csNinst = x_ninst + length (Node.pList node)
|
|
183 | 183 |
} |
184 | 184 |
|
185 | 185 |
-- | Compute the total free disk and memory in the cluster. |
186 | 186 |
totalResources :: Node.List -> CStats |
187 | 187 |
totalResources nl = |
188 | 188 |
let cs = foldl' updateCStats emptyCStats . Container.elems $ nl |
189 |
in cs { cs_score = compCV nl }
|
|
189 |
in cs { csScore = compCV nl }
|
|
190 | 190 |
|
191 | 191 |
-- | The names of the individual elements in the CV list |
192 | 192 |
detailedCVNames :: [String] |
Also available in: Unified diff