Skip to content

Commit 3a6bbe9

Browse files
committed
_make_subscription() renames
1 parent f88f266 commit 3a6bbe9

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

osg_configure/configure_modules/gratia.py

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,13 @@ def configure(self, attributes):
255255
else:
256256
continue
257257

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+
)
263265
if probe == 'condor':
264266
self._configure_condor_probe()
265267
elif probe == 'pbs':
@@ -320,7 +322,7 @@ def check_attributes(self, attributes):
320322
self.log("GratiaConfiguration.check_attributes completed")
321323
return status
322324

323-
def _subscription_present(self, probe_file, probe_host):
325+
def _subscription_present(self, probe_file, remote_host):
324326
"""
325327
Check probe file to see if subscription to the host is present
326328
"""
@@ -330,8 +332,8 @@ def _subscription_present(self, probe_file, probe_host):
330332
for element in elements:
331333
try:
332334
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))
335337
return True
336338
# pylint: disable-msg=W0703
337339
except Exception as e:
@@ -340,30 +342,41 @@ def _subscription_present(self, probe_file, probe_host):
340342
self.log("GratiaConfiguration._subscription_present completed")
341343
return False
342344

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+
345355
Check to see if a given probe has the correct subscription and if not
346356
make it.
347357
"""
348358

349-
self.log("GratiaConfiguration._make_subscription started")
359+
self.log("GratiaConfiguration._subscribe_probe_to_remote_host started")
350360

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):
352365
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")
354367
return True
355368

356369
if probe == 'gridftp':
357370
probe = 'gridftp-transfer'
358371

359372
try:
360373
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)
363376
buf = self.replace_setting(buf, 'Grid', self.grid_group)
364377
buf = self.replace_setting(buf, 'EnableProbe', '1')
365378
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)
367380

368381
if not utilities.atomic_write(probe_file, buf, mode=0o644):
369382
self.log("Error while configuring gratia probes: " +
@@ -376,7 +389,7 @@ def _make_subscription(self, probe, probe_file, probe_host, site, hostname):
376389
level=logging.ERROR)
377390
raise exceptions.ConfigureError("Error configuring gratia")
378391

379-
self.log("GratiaConfiguration._make_subscription completed")
392+
self.log("GratiaConfiguration._subscribe_probe_to_remote_host completed")
380393
return True
381394

382395
def module_name(self):

0 commit comments

Comments
 (0)