, 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
, 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.
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)
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 .
-- 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)
, 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)
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
}
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
(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