- let
- pdx = Instance.pNode inst
- sdx = Instance.sNode inst
- pold = Container.find pdx accu
- pnew = Node.setPri pold inst
- ac2 = Container.add pdx pnew accu
- in
- if sdx /= Node.noSecondary
- then let sold = Container.find sdx accu
- snew = Node.setSec sold inst
- in Container.add sdx snew ac2
- else ac2
-
--- | 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 }
+ let pdx = Instance.pNode inst
+ sdx = Instance.sNode inst
+ pold = Container.find pdx accu
+ pnew = Node.setPri pold inst
+ ac2 = Container.add pdx pnew accu
+ in if sdx /= Node.noSecondary
+ then let sold = Container.find sdx accu
+ snew = Node.setSec sold inst
+ in Container.add sdx snew ac2
+ else ac2
+
+-- | Set the node's policy to its group one. Note that this requires
+-- the group to exist (should have been checked before), otherwise it
+-- will abort with a runtime error.
+setNodePolicy :: Group.List -> Node.Node -> Node.Node
+setNodePolicy gl node =
+ let grp = Container.find (Node.group node) gl
+ gpol = Group.iPolicy grp
+ in Node.setPolicy gpol node
+
+-- | 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 }