Revision f4c0b8c5
b/Ganeti/HTools/CLI.hs | ||
---|---|---|
129 | 129 |
, optLuxi = Nothing |
130 | 130 |
, optMaster = "" |
131 | 131 |
, optMaxLength = -1 |
132 |
, optMcpu = -1
|
|
133 |
, optMdsk = -1
|
|
132 |
, optMcpu = defVcpuRatio
|
|
133 |
, optMdsk = defReservedDiskRatio
|
|
134 | 134 |
, optMinScore = 1e-9 |
135 | 135 |
, optNoHeaders = False |
136 | 136 |
, optNodeSim = Nothing |
... | ... | |
225 | 225 |
oMaxCpu :: OptType |
226 | 226 |
oMaxCpu = Option "" ["max-cpu"] |
227 | 227 |
(ReqArg (\ n opts -> Ok opts { optMcpu = read n }) "RATIO") |
228 |
"maximum virtual-to-physical cpu ratio for nodes" |
|
228 |
"maximum virtual-to-physical cpu ratio for nodes (from 1\ |
|
229 |
\ upwards) [64]" |
|
229 | 230 |
|
230 | 231 |
oMaxSolLength :: OptType |
231 | 232 |
oMaxSolLength = Option "l" ["max-length"] |
... | ... | |
236 | 237 |
oMinDisk :: OptType |
237 | 238 |
oMinDisk = Option "" ["min-disk"] |
238 | 239 |
(ReqArg (\ n opts -> Ok opts { optMdsk = read n }) "RATIO") |
239 |
"minimum free disk space for nodes (between 0 and 1)" |
|
240 |
"minimum free disk space for nodes (between 0 and 1) [0]"
|
|
240 | 241 |
|
241 | 242 |
oMinScore :: OptType |
242 | 243 |
oMinScore = Option "e" ["min-score"] |
b/Ganeti/HTools/Cluster.hs | ||
---|---|---|
170 | 170 |
, csTmem = x_tmem + Node.tMem node |
171 | 171 |
, csTdsk = x_tdsk + Node.tDsk node |
172 | 172 |
, csTcpu = x_tcpu + Node.tCpu node |
173 |
, csVcpu = if inc_vcpu == Node.noLimitInt |
|
174 |
then Node.noLimitInt |
|
175 |
else x_vcpu + inc_vcpu |
|
173 |
, csVcpu = x_vcpu + inc_vcpu |
|
176 | 174 |
, csXmem = x_xmem + Node.xMem node |
177 | 175 |
, csNmem = x_nmem + Node.nMem node |
178 | 176 |
, csNinst = x_ninst + length (Node.pList node) |
... | ... | |
197 | 195 |
csTmem = t_mem, csTdsk = t_dsk, csVcpu = v_cpu } = cfin |
198 | 196 |
rini = RSpec i_icpu i_imem i_idsk |
199 | 197 |
rfin = RSpec (f_icpu - i_icpu) (f_imem - i_imem) (f_idsk - i_idsk) |
200 |
un_cpu = if v_cpu == Node.noLimitInt |
|
201 |
then Node.noLimitInt |
|
202 |
else v_cpu - f_icpu |
|
198 |
un_cpu = v_cpu - f_icpu |
|
203 | 199 |
runa = RSpec un_cpu (truncate t_mem - f_imem) (truncate t_dsk - f_idsk) |
204 | 200 |
in (rini, rfin, runa) |
205 | 201 |
|
b/Ganeti/HTools/Node.hs | ||
---|---|---|
58 | 58 |
, AssocList |
59 | 59 |
, AllocElement |
60 | 60 |
, noSecondary |
61 |
, noLimitInt |
|
62 | 61 |
) where |
63 | 62 |
|
64 | 63 |
import Data.List |
... | ... | |
133 | 132 |
noSecondary :: T.Ndx |
134 | 133 |
noSecondary = -1 |
135 | 134 |
|
136 |
-- | No limit value |
|
137 |
noLimit :: Double |
|
138 |
noLimit = -1 |
|
139 |
|
|
140 |
-- | No limit int value |
|
141 |
noLimitInt :: Int |
|
142 |
noLimitInt = -1 |
|
143 |
|
|
144 | 135 |
-- * Helper functions |
145 | 136 |
|
146 | 137 |
-- | Add a tag to a tagmap |
... | ... | |
204 | 195 |
, pCpu = 0 |
205 | 196 |
, offline = offline_init |
206 | 197 |
, xMem = 0 |
207 |
, mDsk = noLimit
|
|
208 |
, mCpu = noLimit
|
|
209 |
, loDsk = noLimitInt
|
|
210 |
, hiCpu = noLimitInt
|
|
198 |
, mDsk = T.defReservedDiskRatio
|
|
199 |
, mCpu = T.defVcpuRatio
|
|
200 |
, loDsk = mDskToloDsk T.defReservedDiskRatio dsk_t_init
|
|
201 |
, hiCpu = mCpuTohiCpu T.defVcpuRatio cpu_t_init
|
|
211 | 202 |
, utilPool = T.baseUtil |
212 | 203 |
, utilLoad = T.zeroUtil |
213 | 204 |
, pTags = Map.empty |
214 | 205 |
} |
215 | 206 |
|
207 |
-- | Conversion formula from mDsk/tDsk to loDsk |
|
208 |
mDskToloDsk :: Double -> Double -> Int |
|
209 |
mDskToloDsk mval tdsk = floor (mval * tdsk) |
|
210 |
|
|
211 |
-- | Conversion formula from mCpu/tCpu to hiCpu |
|
212 |
mCpuTohiCpu :: Double -> Double -> Int |
|
213 |
mCpuTohiCpu mval tcpu = floor (mval * tcpu) |
|
214 |
|
|
216 | 215 |
-- | Changes the index. |
217 | 216 |
-- |
218 | 217 |
-- This is used only during the building of the data structures. |
... | ... | |
235 | 234 |
|
236 | 235 |
-- | Sets the max disk usage ratio |
237 | 236 |
setMdsk :: Node -> Double -> Node |
238 |
setMdsk t val = t { mDsk = val, |
|
239 |
loDsk = if val == noLimit |
|
240 |
then noLimitInt |
|
241 |
else floor (val * tDsk t) } |
|
237 |
setMdsk t val = t { mDsk = val, loDsk = mDskToloDsk val (tDsk t) } |
|
242 | 238 |
|
243 | 239 |
-- | Sets the max cpu usage ratio |
244 | 240 |
setMcpu :: Node -> Double -> Node |
245 |
setMcpu t val = t { mCpu = val, hiCpu = hcpu } |
|
246 |
where new_hcpu = floor (val * tCpu t)::Int |
|
247 |
hcpu = if new_hcpu < 0 |
|
248 |
then noLimitInt |
|
249 |
else new_hcpu |
|
241 |
setMcpu t val = t { mCpu = val, hiCpu = mCpuTohiCpu val (tCpu t) } |
|
250 | 242 |
|
251 | 243 |
-- | Computes the maximum reserved memory for peers from a peer map. |
252 | 244 |
computeMaxRes :: P.PeerMap -> P.Elem |
... | ... | |
401 | 393 |
availDisk t = |
402 | 394 |
let _f = fDsk t |
403 | 395 |
_l = loDsk t |
404 |
in |
|
405 |
if _l == noLimitInt |
|
406 |
then _f |
|
407 |
else if _f < _l |
|
408 |
then 0 |
|
409 |
else _f - _l |
|
396 |
in if _f < _l |
|
397 |
then 0 |
|
398 |
else _f - _l |
|
410 | 399 |
|
411 | 400 |
-- * Display functions |
412 | 401 |
|
b/Ganeti/HTools/Types.hs | ||
---|---|---|
35 | 35 |
, baseUtil |
36 | 36 |
, addUtil |
37 | 37 |
, subUtil |
38 |
, defVcpuRatio |
|
39 |
, defReservedDiskRatio |
|
38 | 40 |
, Placement |
39 | 41 |
, IMove(..) |
40 | 42 |
, MoveJob |
... | ... | |
124 | 126 |
queryTimeout :: Int |
125 | 127 |
queryTimeout = 60 |
126 | 128 |
|
129 |
-- | Default vcpu-to-pcpu ratio (randomly chosen value). |
|
130 |
defVcpuRatio :: Double |
|
131 |
defVcpuRatio = 64 |
|
132 |
|
|
133 |
-- | Default max disk usage ratio. |
|
134 |
defReservedDiskRatio :: Double |
|
135 |
defReservedDiskRatio = 0 |
|
136 |
|
|
127 | 137 |
{-| |
128 | 138 |
|
129 | 139 |
This is similar to the JSON library Result type - *very* similar, but |
Also available in: Unified diff