Revision ebf38064 htools/Ganeti/HTools/Group.hs

b/htools/Ganeti/HTools/Group.hs
24 24
-}
25 25

  
26 26
module Ganeti.HTools.Group
27
    ( Group(..)
28
    , List
29
    , AssocList
30
    -- * Constructor
31
    , create
32
    , setIdx
33
    , isAllocable
34
    ) where
27
  ( Group(..)
28
  , List
29
  , AssocList
30
  -- * Constructor
31
  , create
32
  , setIdx
33
  , isAllocable
34
  ) where
35 35

  
36 36
import qualified Ganeti.HTools.Container as Container
37 37

  
......
41 41

  
42 42
-- | The node group type.
43 43
data Group = Group
44
    { name        :: String        -- ^ The node name
45
    , uuid        :: T.GroupID     -- ^ The UUID of the group
46
    , idx         :: T.Gdx         -- ^ Internal index for book-keeping
47
    , allocPolicy :: T.AllocPolicy -- ^ The allocation policy for this group
48
    } deriving (Show, Read, Eq)
44
  { name        :: String        -- ^ The node name
45
  , uuid        :: T.GroupID     -- ^ The UUID of the group
46
  , idx         :: T.Gdx         -- ^ Internal index for book-keeping
47
  , allocPolicy :: T.AllocPolicy -- ^ The allocation policy for this group
48
  } deriving (Show, Read, Eq)
49 49

  
50 50
-- Note: we use the name as the alias, and the UUID as the official
51 51
-- name
52 52
instance T.Element Group where
53
    nameOf     = uuid
54
    idxOf      = idx
55
    setAlias   = setName
56
    setIdx     = setIdx
57
    allNames n = [name n, uuid n]
53
  nameOf     = uuid
54
  idxOf      = idx
55
  setAlias   = setName
56
  setIdx     = setIdx
57
  allNames n = [name n, uuid n]
58 58

  
59 59
-- | A simple name for the int, node association list.
60 60
type AssocList = [(T.Gdx, Group)]
......
67 67
-- | Create a new group.
68 68
create :: String -> T.GroupID -> T.AllocPolicy -> Group
69 69
create name_init id_init apol_init =
70
    Group { name        = name_init
71
          , uuid        = id_init
72
          , allocPolicy = apol_init
73
          , idx         = -1
74
          }
70
  Group { name        = name_init
71
        , uuid        = id_init
72
        , allocPolicy = apol_init
73
        , idx         = -1
74
        }
75 75

  
76 76
-- | Sets the group index.
77 77
--

Also available in: Unified diff