Revision 487e1962 htools/Ganeti/HTools/Node.hs
b/htools/Ganeti/HTools/Node.hs | ||
---|---|---|
113 | 113 |
, pRem :: Double -- ^ Percent of reserved memory |
114 | 114 |
, pCpu :: Double -- ^ Ratio of virtual to physical CPUs |
115 | 115 |
, mDsk :: Double -- ^ Minimum free disk ratio |
116 |
, mCpu :: Double -- ^ Max ratio of virt-to-phys CPUs |
|
117 | 116 |
, loDsk :: Int -- ^ Autocomputed from mDsk low disk |
118 | 117 |
-- threshold |
119 | 118 |
, hiCpu :: Int -- ^ Autocomputed from mCpu high cpu |
... | ... | |
214 | 213 |
, offline = offline_init |
215 | 214 |
, xMem = 0 |
216 | 215 |
, mDsk = T.defReservedDiskRatio |
217 |
, mCpu = T.defVcpuRatio |
|
218 | 216 |
, loDsk = mDskToloDsk T.defReservedDiskRatio dsk_t_init |
219 |
, hiCpu = mCpuTohiCpu T.defVcpuRatio cpu_t_init
|
|
217 |
, hiCpu = mCpuTohiCpu (T.iPolicyVcpuRatio T.defIPolicy) cpu_t_init
|
|
220 | 218 |
, utilPool = T.baseUtil |
221 | 219 |
, utilLoad = T.zeroUtil |
222 | 220 |
, pTags = Map.empty |
... | ... | |
256 | 254 |
setMdsk :: Node -> Double -> Node |
257 | 255 |
setMdsk t val = t { mDsk = val, loDsk = mDskToloDsk val (tDsk t) } |
258 | 256 |
|
259 |
-- | Sets the max cpu usage ratio. |
|
257 |
-- | Sets the max cpu usage ratio. This will update the node's |
|
258 |
-- ipolicy, losing sharing (but it should be a seldomly done operation). |
|
260 | 259 |
setMcpu :: Node -> Double -> Node |
261 |
setMcpu t val = t { mCpu = val, hiCpu = mCpuTohiCpu val (tCpu t) } |
|
260 |
setMcpu t val = |
|
261 |
let new_ipol = (iPolicy t) { T.iPolicyVcpuRatio = val } |
|
262 |
in t { hiCpu = mCpuTohiCpu val (tCpu t), iPolicy = new_ipol } |
|
262 | 263 |
|
263 | 264 |
-- | Sets the policy. |
264 | 265 |
setPolicy :: T.IPolicy -> Node -> Node |
265 |
setPolicy pol node = node { iPolicy = pol } |
|
266 |
setPolicy pol node = |
|
267 |
node { iPolicy = pol |
|
268 |
, hiCpu = mCpuTohiCpu (T.iPolicyVcpuRatio pol) (tCpu node) } |
|
266 | 269 |
|
267 | 270 |
-- | Computes the maximum reserved memory for peers from a peer map. |
268 | 271 |
computeMaxRes :: P.PeerMap -> P.Elem |
... | ... | |
391 | 394 |
new_ucpu = Instance.applyIfOnline inst (+ Instance.vcpus inst) (uCpu t) |
392 | 395 |
new_pcpu = fromIntegral new_ucpu / tCpu t |
393 | 396 |
new_dp = fromIntegral new_dsk / tDsk t |
394 |
l_cpu = mCpu t
|
|
397 |
l_cpu = T.iPolicyVcpuRatio $ iPolicy t
|
|
395 | 398 |
new_load = utilLoad t `T.addUtil` Instance.util inst |
396 | 399 |
inst_tags = Instance.tags inst |
397 | 400 |
old_tags = pTags t |
Also available in: Unified diff