@@ -62,9 +62,8 @@ def __init__(self, *args, **kwargs):
62
62
default_value = '' ,
63
63
required = configfile .Option .OPTIONAL )}
64
64
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 = {}
68
67
69
68
# defaults for itb and production use
70
69
self ._itb_defaults = {'probes' :
@@ -117,8 +116,8 @@ def parse_configuration(self, configuration):
117
116
self ._itb_defaults ['probes' ]
118
117
119
118
# 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 :
122
121
if probe == 'condor' :
123
122
self ._probe_config ['condor' ] = {'condor_location' :
124
123
CondorConfiguration .get_condor_location (configuration ),
@@ -197,7 +196,7 @@ def parse_configuration(self, configuration):
197
196
self .log ('GratiaConfiguration.parse_configuration completed' )
198
197
return
199
198
200
- self ._parse_probes (self .options ['probes' ].value )
199
+ self ._set_enabled_probe_host (self .options ['probes' ].value )
201
200
self .log ('GratiaConfiguration.parse_configuration completed' )
202
201
203
202
def configure (self , attributes ):
@@ -236,27 +235,28 @@ def configure(self, attributes):
236
235
return False
237
236
238
237
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 :
241
241
if probe in self ._job_managers :
242
242
if probe not in self ._probe_config :
243
243
# Probe is installed but we don't have configuration for it
244
244
# might be due to pbs-lsf probe sharing or relevant job
245
245
# manager is not shared
246
246
continue
247
247
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' ]
250
250
else :
251
251
continue
252
252
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 ]
255
255
else :
256
256
continue
257
257
258
258
self ._make_subscription (probe ,
259
- probe_list [probe ],
259
+ probe_config_files [probe ],
260
260
probe_host ,
261
261
self .options ['resource' ].value ,
262
262
hostname )
@@ -278,9 +278,9 @@ def configure(self, attributes):
278
278
279
279
# pylint: disable-msg=R0201
280
280
@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.
284
284
"""
285
285
286
286
probes = {}
@@ -316,7 +316,7 @@ def check_attributes(self, attributes):
316
316
self .log ("GratiaConfiguration.check_attributes completed" )
317
317
return True
318
318
status = self ._check_servers ()
319
- status &= self ._verify_gratia_dirs ()
319
+ status &= self ._verify_gratia_dirs_for_condor_probe ()
320
320
self .log ("GratiaConfiguration.check_attributes completed" )
321
321
return status
322
322
@@ -395,11 +395,11 @@ def _check_servers(self):
395
395
e.g. server1.example.com,server2.example.com:2188
396
396
"""
397
397
valid = True
398
- for probe in self .enabled_probe_settings :
398
+ for probe in self .enabled_probe_hosts :
399
399
if probe == 'metric' :
400
400
sys .stdout .write (self .metric_probe_deprecation + "\n " )
401
401
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 ]
403
403
if not validation .valid_domain (server , False ):
404
404
err_mesg = "The server specified for probe %s is not " % probe
405
405
err_mesg += "a valid domain: %s" % server
@@ -409,8 +409,8 @@ def _check_servers(self):
409
409
err_mesg = "The server specified for probe %s does not " % probe
410
410
err_mesg += "resolve: %s" % server
411
411
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 ]
414
414
try :
415
415
temp = int (port )
416
416
if temp < 0 :
@@ -422,10 +422,11 @@ def _check_servers(self):
422
422
level = logging .ERROR )
423
423
return valid
424
424
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".
429
430
"""
430
431
431
432
for probe_entry in probes .split (',' ):
@@ -434,9 +435,9 @@ def _parse_probes(self, probes):
434
435
if probe_name == 'gridftp' :
435
436
probe_name = 'gridftp-transfer'
436
437
if len (tmp [1 :]) == 1 :
437
- self .enabled_probe_settings [probe_name ] = tmp [1 ]
438
+ self .enabled_probe_hosts [probe_name ] = tmp [1 ]
438
439
else :
439
- self .enabled_probe_settings [probe_name ] = ':' .join (tmp [1 :])
440
+ self .enabled_probe_hosts [probe_name ] = ':' .join (tmp [1 :])
440
441
441
442
def _auto_configure (self , configuration ):
442
443
"""
@@ -471,7 +472,7 @@ def _auto_configure(self, configuration):
471
472
'OSG or OSG-ITB' )
472
473
473
474
self .options ['probes' ].value = probes
474
- self ._parse_probes (probes )
475
+ self ._set_enabled_probe_host (probes )
475
476
476
477
return True
477
478
@@ -602,7 +603,7 @@ def _configure_htcondor_ce_probe(self):
602
603
return True
603
604
604
605
605
- def _verify_gratia_dirs (self ):
606
+ def _verify_gratia_dirs_for_condor_probe (self ):
606
607
"""
607
608
Verify that the condor per_job_history directory and the DataFolder
608
609
directory are the same and warn if admin if the two don't match
@@ -632,7 +633,7 @@ def _verify_gratia_dirs(self):
632
633
data_folder = data_folder .strip ('" \t ' )
633
634
# PER_JOB_HISTORY_DIR comes from the schedd, so if condor's not
634
635
# 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 )
636
637
if not history_dir :
637
638
self .log ("Could not verify DataFolder correctness: unable to get PER_JOB_HISTORY_DIR. "
638
639
"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):
671
672
672
673
return valid
673
674
674
- def _get_history_dir (self , condor_config_val_bin ):
675
+ def _get_condor_history_dir (self , condor_config_val_bin ):
675
676
cmd = [condor_config_val_bin , '-schedd' , 'PER_JOB_HISTORY_DIR' ]
676
677
try :
677
678
process = subprocess .Popen (cmd , stdout = subprocess .PIPE , stderr = subprocess .PIPE , encoding = "latin-1" )
0 commit comments