@@ -255,11 +255,13 @@ def configure(self, attributes):
255
255
else :
256
256
continue
257
257
258
- self ._make_subscription (probe ,
259
- probe_config_files [probe ],
260
- probe_host ,
261
- self .options ['resource' ].value ,
262
- hostname )
258
+ self ._subscribe_probe_to_remote_host (
259
+ probe ,
260
+ probe_config_files [probe ],
261
+ remote_host = probe_host ,
262
+ local_resource = self .options ['resource' ].value ,
263
+ local_host = hostname
264
+ )
263
265
if probe == 'condor' :
264
266
self ._configure_condor_probe ()
265
267
elif probe == 'pbs' :
@@ -320,7 +322,7 @@ def check_attributes(self, attributes):
320
322
self .log ("GratiaConfiguration.check_attributes completed" )
321
323
return status
322
324
323
- def _subscription_present (self , probe_file , probe_host ):
325
+ def _subscription_present (self , probe_file , remote_host ):
324
326
"""
325
327
Check probe file to see if subscription to the host is present
326
328
"""
@@ -330,8 +332,8 @@ def _subscription_present(self, probe_file, probe_host):
330
332
for element in elements :
331
333
try :
332
334
if (element .getAttribute ('EnableProbe' ) == 1 and
333
- element .getAttribute ('SOAPHost' ) == probe_host ):
334
- self .log ("Subscription for %s in %s found" % (probe_host , probe_file ))
335
+ element .getAttribute ('SOAPHost' ) == remote_host ):
336
+ self .log ("Subscription for %s in %s found" % (remote_host , probe_file ))
335
337
return True
336
338
# pylint: disable-msg=W0703
337
339
except Exception as e :
@@ -340,30 +342,41 @@ def _subscription_present(self, probe_file, probe_host):
340
342
self .log ("GratiaConfiguration._subscription_present completed" )
341
343
return False
342
344
343
- def _make_subscription (self , probe , probe_file , probe_host , site , hostname ):
344
- """
345
+ def _subscribe_probe_to_remote_host (
346
+ self , probe , probe_file , remote_host , local_resource , local_host ):
347
+ """Subscribe the given probe to the given remote host if necessary --
348
+ this means:
349
+ - Enable the probe
350
+ - Set the local host name in the probe config (in ProbeName)
351
+ - Set the local resource name (in SiteName)
352
+ - Set the grid group (in Grid)
353
+ - Set the *Host settings to the the remote host
354
+
345
355
Check to see if a given probe has the correct subscription and if not
346
356
make it.
347
357
"""
348
358
349
- self .log ("GratiaConfiguration._make_subscription started" )
359
+ self .log ("GratiaConfiguration._subscribe_probe_to_remote_host started" )
350
360
351
- if self ._subscription_present (probe_file , probe_host ):
361
+ # XXX This just checks EnableProbe and SOAPHost; should we check the other *Host
362
+ # settings or are we using SOAPHost as a "don't configure me" sentinel?
363
+ # -mat 2/19/21
364
+ if self ._subscription_present (probe_file , remote_host ):
352
365
self .log ("Subscription found %s probe, returning" % probe )
353
- self .log ("GratiaConfiguration._make_subscription completed" )
366
+ self .log ("GratiaConfiguration._subscribe_probe_to_remote_host completed" )
354
367
return True
355
368
356
369
if probe == 'gridftp' :
357
370
probe = 'gridftp-transfer'
358
371
359
372
try :
360
373
buf = open (probe_file , "r" , encoding = "latin-1" ).read ()
361
- buf = self .replace_setting (buf , 'ProbeName' , "%s:%s" % (probe , hostname ))
362
- buf = self .replace_setting (buf , 'SiteName' , site )
374
+ buf = self .replace_setting (buf , 'ProbeName' , "%s:%s" % (probe , local_host ))
375
+ buf = self .replace_setting (buf , 'SiteName' , local_resource )
363
376
buf = self .replace_setting (buf , 'Grid' , self .grid_group )
364
377
buf = self .replace_setting (buf , 'EnableProbe' , '1' )
365
378
for var in ['SSLHost' , 'SOAPHost' , 'SSLRegistrationHost' , 'CollectorHost' ]:
366
- buf = self .replace_setting (buf , var , probe_host )
379
+ buf = self .replace_setting (buf , var , remote_host )
367
380
368
381
if not utilities .atomic_write (probe_file , buf , mode = 0o644 ):
369
382
self .log ("Error while configuring gratia probes: " +
@@ -376,7 +389,7 @@ def _make_subscription(self, probe, probe_file, probe_host, site, hostname):
376
389
level = logging .ERROR )
377
390
raise exceptions .ConfigureError ("Error configuring gratia" )
378
391
379
- self .log ("GratiaConfiguration._make_subscription completed" )
392
+ self .log ("GratiaConfiguration._subscribe_probe_to_remote_host completed" )
380
393
return True
381
394
382
395
def module_name (self ):
0 commit comments