Revision 92e32d76

b/Ganeti/HTools/CLI.hs
69 69
import Text.Printf (printf)
70 70

  
71 71
import qualified Ganeti.HTools.Version as Version(version)
72
import qualified Ganeti.HTools.Cluster as Cluster
72
import Ganeti.HTools.Types
73 73

  
74 74
-- | The default value for the luxi socket
75 75
defaultLuxiSocket :: FilePath
......
95 95
    , optIDsk      :: Int            -- ^ Instance disk
96 96
    , optIVCPUs    :: Int            -- ^ Instance VCPUs
97 97
    , optINodes    :: Int            -- ^ Nodes required for an instance
98
    , optMinScore  :: Cluster.Score  -- ^ The minimum score we aim for
98
    , optMinScore  :: Score          -- ^ The minimum score we aim for
99 99
    , optMcpu      :: Double         -- ^ Max cpu ratio for nodes
100 100
    , optMdsk      :: Double         -- ^ Max disk usage ratio for nodes
101 101
    , optDiskMoves :: Bool           -- ^ Allow disk moves
b/Ganeti/HTools/Cluster.hs
32 32
      Placement
33 33
    , AllocSolution
34 34
    , Table(..)
35
    , Score
36
    , IMove(..)
37 35
    , CStats(..)
38 36
    -- * Generic functions
39 37
    , totalResources
......
72 70

  
73 71
-- * Types
74 72

  
75
-- | A separate name for the cluster score type.
76
type Score = Double
77

  
78
-- | The description of an instance placement.
79
type Placement = ( Idx   -- ^ The index of the instance being moved
80
                 , Ndx   -- ^ New primary node
81
                 , Ndx   -- ^ New secondary node
82
                 , IMove -- ^ The move being performed
83
                 , Score -- ^ The score of the cluster after this move
84
                 )
85

  
86 73
-- | Allocation\/relocation solution.
87 74
type AllocSolution = ([FailMode], Int, Maybe (Score, AllocElement))
88 75

  
89 76
-- | Allocation\/relocation element.
90 77
type AllocElement = (Node.List, Instance.Instance, [Node.Node])
91 78

  
92
-- | An instance move definition
93
data IMove = Failover                -- ^ Failover the instance (f)
94
           | ReplacePrimary Ndx      -- ^ Replace primary (f, r:np, f)
95
           | ReplaceSecondary Ndx    -- ^ Replace secondary (r:ns)
96
           | ReplaceAndFailover Ndx  -- ^ Replace secondary, failover (r:np, f)
97
           | FailoverAndReplace Ndx  -- ^ Failover, replace secondary (f, r:ns)
98
             deriving (Show)
99 79

  
100 80
-- | The complete state for the balancing solution
101 81
data Table = Table Node.List Instance.List Score [Placement]
b/Ganeti/HTools/Types.hs
27 27
    ( Idx
28 28
    , Ndx
29 29
    , NameAssoc
30
    , Score
31
    , Placement
32
    , IMove(..)
30 33
    , MoveJob
31 34
    , JobSet
32 35
    , Result(..)
......
47 50
-- | The type used to hold name-to-idx mappings.
48 51
type NameAssoc = [(String, Int)]
49 52

  
53
-- | A separate name for the cluster score type.
54
type Score = Double
55

  
56
-- | The description of an instance placement.
57
type Placement = ( Idx   -- ^ The index of the instance being moved
58
                 , Ndx   -- ^ New primary node
59
                 , Ndx   -- ^ New secondary node
60
                 , IMove -- ^ The move being performed
61
                 , Score -- ^ The score of the cluster after this move
62
                 )
63

  
64
-- | An instance move definition
65
data IMove = Failover                -- ^ Failover the instance (f)
66
           | ReplacePrimary Ndx      -- ^ Replace primary (f, r:np, f)
67
           | ReplaceSecondary Ndx    -- ^ Replace secondary (r:ns)
68
           | ReplaceAndFailover Ndx  -- ^ Replace secondary, failover (r:np, f)
69
           | FailoverAndReplace Ndx  -- ^ Failover, replace secondary (f, r:ns)
70
             deriving (Show)
71

  
50 72
-- | Formatted solution output for one move (involved nodes and
51 73
-- commands
52 74
type MoveJob = ([Ndx], [String])
b/hbal.hs
77 77
             -> Int              -- ^ Max instance name len
78 78
             -> [MoveJob]        -- ^ Current command list
79 79
             -> Bool             -- ^ Whether to be silent
80
             -> Cluster.Score    -- ^ Score at which to stop
80
             -> Score            -- ^ Score at which to stop
81 81
             -> IO (Cluster.Table, [MoveJob]) -- ^ The resulting table
82 82
                                              -- and commands
83 83
iterateDepth ini_tbl max_rounds disk_moves nmlen imlen

Also available in: Unified diff