Revision 78694255 Ganeti/HTools/Cluster.hs

b/Ganeti/HTools/Cluster.hs
30 30
```    (
```
31 31
```     -- * Types
```
32 32
```      Placement
```
33
```    , AllocSolution
```
33 34
```    , Solution(..)
```
34 35
```    , Table(..)
```
35 36
```    , Removal
```
......
78 79
```-- | The description of an instance placement.
```
79 80
```type Placement = (Idx, Ndx, Ndx, Score)
```
80 81

82
```-- | Allocation/relocation solution.
```
83
```type AllocSolution = [(Maybe Node.List, Instance.Instance, [Node.Node])]
```
84

81 85
```-- | A cluster solution described as the solution delta and the list
```
82 86
```-- of placements.
```
83 87
```data Solution = Solution Int [Placement]
```
......
158 162
```        mem_cv = varianceCoeff mem_l
```
159 163
```        dsk_cv = varianceCoeff dsk_l
```
160 164
```        n1_l = length \$ filter Node.failN1 nodes
```
161
```        n1_score = (fromIntegral n1_l) / (fromIntegral \$ length nodes)
```
165
```        n1_score = ((fromIntegral n1_l) /
```
166
```                    (fromIntegral \$ length nodes))::Double
```
162 167
```        res_l = map Node.p_rem nodes
```
163 168
```        res_cv = varianceCoeff res_l
```
164 169
```        offline_inst = sum . map (\n -> (length . Node.plist \$ n) +
```
165 170
```                                        (length . Node.slist \$ n)) \$ offline
```
166 171
```        online_inst = sum . map (\n -> (length . Node.plist \$ n) +
```
167 172
```                                       (length . Node.slist \$ n)) \$ nodes
```
168
```        off_score = (fromIntegral offline_inst) /
```
169
```                    (fromIntegral \$ online_inst + offline_inst)
```
173
```        off_score = ((fromIntegral offline_inst) /
```
174
```                     (fromIntegral \$ online_inst + offline_inst))::Double
```
170 175
```        cpu_l = map Node.p_cpu nodes
```
171 176
```        cpu_cv = varianceCoeff cpu_l
```
172 177
```    in (mem_cv, dsk_cv, n1_score, res_cv, off_score, cpu_cv)
```
......
631 636
```         -> Instance.List     -- ^ The instance list
```
632 637
```         -> Instance.Instance -- ^ The instance to allocate
```
633 638
```         -> Int               -- ^ Required number of nodes
```
634
```         -> m [(Maybe Node.List, Instance.Instance, [Node.Node])]
```
635
```                              -- ^ Possible solution list
```
639
```         -> m AllocSolution   -- ^ Possible solution list
```
636 640
```tryAlloc nl _ inst 2 =
```
637 641
```    let all_nodes = getOnline nl
```
638 642
```        all_pairs = liftM2 (,) all_nodes all_nodes
```
......
655 659

656 660
```-- | Try to allocate an instance on the cluster.
```
657 661
```tryReloc :: (Monad m) =>
```
658
```            Node.List     -- ^ The node list
```
659
```         -> Instance.List -- ^ The instance list
```
660
```         -> Idx           -- ^ The index of the instance to move
```
661
```         -> Int           -- ^ The numver of nodes required
```
662
```         -> [Ndx]         -- ^ Nodes which should not be used
```
663
```         -> m [(Maybe Node.List, Instance.Instance, [Node.Node])]
```
664
```                          -- ^ Solution list
```
662
```            Node.List       -- ^ The node list
```
663
```         -> Instance.List   -- ^ The instance list
```
664
```         -> Idx             -- ^ The index of the instance to move
```
665
```         -> Int             -- ^ The numver of nodes required
```
666
```         -> [Ndx]           -- ^ Nodes which should not be used
```
667
```         -> m AllocSolution -- ^ Solution list
```
665 668
```tryReloc nl il xid 1 ex_idx =
```
666 669
```    let all_nodes = getOnline nl
```
667 670
```        inst = Container.find xid il
```
......
782 785
```    let snl = sortBy (compare `on` Node.idx) (Container.elems nl)
```
783 786
```        m_name = maximum . map (length . Node.name) \$ snl
```
784 787
```        helper = Node.list m_name
```
785
```        header = printf
```
786
```                 "%2s %-*s %5s %5s %5s %5s %5s %5s %5s %5s %4s %4s \
```
787
```                 \%3s %3s %6s %6s %5s"
```
788
```                 " F" m_name "Name"
```
789
```                 "t_mem" "n_mem" "i_mem" "x_mem" "f_mem" "r_mem"
```
790
```                 "t_dsk" "f_dsk" "pcpu" "vcpu"
```
791
```                 "pri" "sec" "p_fmem" "p_fdsk" "r_cpu"
```
788
```        header = (printf
```
789
```                  "%2s %-*s %5s %5s %5s %5s %5s %5s %5s %5s %4s %4s \
```
790
```                  \%3s %3s %6s %6s %5s"
```
791
```                  " F" m_name "Name"
```
792
```                  "t_mem" "n_mem" "i_mem" "x_mem" "f_mem" "r_mem"
```
793
```                  "t_dsk" "f_dsk" "pcpu" "vcpu"
```
794
```                  "pri" "sec" "p_fmem" "p_fdsk" "r_cpu")::String
```
792 795
```    in unlines \$ (header:map helper snl)
```
793 796

794 797
```-- | Shows statistics for a given node list.
```

Also available in: Unified diff