Skip to content

Commit 7666754

Browse files
committed
buncha renames so I can understand what's actually going on
1 parent a866ba2 commit 7666754

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

osg_configure/configure_modules/gratia.py

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ def __init__(self, *args, **kwargs):
6262
default_value='',
6363
required=configfile.Option.OPTIONAL)}
6464

65-
# Dictionary holding probe settings, the probe's name is used as the key and the
66-
# server the probe should report to is the value.
67-
self.enabled_probe_settings = {}
65+
# Dictionary of which host[:port] to send probe data to, keyed by probe.
66+
self.enabled_probe_hosts = {}
6867

6968
# defaults for itb and production use
7069
self._itb_defaults = {'probes':
@@ -117,8 +116,8 @@ def parse_configuration(self, configuration):
117116
self._itb_defaults['probes']
118117

119118
# grab configuration information for various jobmanagers
120-
probes = self.get_installed_probes()
121-
for probe in probes:
119+
probes_iter = self.get_installed_probe_config_files().keys()
120+
for probe in probes_iter:
122121
if probe == 'condor':
123122
self._probe_config['condor'] = {'condor_location':
124123
CondorConfiguration.get_condor_location(configuration),
@@ -197,7 +196,7 @@ def parse_configuration(self, configuration):
197196
self.log('GratiaConfiguration.parse_configuration completed')
198197
return
199198

200-
self._parse_probes(self.options['probes'].value)
199+
self._set_enabled_probe_host(self.options['probes'].value)
201200
self.log('GratiaConfiguration.parse_configuration completed')
202201

203202
def configure(self, attributes):
@@ -236,27 +235,28 @@ def configure(self, attributes):
236235
return False
237236

238237
hostname = attributes['OSG_HOSTNAME']
239-
probe_list = self.get_installed_probes()
240-
for probe in probe_list:
238+
probe_config_files = self.get_installed_probe_config_files()
239+
probes_iter = probe_config_files.keys()
240+
for probe in probes_iter:
241241
if probe in self._job_managers:
242242
if probe not in self._probe_config:
243243
# Probe is installed but we don't have configuration for it
244244
# might be due to pbs-lsf probe sharing or relevant job
245245
# manager is not shared
246246
continue
247247

248-
if 'jobmanager' in self.enabled_probe_settings:
249-
probe_host = self.enabled_probe_settings['jobmanager']
248+
if 'jobmanager' in self.enabled_probe_hosts:
249+
probe_host = self.enabled_probe_hosts['jobmanager']
250250
else:
251251
continue
252252
else:
253-
if probe in self.enabled_probe_settings:
254-
probe_host = self.enabled_probe_settings[probe]
253+
if probe in self.enabled_probe_hosts:
254+
probe_host = self.enabled_probe_hosts[probe]
255255
else:
256256
continue
257257

258258
self._make_subscription(probe,
259-
probe_list[probe],
259+
probe_config_files[probe],
260260
probe_host,
261261
self.options['resource'].value,
262262
hostname)
@@ -278,9 +278,9 @@ def configure(self, attributes):
278278

279279
# pylint: disable-msg=R0201
280280
@staticmethod
281-
def get_installed_probes():
282-
"""
283-
Check for probes that have been installed and return a list of these probes installed
281+
def get_installed_probe_config_files():
282+
"""Return a mapping of probe name -> ProbeConfig file.
283+
Note that "pbs" and "lsf" have the same probe.
284284
"""
285285

286286
probes = {}
@@ -316,7 +316,7 @@ def check_attributes(self, attributes):
316316
self.log("GratiaConfiguration.check_attributes completed")
317317
return True
318318
status = self._check_servers()
319-
status &= self._verify_gratia_dirs()
319+
status &= self._verify_gratia_dirs_for_condor_probe()
320320
self.log("GratiaConfiguration.check_attributes completed")
321321
return status
322322

@@ -395,11 +395,11 @@ def _check_servers(self):
395395
e.g. server1.example.com,server2.example.com:2188
396396
"""
397397
valid = True
398-
for probe in self.enabled_probe_settings:
398+
for probe in self.enabled_probe_hosts:
399399
if probe == 'metric':
400400
sys.stdout.write(self.metric_probe_deprecation + "\n")
401401
self.log(self.metric_probe_deprecation, level=logging.WARNING)
402-
server = self.enabled_probe_settings[probe].split(':')[0]
402+
server = self.enabled_probe_hosts[probe].split(':')[0]
403403
if not validation.valid_domain(server, False):
404404
err_mesg = "The server specified for probe %s is not " % probe
405405
err_mesg += "a valid domain: %s" % server
@@ -409,8 +409,8 @@ def _check_servers(self):
409409
err_mesg = "The server specified for probe %s does not " % probe
410410
err_mesg += "resolve: %s" % server
411411
self.log(err_mesg, level=logging.WARNING)
412-
if server != self.enabled_probe_settings[probe]:
413-
port = self.enabled_probe_settings[probe].split(':')[1]
412+
if server != self.enabled_probe_hosts[probe]:
413+
port = self.enabled_probe_hosts[probe].split(':')[1]
414414
try:
415415
temp = int(port)
416416
if temp < 0:
@@ -422,10 +422,11 @@ def _check_servers(self):
422422
level=logging.ERROR)
423423
return valid
424424

425-
def _parse_probes(self, probes):
426-
"""
427-
Parse a list of probes and set the list of enabled probes for this
428-
configuration
425+
def _set_enabled_probe_host(self, probes):
426+
"""Parse a list of probes (taken from the Gratia.probes option)
427+
and set the `enabled_probe_hosts`, which is a probe name -> upload host
428+
mapping (with an optional port).
429+
Treat "gridftp" as an alias for "gridftp-transfer".
429430
"""
430431

431432
for probe_entry in probes.split(','):
@@ -434,9 +435,9 @@ def _parse_probes(self, probes):
434435
if probe_name == 'gridftp':
435436
probe_name = 'gridftp-transfer'
436437
if len(tmp[1:]) == 1:
437-
self.enabled_probe_settings[probe_name] = tmp[1]
438+
self.enabled_probe_hosts[probe_name] = tmp[1]
438439
else:
439-
self.enabled_probe_settings[probe_name] = ':'.join(tmp[1:])
440+
self.enabled_probe_hosts[probe_name] = ':'.join(tmp[1:])
440441

441442
def _auto_configure(self, configuration):
442443
"""
@@ -471,7 +472,7 @@ def _auto_configure(self, configuration):
471472
'OSG or OSG-ITB')
472473

