diff --git a/htools/Ganeti/HTools/Instance.hs b/htools/Ganeti/HTools/Instance.hs index 76465cee4e8152e7b6c2ab84dfd60e145e338b91..a330afe0dbc9c55b8c350341d5ff5d4482cd20dc 100644 --- a/htools/Ganeti/HTools/Instance.hs +++ b/htools/Ganeti/HTools/Instance.hs @@ -78,9 +78,10 @@ data Instance = Instance , util :: T.DynUtil -- ^ Dynamic resource usage , movable :: Bool -- ^ Can and should the instance be moved? , autoBalance :: Bool -- ^ Is the instance auto-balanced? - , tags :: [String] -- ^ List of instance tags , diskTemplate :: T.DiskTemplate -- ^ The disk template of the instance , spindleUse :: Int -- ^ The numbers of used spindles + , allTags :: [String] -- ^ List of all instance tags + , exclTags :: [String] -- ^ List of instance exclusion tags } deriving (Show, Read, Eq) instance T.Element Instance where @@ -173,11 +174,12 @@ create name_init mem_init dsk_init vcpus_init run_init tags_init , sNode = sn , idx = -1 , util = T.baseUtil - , tags = tags_init , movable = supportsMoves dt , autoBalance = auto_balance_init , diskTemplate = dt , spindleUse = su + , allTags = tags_init + , exclTags = [] } -- | Changes the index. diff --git a/htools/Ganeti/HTools/Loader.hs b/htools/Ganeti/HTools/Loader.hs index 851c84bb9f83deffc22787eea9023f9477287d48..d441669de3a7bb6eefb3cc511edee953a15cf111 100644 --- a/htools/Ganeti/HTools/Loader.hs +++ b/htools/Ganeti/HTools/Loader.hs @@ -151,12 +151,12 @@ setNodePolicy gl node = gpol = Group.iPolicy grp in Node.setPolicy gpol node --- | Remove non-selected tags from the exclusion list. -filterExTags :: [String] -> Instance.Instance -> Instance.Instance -filterExTags tl inst = - let old_tags = Instance.tags inst - new_tags = filter (\tag -> any (`isPrefixOf` tag) tl) old_tags - in inst { Instance.tags = new_tags } +-- | Update instance with exclusion tags list. +updateExclTags :: [String] -> Instance.Instance -> Instance.Instance +updateExclTags tl inst = + let allTags = Instance.allTags inst + exclTags = filter (\tag -> any (`isPrefixOf` tag) tl) allTags + in inst { Instance.exclTags = exclTags } -- | Update the movable attribute. updateMovable :: [String] -- ^ Selected instances (if not empty) @@ -226,7 +226,7 @@ mergeData um extags selinsts exinsts cdata@(ClusterData gl nl il2 tags _) = node_names = map Node.name (Container.elems nl) common_suffix = longestDomain (node_names ++ inst_names) il4 = Container.map (computeAlias common_suffix . - filterExTags allextags . + updateExclTags allextags . updateMovable selinst_names exinst_names) il3 nl2 = foldl' fixNodes nl (Container.elems il4) nl3 = Container.map (setNodePolicy gl . diff --git a/htools/Ganeti/HTools/Node.hs b/htools/Ganeti/HTools/Node.hs index f744e58e5cfee70a8c89635107bf801d686e01e9..1a14af26b60581497c3ee158cc18e382efa51126 100644 --- a/htools/Ganeti/HTools/Node.hs +++ b/htools/Ganeti/HTools/Node.hs @@ -126,7 +126,7 @@ data Node = Node -- computations , utilPool :: T.DynUtil -- ^ Total utilisation capacity , utilLoad :: T.DynUtil -- ^ Sum of instance utilisation - , pTags :: TagMap -- ^ Map of primary instance tags and their count + , pTags :: TagMap -- ^ Primary instance exclusion tags and their count , group :: T.Gdx -- ^ The node's group (index) , iPolicy :: T.IPolicy -- ^ The instance policy (of the node's group) } deriving (Show, Read, Eq) @@ -327,7 +327,7 @@ setPri t inst = t { pList = Instance.idx inst:pList t , uCpu = new_count , pCpu = fromIntegral new_count / tCpu t , utilLoad = utilLoad t `T.addUtil` Instance.util inst - , pTags = addTags (pTags t) (Instance.tags inst) + , pTags = addTags (pTags t) (Instance.exclTags inst) , instSpindles = calcSpindleUse t inst } where new_count = Instance.applyIfOnline inst (+ Instance.vcpus inst) @@ -376,7 +376,7 @@ removePri t inst = in t { pList = new_plist, fMem = new_mem, fDsk = new_dsk , failN1 = new_failn1, pMem = new_mp, pDsk = new_dp , uCpu = new_ucpu, pCpu = new_rcpu, utilLoad = new_load - , pTags = delTags (pTags t) (Instance.tags inst) + , pTags = delTags (pTags t) (Instance.exclTags inst) , instSpindles = new_spindles } @@ -440,7 +440,7 @@ addPriEx force t inst = new_dp = computePDsk new_dsk (tDsk t) l_cpu = T.iPolicyVcpuRatio $ iPolicy t new_load = utilLoad t `T.addUtil` Instance.util inst - inst_tags = Instance.tags inst + inst_tags = Instance.exclTags inst old_tags = pTags t strict = not force in case () of diff --git a/htools/Ganeti/HTools/Text.hs b/htools/Ganeti/HTools/Text.hs index 4febe9ce4aefb03af551bfad41a4a63c15bc72c5..4197f9fc8fe55fd180fc2bfd11f98da7e59e21b6 100644 --- a/htools/Ganeti/HTools/Text.hs +++ b/htools/Ganeti/HTools/Text.hs @@ -107,7 +107,7 @@ serializeInstance nl inst = (Instance.vcpus inst) (instanceStatusToRaw (Instance.runSt inst)) (if Instance.autoBalance inst then "Y" else "N") pnode snode (diskTemplateToRaw (Instance.diskTemplate inst)) - (intercalate "," (Instance.tags inst)) (Instance.spindleUse inst) + (intercalate "," (Instance.allTags inst)) (Instance.spindleUse inst) -- | Generate instance file data from instance objects. serializeInstances :: Node.List -> Instance.List -> String