def manage_runAllRulesets(self, REQUEST=None): """ build current/potential matches for devices matching all ruleset rules """ data = ProfileData(self.dmd) rmvs = [] adds = [] print "building adds and removes sets" for ruleset in self.getAllRulesets(): print "ruleset", ruleset.id rmvs.append(set(ruleset.applyRules(True))) adds.append(set(ruleset.applyRules(False))) print "rebuilding components for all rulesets" self.setRulesetComponents() from ProfileSets import ProfileSets setMgr = ProfileSets(self.dmd) rmdevs = setMgr.evalSets(rmvs, False) addevs = setMgr.evalSets(adds, False) message = "No changes were made" if len(rmdevs) > 0 or len(addevs) > 0: message = "" if len(rmdevs) > 0: message += "Rulesets unapplied to %s" % ", ".join(data.getDeviceNames(rmdevs)) if len(addevs) > 0: message += " Rulesets applied to %s" % ", ".join(data.getDeviceNames(addevs)) if REQUEST: messaging.IMessageSender(self).sendToBrowser(message, message) return self.callZenScreen(REQUEST)
def getPotentialDeviceMatches(self): """ return list of potential member devices complying with any or all rules in a set """ setMgr = ProfileSets(self.dmd) setData = ProfileData(self.dmd) sets = [] for rule in self.rules(): if rule.enabled == True: dset = set(rule.rulePotentialMatches) sets.append(dset) devices = setMgr.evalSets(sets,self.matchAll) return setData.getDeviceObjects(devices)
def setRuleMatches(self): """ find potential matches for this rule: potential matches match the rule, but are not members of all rule organizers """ self.rulePotentialMatches = [] self.ruleCurrentMatches = [] setmgr = ProfileSets(self.dmd) data = ProfileData(self.dmd) devices = setmgr.evalRule(self) if devices: data.setRuleMembers(self,devices) else: self.rulePotentialMatches = [] self.ruleCurrentMatches = []
def setRuleComponents(self): """ collect components that match rule """ setmgr = ProfileSets(self.dmd) devices = self.ruleset.getCurrentDeviceMatches() + self.ruleset.getPotentialDeviceMatches() setmgr.evalRuleComponents(self,devices)