def find_entries_with_partial_id_match(config_xml, skip_disabled): """ Finds the bdii, ress and TeraGrid entries with partial matches. """ try: # Find all enabled config entries with ref ids config_dom = minidom.parse(config_xml) config_entries = infosys_lib.parse_entries(config_dom, skip_missing_ref_id=True, skip_disabled=skip_disabled) # Create an info systems list from factory config infosystems = infosys_lib.parse_info_systems(config_dom) has_ress = False for infosys in infosystems: if infosystems[infosys].lower() == 'ress': has_ress = True break if has_ress: # Update path with condor condor_path = infosys_lib.parse_condor_path(config_dom) os.environ["CONDOR_CONFIG"] = condor_path + "/etc/condor_config" condorExe.set_path(condor_path + "/bin", condor_path + "/sbin") except: print "Error parsing the the config file '%s', exiting the tool." % config_xml sys.exit(2) # Retrieve info systems entries bdii_entries = {} ress_entries = {} tg_entries = {} for infosys, type in infosystems.iteritems(): if type.lower() == 'bdii': bdii_entries.update(infosys_lib.query_bdii(infosys)) elif type.lower() == 'ress': ress_entries.update(infosys_lib.query_ress(infosys)) elif type.lower() == 'tg': tg_entries.update(infosys_lib.query_teragrid(infosys)) partial_match_bdii_entries = find_partial_id_match(bdii_entries, config_entries, 'bdii') partial_match_ress_entries = find_partial_id_match(ress_entries, config_entries, 'ress') partial_match_tg_entries = find_partial_id_match(tg_entries, config_entries, 'tg') return partial_match_bdii_entries, partial_match_ress_entries, partial_match_tg_entries
def test_parse_info_systems(self): """ Get a list of information systems listed in the entries for comparison """ # Test valid entries valid_file = open('valid.xml', 'w') valid_file.write('<glidein schedd_name="[email protected],[email protected]"> \ <entries> \ <entry name="valid_entry" \ enabled="True" \ gatekeeper="node.fnal.gov/jobmanager-condor" \ gridtype="gt2" \ rsl="(queue=default)" \ schedd_name="*****@*****.**" \ verbosity="std" \ work_dir="OSG"> \ <attrs> \ <attr name="CONDOR_ARCH" value="default"/> \ <attr name="GLEXEC_BIN" value="NONE"/> \ <attr name="GLIDEIN_Site" value="VE1"/> \ </attrs> \ <infosys_refs> \ </infosys_refs> \ </entry> \ <entry name="valid_entry2" \ enabled="True" \ gatekeeper="node2.fnal.gov/jobmanager-condor" \ gridtype="cream" \ schedd_name="*****@*****.**" \ verbosity="std" \ work_dir="."> \ <infosys_refs> \ <infosys_ref ref="GlueCEUniqueID=node.fnal.gov:2119/jobmanager-condor_default,Mds-Vo-name=TEST,Mds-Vo-name=local,o=grid" \ server="exp-bdii.cern.ch" type="BDII"/> \ </infosys_refs> \ </entry> \ </entries> \ <condor_tarball arch="default" base_dir="/opt/glidecondor" os="default" \ tar_file="/var/www/html/glidefactory/stage/glidein_v2plus/condor.tgz" version="default"/> \ </glidein>') valid_file.close() config_dom = minidom.parse('valid.xml') infosystems = parse_info_systems(config_dom) self.assertEqual(infosystems, {'exp-bdii.cern.ch' : 'BDII'}) os.remove('valid.xml') # Test no info systems found valid_file = open('missing_infosys.xml', 'w') valid_file.write('<glidein schedd_name="[email protected],[email protected]"> \ <entries> \ <entry name="valid_entry" \ enabled="True" \ gatekeeper="node.fnal.gov/jobmanager-condor" \ gridtype="gt2" \ rsl="(queue=default)" \ schedd_name="*****@*****.**" \ verbosity="std" \ work_dir="OSG"> \ <attrs> \ </attrs> \ <infosys_refs> \ </infosys_refs> \ </entry> \ </entries> \ <condor_tarball arch="default" base_dir="/opt/glidecondor" os="default" \ tar_file="/var/www/html/glidefactory/stage/glidein_v2plus/condor.tgz" version="default"/> \ </glidein>') valid_file.close() config_dom = minidom.parse('missing_infosys.xml') infosystems = parse_info_systems(config_dom) self.assertEqual(infosystems, {}) os.remove('missing_infosys.xml')