X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/0ec6344ec9e71ac565421b2c5890869d6b733301..13f2321cc5e852dd2183faa1de1c5e14569a5599:/htools/Ganeti/HTools/Group.hs?ds=sidebyside diff --git a/htools/Ganeti/HTools/Group.hs b/htools/Ganeti/HTools/Group.hs index 8281678..8eb7e4f 100644 --- a/htools/Ganeti/HTools/Group.hs +++ b/htools/Ganeti/HTools/Group.hs @@ -24,14 +24,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -} 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 @@ -41,20 +41,21 @@ import qualified Ganeti.HTools.Types as T -- | 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)] @@ -65,14 +66,17 @@ type List = Container.Container 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}