Skip to content

Commit 7125e73

Browse files
committed
Remove extra configuration for old batch system probes
1 parent 4b08148 commit 7125e73

File tree

1 file changed

+0
-207
lines changed

1 file changed

+0
-207
lines changed

osg_configure/configure_modules/gratia.py

Lines changed: 0 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@
44
import re
55
import sys
66
import logging
7-
import subprocess
87
from xml.sax import saxutils
98

109
from osg_configure.modules import exceptions
1110
from osg_configure.modules import utilities
1211
from osg_configure.modules import validation
1312
from osg_configure.modules import configfile
1413
from osg_configure.modules.baseconfiguration import BaseConfiguration
15-
from osg_configure.configure_modules.condor import CondorConfiguration
16-
from osg_configure.configure_modules.sge import SGEConfiguration
17-
from osg_configure.configure_modules.slurm import SlurmConfiguration
1814

1915
__all__ = ['GratiaConfiguration']
2016

@@ -244,7 +240,6 @@ def check_attributes(self, attributes):
244240
self.log("GratiaConfiguration.check_attributes completed")
245241
return True
246242
status = self._check_servers()
247-
status &= self._verify_gratia_dirs_for_condor_probe()
248243
self.log("GratiaConfiguration.check_attributes completed")
249244
return status
250245

@@ -415,119 +410,6 @@ def _configure_default_ce(self, configuration):
415410

416411
return True
417412

