def assert_node_features(self, feature_names, node_names, mod_op='replace'): for feat in feature_names: if not feat in self.feat_names: emsg = "Feature %s not in config store" % (feat) raise Exception(emsg) # apply feature list to nodes for name in node_names: node_obj = WallabyHelpers.get_node(self.session, self.config_store, name) group_name = WallabyHelpers.get_id_group_name(node_obj, self.session) group_obj = WallabyHelpers.get_group(self.session, self.config_store, group_name) if mod_op == 'insert': result = group_obj.modifyFeatures('replace', feature_names + group_obj.features, {}) else: result = group_obj.modifyFeatures(mod_op, feature_names, {}) if result.status != 0: sys.stderr.write("Failed to set features for %s: (%d, %s)\n" % (name, result.status, result.text)) raise WallabyStoreError(result.text)
def clear_nodes(self, node_names): for name in node_names: node_obj = WallabyHelpers.get_node(self.session, self.config_store, name) result = node_obj.modifyMemberships('replace', [], {}) if result.status != 0: sys.stderr.write("Failed to clear groups from %s: (%d, %s)\n" % (name, result.status, result.text)) raise WallabyStoreError("Failed to clear groups") group_name = WallabyHelpers.get_id_group_name(node_obj, self.session) group_obj = WallabyHelpers.get_group(self.session, self.config_store, group_name) result = group_obj.modifyFeatures('replace', [], {}) if result.status != 0: sys.stderr.write("Failed to clear features from %s: (%d, %s)\n" % (name, result.status, result.text)) raise WallabyStoreError("Failed to clear features") result = group_obj.modifyParams('replace', {}, {}) if result.status != 0: sys.stderr.write("Failed to clear params from %s: (%d, %s)\n" % (name, result.status, result.text)) raise WallabyStoreError("Failed to clear params")
def list_nodes(self, with_all_feats=None, without_any_feats=None, with_all_groups=None, without_any_groups=None, checkin_since=None): r = [] for node in self.node_names: node_obj = WallabyHelpers.get_node(self.session, self.config_store, node) sys.stdout.write(" list_nodes: node=%s checkin= %s\n" % (node, node_obj.last_checkin)) if (checkin_since != None) and ((node_obj.last_checkin / 1000000) < checkin_since): continue nodefeats = [] if (with_all_feats != None) or (without_any_feats != None): nodefeats = WallabyHelpers.get_node_features(node_obj, self.session, self.config_store) if (with_all_feats != None) and (False in [x in nodefeats for x in with_all_feats]): continue if (without_any_feats != None) and (True in [x in nodefeats for x in without_any_feats]): continue nodegroups = [] if (with_all_groups != None) or (without_any_groups != None): nodegroups = [WallabyHelpers.get_id_group_name(node_obj, self.session)] + node_obj.memberships + ['+++DEFAULT'] if (with_all_groups != None) and (False in [x in nodegroups for x in with_all_groups]): continue if (without_any_groups != None) and (True in [x in nodegroups for x in without_any_groups]): continue r += [node] return r
env['_CONDOR_CONFIGD_CHECK_INTERVAL'] = '0' env['_CONDOR_QMF_BROKER_HOST'] = '127.0.0.1' env['_CONDOR_QMF_BROKER_PORT'] = '5672' env['_CONDOR_CONFIGD_OVERRIDE_DIR'] = override_dir env['_CONDOR_LOG'] = '.' env['PATH'] = os.environ['PATH'] cmd = shlex.split('../condor_configd -d -l %s -m %s -h %s' % (log_file, config_file, nodename)) os.execve(cmd[0], cmd, env) sys.exit(0) # The configd performs a checkin within 10 seconds on startup time.sleep(15) # Add features and groups to the node WallabyHelpers.add_group(session, store, 'TestGroup') grp_name = WallabyHelpers.get_id_group_name(node, session) node_grp = WallabyHelpers.get_group(session, store, grp_name) node.modifyMemberships('add', ['TestGroup'], {}) node_grp.modifyFeatures('add', ['TestFeature'], {}) node.update() node_grp.update() # Verify older config version causes config retrieval print 'Testing older version causes config retrieval: \t\t\t', node.setLastUpdatedVersion(version-1) store.raiseEvent([nodename]) time.sleep(10) old_version = version try: version = int(read_condor_config('WALLABY', ['CONFIG_VERSION'], environ={'CONDOR_CONFIG':config_file}, permit_param_only = False)['config_version']) except: