-}
module Ganeti.HTools.Group
- ( Group(..)
- , List
- , AssocList
- -- * Constructor
- , create
- , setIdx
- , isAllocable
- ) where
+ ( Group(..)
+ , List
+ , AssocList
+ -- * Constructor
+ , create
+ , setIdx
+ , isAllocable
+ ) where
import qualified Ganeti.HTools.Container as Container
-- | The node group type.
data Group = Group
- { name :: String -- ^ The node name
- , uuid :: T.GroupID -- ^ The UUID of the group
- , idx :: T.Gdx -- ^ Internal index for book-keeping
- , allocPolicy :: T.AllocPolicy -- ^ The allocation policy for this group
- } deriving (Show, Read, Eq)
+ { name :: String -- ^ The node name
+ , uuid :: T.GroupID -- ^ The UUID of the group
+ , idx :: T.Gdx -- ^ Internal index for book-keeping
+ , allocPolicy :: T.AllocPolicy -- ^ The allocation policy for this group
+ , iPolicy :: T.IPolicy -- ^ The instance policy for this group
+ } deriving (Show, Read, Eq)
-- Note: we use the name as the alias, and the UUID as the official
-- name
instance T.Element Group where
- nameOf = uuid
- idxOf = idx
- setAlias = setName
- setIdx = setIdx
- allNames n = [name n, uuid n]
+ nameOf = uuid
+ idxOf = idx
+ setAlias = setName
+ setIdx = setIdx
+ allNames n = [name n, uuid n]
-- | A simple name for the int, node association list.
type AssocList = [(T.Gdx, Group)]
-- * Initialization functions
-- | Create a new group.
-create :: String -> T.GroupID -> T.AllocPolicy -> Group
-create name_init id_init apol_init =
- Group { name = name_init
- , uuid = id_init
- , allocPolicy = apol_init
- , idx = -1
- }
-
+create :: String -> T.GroupID -> T.AllocPolicy -> T.IPolicy -> Group
+create name_init id_init apol_init ipol_init =
+ Group { name = name_init
+ , uuid = id_init
+ , allocPolicy = apol_init
+ , iPolicy = ipol_init
+ , idx = -1
+ }
+
+-- | Sets the group index.
+--
-- This is used only during the building of the data structures.
setIdx :: Group -> T.Gdx -> Group
setIdx t i = t {idx = i}