473474
self.options['probes'].value = probes
474-
self._parse_probes(probes)
475+
self._set_enabled_probe_host(probes)
475476

476477
return True
477478

@@ -602,7 +603,7 @@ def _configure_htcondor_ce_probe(self):
602603
return True
603604

604605

605-
def _verify_gratia_dirs(self):
606+
def _verify_gratia_dirs_for_condor_probe(self):
606607
"""
607608
Verify that the condor per_job_history directory and the DataFolder
608609
directory are the same and warn if admin if the two don't match
@@ -632,7 +633,7 @@ def _verify_gratia_dirs(self):
632633
data_folder = data_folder.strip('" \t')
633634
# PER_JOB_HISTORY_DIR comes from the schedd, so if condor's not
634635
# running, we can't get a value (SOFTWARE-1564)
635-
history_dir = self._get_history_dir(condor_config_val_bin)
636+
history_dir = self._get_condor_history_dir(condor_config_val_bin)
636637
if not history_dir:
637638
self.log("Could not verify DataFolder correctness: unable to get PER_JOB_HISTORY_DIR. "
638639
"This may be caused by the condor schedd not running, or by PER_JOB_HISTORY_DIR "
@@ -671,7 +672,7 @@ def _verify_gratia_dirs(self):
671672

672673
return valid
673674

674-
def _get_history_dir(self, condor_config_val_bin):
675+
def _get_condor_history_dir(self, condor_config_val_bin):
675676
cmd = [condor_config_val_bin, '-schedd', 'PER_JOB_HISTORY_DIR']
676677
try:
677678
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="latin-1")

0 commit comments

Comments
 (0)