def whatChanged(self, old, new): oc = self.cm.fetch_json_resource( "/config/node/%s" % urllib.quote_plus(self.name), {"commit": old}, {}) nc = self.cm.fetch_json_resource( "/config/node/%s" % urllib.quote_plus(self.name), {"commit": new}, {}) ock = set(oc) nck = set(nc) params = set([ p for p in (ock | nck) if p not in ock or p not in nck or oc[p] != nc[p] ]) - set(["WALLABY_CONFIG_VERSION"]) mc_params = set( [p for p in params if store_singleton().getParam(p).must_change]) subsystems = [ store_singleton().getSubsys(sub) for sub in self.cm.list_objects("subsystem") ] restart, reconfig = [], [] for ss in subsystems: ss.refresh ssp = set(ss.parameters) if ssp.intersection(mc_params): restart.append(ss.name) elif ssp.intersection(params): reconfig.append(ss.name) return [list(params), restart, reconfig]
def modifyLabels(self, op, labels, **options): thestore = store_singleton() memberships = self.memberships current_labels = self.getLabels() label_set = set(current_labels + [PARTITION_GROUP]) new_labels = [] if op == "ADD": new_labels = current_labels + labels pass elif op == "REPLACE": new_labels = labels pass elif op == "REMOVE": new_labels = [label for label in current_labels if label not in labels] else: raise NotImplementedError("modifyLabels: operation " + op + " not understood") just_memberships = [grp for grp in memberships if grp not in label_set] new_memberships = uniq(just_memberships + [PARTITION_GROUP] + new_labels) if "ensure_partition_group" in options and options["ensure_partition_group"] is not False: if thestore is None: raise RuntimeError("store singleton must be initialized before using the ensure_partition_group option") thestore.getPartitionGroup() if "create_missing_labels" in options and options["create_missing_labels"] is not False: if thestore is None: raise RuntimeError("store singleton must be initialized before using the create_missing_labels option") for missing_label in thestore.checkGroupValidity(new_labels): thestore.addLabel(missing_label) return self.modifyMemberships("REPLACE", new_memberships, {})
def whatChanged(self, old, new): oc = self.cm.fetch_json_resource("/config/node/%s" % urllib.quote_plus(self.name), {"commit":old}, {}) nc = self.cm.fetch_json_resource("/config/node/%s" % urllib.quote_plus(self.name), {"commit":new}, {}) ock = set(oc) nck = set(nc) params = set([p for p in (ock | nck) if p not in ock or p not in nck or oc[p] != nc[p]]) - set(["WALLABY_CONFIG_VERSION"]) mc_params = set([p for p in params if store_singleton().getParam(p).must_change]) subsystems = [store_singleton().getSubsys(sub) for sub in self.cm.list_objects("subsystem")] restart, reconfig = [], [] for ss in subsystems: ss.refresh ssp = set(ss.parameters) if ssp.intersection(mc_params): restart.append(ss.name) elif ssp.intersection(params): reconfig.append(ss.name) return [list(params), restart, reconfig]
def modifyLabels(self, op, labels, **options): thestore = store_singleton() memberships = self.memberships current_labels = self.getLabels() label_set = set(current_labels + [PARTITION_GROUP]) new_labels = [] if op == "ADD": new_labels = current_labels + labels pass elif op == "REPLACE": new_labels = labels pass elif op == "REMOVE": new_labels = [ label for label in current_labels if label not in labels ] else: raise NotImplementedError("modifyLabels: operation " + op + " not understood") just_memberships = [grp for grp in memberships if grp not in label_set] new_memberships = uniq(just_memberships + [PARTITION_GROUP] + new_labels) if "ensure_partition_group" in options and options[ "ensure_partition_group"] is not False: if thestore is None: raise RuntimeError( "store singleton must be initialized before using the ensure_partition_group option" ) thestore.getPartitionGroup() if "create_missing_labels" in options and options[ "create_missing_labels"] is not False: if thestore is None: raise RuntimeError( "store singleton must be initialized before using the create_missing_labels option" ) for missing_label in thestore.checkGroupValidity(new_labels): thestore.addLabel(missing_label) return self.modifyMemberships("REPLACE", new_memberships, {})