Revision 836533fa Ganeti/HTools/Node.hs

b/Ganeti/HTools/Node.hs
30 30
           t_dsk, f_dsk,
31 31
           t_cpu, u_cpu,
32 32
           p_mem, p_dsk, p_rem, p_cpu,
33
           m_dsk, m_cpu,
33
           m_dsk, m_cpu, lo_dsk, hi_cpu,
34 34
           plist, slist, offline)
35 35
    , List
36 36
    -- * Constructor
......
93 93
                 , p_cpu :: Double -- ^ Ratio of virtual to physical CPUs
94 94
                 , m_dsk :: Double -- ^ Minimum free disk ratio
95 95
                 , m_cpu :: Double -- ^ Max ratio of virt-to-phys CPUs
96
                 , lo_dsk :: Int   -- ^ Autocomputed from m_dsk low disk
97
                                   -- threshold
98
                 , hi_cpu :: Int   -- ^ Autocomputed from m_cpu high cpu
99
                                   -- threshold
96 100
                 , offline :: Bool -- ^ Whether the node should not be used
97 101
                                   -- for allocations and skipped from
98 102
                                   -- score computations
......
118 122
noLimit :: Double
119 123
noLimit = -1
120 124

  
125
-- | No limit int value
126
noLimitInt :: Int
127
noLimitInt = -1
128

  
121 129
-- * Initialization functions
122 130

  
123 131
-- | Create a new node.
......
151 159
      offline = offline_init,
152 160
      x_mem = 0,
153 161
      m_dsk = noLimit,
154
      m_cpu = noLimit
162
      m_cpu = noLimit,
163
      lo_dsk = noLimitInt,
164
      hi_cpu = noLimitInt
155 165
    }
156 166

  
157 167
-- | Changes the index.
......
176 186

  
177 187
-- | Sets the max disk usage ratio
178 188
setMdsk :: Node -> Double -> Node
179
setMdsk t val = t { m_dsk = val }
189
setMdsk t val = t { m_dsk = val,
190
                    lo_dsk = if val == noLimit
191
                             then noLimitInt
192
                             else floor (val * (t_dsk t)) }
180 193

  
181 194
-- | Sets the max cpu usage ratio
182 195
setMcpu :: Node -> Double -> Node
183
setMcpu t val = t { m_cpu = val }
196
setMcpu t val = t { m_cpu = val, hi_cpu = floor (val * (t_cpu t)) }
184 197

  
185 198
-- | Computes the maximum reserved memory for peers from a peer map.
186 199
computeMaxRes :: PeerMap.PeerMap -> PeerMap.Elem

Also available in: Unified diff