Revision 2f907bad
b/htools/Ganeti/HTools/Instance.hs | ||
---|---|---|
78 | 78 |
, util :: T.DynUtil -- ^ Dynamic resource usage |
79 | 79 |
, movable :: Bool -- ^ Can and should the instance be moved? |
80 | 80 |
, autoBalance :: Bool -- ^ Is the instance auto-balanced? |
81 |
, tags :: [String] -- ^ List of instance tags |
|
82 | 81 |
, diskTemplate :: T.DiskTemplate -- ^ The disk template of the instance |
83 | 82 |
, spindleUse :: Int -- ^ The numbers of used spindles |
83 |
, allTags :: [String] -- ^ List of all instance tags |
|
84 |
, exclTags :: [String] -- ^ List of instance exclusion tags |
|
84 | 85 |
} deriving (Show, Read, Eq) |
85 | 86 |
|
86 | 87 |
instance T.Element Instance where |
... | ... | |
173 | 174 |
, sNode = sn |
174 | 175 |
, idx = -1 |
175 | 176 |
, util = T.baseUtil |
176 |
, tags = tags_init |
|
177 | 177 |
, movable = supportsMoves dt |
178 | 178 |
, autoBalance = auto_balance_init |
179 | 179 |
, diskTemplate = dt |
180 | 180 |
, spindleUse = su |
181 |
, allTags = tags_init |
|
182 |
, exclTags = [] |
|
181 | 183 |
} |
182 | 184 |
|
183 | 185 |
-- | Changes the index. |
b/htools/Ganeti/HTools/Loader.hs | ||
---|---|---|
151 | 151 |
gpol = Group.iPolicy grp |
152 | 152 |
in Node.setPolicy gpol node |
153 | 153 |
|
154 |
-- | Remove non-selected tags from the exclusion list.
|
|
155 |
filterExTags :: [String] -> Instance.Instance -> Instance.Instance
|
|
156 |
filterExTags tl inst =
|
|
157 |
let old_tags = Instance.tags inst
|
|
158 |
new_tags = filter (\tag -> any (`isPrefixOf` tag) tl) old_tags
|
|
159 |
in inst { Instance.tags = new_tags }
|
|
154 |
-- | Update instance with exclusion tags list.
|
|
155 |
updateExclTags :: [String] -> Instance.Instance -> Instance.Instance
|
|
156 |
updateExclTags tl inst =
|
|
157 |
let allTags = Instance.allTags inst
|
|
158 |
exclTags = filter (\tag -> any (`isPrefixOf` tag) tl) allTags
|
|
159 |
in inst { Instance.exclTags = exclTags }
|
|
160 | 160 |
|
161 | 161 |
-- | Update the movable attribute. |
162 | 162 |
updateMovable :: [String] -- ^ Selected instances (if not empty) |
... | ... | |
226 | 226 |
node_names = map Node.name (Container.elems nl) |
227 | 227 |
common_suffix = longestDomain (node_names ++ inst_names) |
228 | 228 |
il4 = Container.map (computeAlias common_suffix . |
229 |
filterExTags allextags .
|
|
229 |
updateExclTags allextags .
|
|
230 | 230 |
updateMovable selinst_names exinst_names) il3 |
231 | 231 |
nl2 = foldl' fixNodes nl (Container.elems il4) |
232 | 232 |
nl3 = Container.map (setNodePolicy gl . |
b/htools/Ganeti/HTools/Node.hs | ||
---|---|---|
126 | 126 |
-- computations |
127 | 127 |
, utilPool :: T.DynUtil -- ^ Total utilisation capacity |
128 | 128 |
, utilLoad :: T.DynUtil -- ^ Sum of instance utilisation |
129 |
, pTags :: TagMap -- ^ Map of primary instance tags and their count
|
|
129 |
, pTags :: TagMap -- ^ Primary instance exclusion tags and their count
|
|
130 | 130 |
, group :: T.Gdx -- ^ The node's group (index) |
131 | 131 |
, iPolicy :: T.IPolicy -- ^ The instance policy (of the node's group) |
132 | 132 |
} deriving (Show, Read, Eq) |
... | ... | |
327 | 327 |
, uCpu = new_count |
328 | 328 |
, pCpu = fromIntegral new_count / tCpu t |
329 | 329 |
, utilLoad = utilLoad t `T.addUtil` Instance.util inst |
330 |
, pTags = addTags (pTags t) (Instance.tags inst)
|
|
330 |
, pTags = addTags (pTags t) (Instance.exclTags inst)
|
|
331 | 331 |
, instSpindles = calcSpindleUse t inst |
332 | 332 |
} |
333 | 333 |
where new_count = Instance.applyIfOnline inst (+ Instance.vcpus inst) |
... | ... | |
376 | 376 |
in t { pList = new_plist, fMem = new_mem, fDsk = new_dsk |
377 | 377 |
, failN1 = new_failn1, pMem = new_mp, pDsk = new_dp |
378 | 378 |
, uCpu = new_ucpu, pCpu = new_rcpu, utilLoad = new_load |
379 |
, pTags = delTags (pTags t) (Instance.tags inst)
|
|
379 |
, pTags = delTags (pTags t) (Instance.exclTags inst)
|
|
380 | 380 |
, instSpindles = new_spindles |
381 | 381 |
} |
382 | 382 |
|
... | ... | |
440 | 440 |
new_dp = computePDsk new_dsk (tDsk t) |
441 | 441 |
l_cpu = T.iPolicyVcpuRatio $ iPolicy t |
442 | 442 |
new_load = utilLoad t `T.addUtil` Instance.util inst |
443 |
inst_tags = Instance.tags inst
|
|
443 |
inst_tags = Instance.exclTags inst
|
|
444 | 444 |
old_tags = pTags t |
445 | 445 |
strict = not force |
446 | 446 |
in case () of |
b/htools/Ganeti/HTools/Text.hs | ||
---|---|---|
107 | 107 |
(Instance.vcpus inst) (instanceStatusToRaw (Instance.runSt inst)) |
108 | 108 |
(if Instance.autoBalance inst then "Y" else "N") |
109 | 109 |
pnode snode (diskTemplateToRaw (Instance.diskTemplate inst)) |
110 |
(intercalate "," (Instance.tags inst)) (Instance.spindleUse inst)
|
|
110 |
(intercalate "," (Instance.allTags inst)) (Instance.spindleUse inst)
|
|
111 | 111 |
|
112 | 112 |
-- | Generate instance file data from instance objects. |
113 | 113 |
serializeInstances :: Node.List -> Instance.List -> String |
Also available in: Unified diff