418-
def _configure_condor_probe(self):
419-
"""
420-
Do condor probe specific configuration
421-
"""
422-
423-
config_location = GRATIA_CONFIG_FILES['condor']
424-
buf = open(config_location, "r", encoding="latin-1").read()
425-
settings = self._probe_config['condor']
426-
buf = self.replace_setting(buf, 'CondorLocation', settings['condor_location'])
427-
buf = self.replace_setting(buf, 'CondorConfig', settings['condor_config'])
428-
if not utilities.atomic_write(config_location, buf):
429-
return False
430-
return True
431-
432-
def _configure_pbs_probe(self):
433-
"""
434-
Do pbs probe specific configuration
435-
"""
436-
if (self._probe_config['pbs']['accounting_log_directory'] is None or
437-
self._probe_config['pbs']['accounting_log_directory'] == ''):
438-
return True
439-
accounting_dir = self._probe_config['pbs']['accounting_log_directory']
440-
if not validation.valid_directory(accounting_dir):
441-
self.log("PBS accounting log not present, PBS gratia probe not configured",
442-
level=logging.ERROR,
443-
option='accounting_log_directory',
444-
section='PBS')
445-
return True
446-
447-
config_location = GRATIA_CONFIG_FILES['pbs']
448-
buf = open(config_location, "r", encoding="latin-1").read()
449-
buf = self.replace_setting(buf, 'pbsAcctLogDir', accounting_dir, xml_file=False)
450-
buf = self.replace_setting(buf, 'lrmsType', 'pbs', xml_file=False)
451-
if not utilities.atomic_write(config_location, buf):
452-
return False
453-
return True
454-
455-
def _configure_lsf_probe(self):
456-
"""
457-
Do lsf probe specific configuration
458-
"""
459-
if (self._probe_config['lsf']['log_directory'] is None or
460-
self._probe_config['lsf']['log_directory'] == ''):
461-
self.log("LSF accounting log directory not given, LSF gratia probe not configured",
462-
level=logging.ERROR,
463-
option='log_directory',
464-
section='LSF')
465-
return True
466-
log_directory = self._probe_config['lsf']['log_directory']
467-
if not validation.valid_directory(log_directory):
468-
self.log("LSF accounting log not present, LSF gratia probe not configured",
469-
level=logging.ERROR,
470-
option='log_directory',
471-
section='LSF')
472-
return True
473-
config_location = GRATIA_CONFIG_FILES['lsf']
474-
buf = open(config_location, "r", encoding="latin-1").read()
475-
buf = self.replace_setting(buf, 'lsfAcctLogDir', log_directory, xml_file=False)
476-
477-
# setup lsfBinDir
478-
if (self._probe_config['lsf']['lsf_location'] is None or
479-
self._probe_config['lsf']['lsf_location'] == ''):
480-
self.log("LSF location not given, lsf gratia probe not configured",
481-
level=logging.ERROR,
482-
option='lsf_location',
483-
section='LSF')
484-
return True
485-
lsf_bin_dir = os.path.join(self._probe_config['lsf']['lsf_location'], 'bin')
486-
buf = self.replace_setting(buf, 'lsfBinDir', lsf_bin_dir, xml_file=False)
487-
buf = self.replace_setting(buf, 'lrmsType', 'lsf', xml_file=False)
488-
if not utilities.atomic_write(config_location, buf):
489-
return False
490-
return True
491-
492-
def _configure_sge_probe(self):
493-
"""
494-
Do SGE probe specific configuration
495-
"""
496-
accounting_path = self._probe_config['sge']['sge_accounting_file']
497-
config_location = GRATIA_CONFIG_FILES['sge']
498-
buf = open(config_location, "r", encoding="latin-1").read()
499-
buf = self.replace_setting(buf, 'SGEAccountingFile', accounting_path)
500-
if not utilities.atomic_write(config_location, buf):
501-
return False
502-
return True
503-
504-
def _configure_slurm_probe(self):
505-
"""
506-
Do SLURM probe specific configuration
507-
"""
508-
config_location = GRATIA_CONFIG_FILES['slurm']
509-
buf = open(config_location, "r", encoding="latin-1").read()
510-
511-
settings = self._probe_config['slurm']
512-
if not validation.valid_file(settings['db_pass']):
513-
self.log("Slurm DB password file not present",
514-
level=logging.ERROR,
515-
option='db_pass',
516-
section='SLURM')
517-
return True
518-
519-
buf = self.replace_setting(buf, 'SlurmDbHost', settings['db_host'])
520-
buf = self.replace_setting(buf, 'SlurmDbPort', settings['db_port'])
521-
buf = self.replace_setting(buf, 'SlurmDbUser', settings['db_user'])
522-
buf = self.replace_setting(buf, 'SlurmDbPasswordFile', settings['db_pass'])
523-
buf = self.replace_setting(buf, 'SlurmDbName', settings['db_name'])
524-
buf = self.replace_setting(buf, 'SlurmCluster', settings['cluster'])
525-
buf = self.replace_setting(buf, 'SlurmLocation', settings['location'])
526-
527-
if not utilities.atomic_write(config_location, buf):
528-
return False
529-
return True
530-
531413
def _configure_htcondor_ce_probe(self):
532414
"""
533415
Do HTCondor-CE probe specific configuration
@@ -540,95 +422,6 @@ def _configure_htcondor_ce_probe(self):
540422
if not utilities.atomic_write(config_location, buf):
541423
return False
542424
return True
543-
544-
545-
def _verify_gratia_dirs_for_condor_probe(self):
546-
"""
547-
Verify that the condor per_job_history directory and the DataFolder
548-
directory are the same and warn if admin if the two don't match
549-
"""
550-
551-
valid = True
552-
if 'condor' not in self._probe_config:
553-
# Don't need this for non-condor probes
554-
return valid
555-
condor_config_val_bin = os.path.join(self._probe_config['condor']['condor_location'],
556-
"bin",
557-
"condor_config_val")
558-
if not os.path.exists(condor_config_val_bin):
559-
self.log("While checking gratia parameters: Unable to find condor_config_val binary (looked for %s).\n"
560-
"In the [Condor] section of your configuration, set condor_location such that "
561-
"(condor_location)/bin/condor_config_val is the location of the condor_config_val binary."
562-
% condor_config_val_bin,
563-
level=logging.ERROR)
564-
return False
565-
566-
config_location = GRATIA_CONFIG_FILES['condor']
567-
contents = open(config_location, "r", encoding="latin-1").read()
568-
re_obj = re.compile(r'(?m)^\s*DataFolder\s*=(.*)\s*$')
569-
match = re_obj.search(contents)
570-
if match is not None:
571-
data_folder = match.group(1)
572-
data_folder = data_folder.strip('" \t')
573-
# PER_JOB_HISTORY_DIR comes from the schedd, so if condor's not
574-
# running, we can't get a value (SOFTWARE-1564)
575-
history_dir = self._get_condor_history_dir(condor_config_val_bin)
576-
if not history_dir:
577-
self.log("Could not verify DataFolder correctness: unable to get PER_JOB_HISTORY_DIR. "
578-
"This may be caused by the condor schedd not running, or by PER_JOB_HISTORY_DIR "
579-
"not being defined.", level=logging.WARNING)
580-
else:
581-
# os.path.samefile will die if the paths don't exist so check that explicitly (SOFTWARE-1735)
582-
if not os.path.exists(data_folder):
583-
self.log("DataFolder setting in %s (%s) points to a nonexistant location" % (
584-
config_location, data_folder),
585-
level=logging.ERROR)
586-
valid = False
587-
elif not os.path.exists(history_dir):
588-
self.log("Condor PER_JOB_HISTORY_DIR %s points to a nonexistant location" % history_dir,
589-
level=logging.ERROR)
590-
valid = False
591-
else:
592-
try:
593-
if not os.path.samefile(data_folder, history_dir):
594-
self.log("DataFolder setting in %s (%s) and condor PER_JOB_HISTORY_DIR %s "
595-
"do not match, these settings must match!" % (config_location,
596-
data_folder,
597-
history_dir),
598-
level=logging.ERROR)
599-
valid = False
600-
except OSError as e:
601-
self.log("Error comparing DataFolder setting in %s (%s) and condor PER_JOB_HISTORY_DIR %s:\n%s"
602-
% (config_location, data_folder, history_dir, e),
603-
level=logging.ERROR)
604-
valid = False
605-
606-
# Per Gratia-126 DataFolder must end in / otherwise gratia won't find certinfo files
607-
if not data_folder.endswith('/'):
608-
self.log("DataFolder setting in %s must end in a /" % config_location,
609-
level=logging.ERROR)
610-
valid = False
611-
612-
return valid
613-
614-
def _get_condor_history_dir(self, condor_config_val_bin):
615-
cmd = [condor_config_val_bin, '-schedd', 'PER_JOB_HISTORY_DIR']
616-
try:
617-
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="latin-1")
618-
(history_dir, errtext) = process.communicate()
619-
if process.returncode != 0:
620-
self.log("While checking gratia parameters: %s failed. Output follows:\n%s" % (condor_config_val_bin,
621-
errtext),
622-
level=logging.INFO)
623-
return None
624-
except OSError as err:
625-
self.log("While checking gratia parameters: Error running %s: %s" % (condor_config_val_bin, str(err)),
626-
level=logging.INFO)
627-
return None
628-
history_dir = history_dir.strip()
629-
if history_dir.startswith('Not defined'):
630-
return None
631-
return history_dir
632425

633426
@staticmethod
634427
def replace_setting(buf, setting, value, xml_file=True):

0 commit comments

Comments
 (0)