2
2
for CE collector info services"""
3
3
4
4
import re
5
- import configparser as ConfigParser
5
+ from configparser import ConfigParser
6
6
import subprocess
7
7
import logging
8
8
9
9
from osg_configure .modules import exceptions
10
10
from osg_configure .modules import utilities
11
11
from osg_configure .modules import configfile
12
12
from osg_configure .modules .baseconfiguration import BaseConfiguration
13
+ from osg_configure .modules import ce_attributes
13
14
from osg_configure .modules import subcluster
14
15
from osg_configure .modules import reversevomap
15
16
22
23
BAN_VOMS_MAPFILE = reversevomap .BAN_MAPFILE
23
24
BAN_MAPFILE = '/etc/grid-security/ban-mapfile'
24
25
25
- # BATCH_SYSTEMS here is both the config sections for the batch systems
26
- # and the values in the OSG_BatchSystems attribute since they are
27
- # coincidentally the same. If they ever change, make a mapping.
28
- BATCH_SYSTEMS = ['Condor' , 'LSF' , 'PBS' , 'SGE' , 'SLURM' ]
29
26
30
27
try :
31
28
import classad
@@ -55,13 +52,10 @@ def __init__(self, *args, **kwargs):
55
52
56
53
self .ce_collectors = []
57
54
self .ce_collector_required_rpms_installed = utilities .rpm_installed ('htcondor-ce' )
58
- self .osg_resource = ""
59
- self .osg_resource_group = ""
60
- self .enabled_batch_systems = []
61
55
self .htcondor_gateway_enabled = None
62
- self .resource_catalog = None
63
56
self .authorization_method = None
64
- self .subcluster_sections = None
57
+ self .configuration = None
58
+ self .ce_attributes_str = ""
65
59
66
60
self .log ("InfoServicesConfiguration.__init__ completed" )
67
61
@@ -80,7 +74,7 @@ def _parse_ce_collectors(self, val):
80
74
else :
81
75
return val .split (',' )
82
76
83
- def parse_configuration (self , configuration ):
77
+ def parse_configuration (self , configuration : ConfigParser ):
84
78
"""
85
79
Try to get configuration information from ConfigParser or SafeConfigParser object given
86
80
by configuration and write recognized settings to attributes dict
@@ -113,27 +107,9 @@ def parse_configuration(self, configuration):
113
107
114
108
self .ce_collectors = self ._parse_ce_collectors (self .options ['ce_collectors' ].value )
115
109
116
- def csg (section , option ):
117
- return utilities .config_safe_get (configuration , section , option , None )
110
+ self .htcondor_gateway_enabled = configuration .get ('Gateway' , 'htcondor_gateway_enabled' , fallback = False )
118
111
119
- def csgbool (section , option ):
120
- return utilities .config_safe_getboolean (configuration , section , option , False )
121
-
122
- # We get some values for HTCondor-CE from the Site Information section
123
- self .osg_resource = csg ('Site Information' , 'resource' )
124
- self .osg_resource_group = csg ('Site Information' , 'resource_group' )
125
- # and the enabled batch systems from their respective sections
126
- self .enabled_batch_systems = [bs for bs in BATCH_SYSTEMS if csgbool (bs , 'enabled' )]
127
-
128
- self .htcondor_gateway_enabled = csgbool ('Gateway' , 'htcondor_gateway_enabled' )
129
-
130
- self .subcluster_sections = ConfigParser .SafeConfigParser ()
131
-
132
- for section in configuration .sections ():
133
- if subcluster .is_subcluster_like (section ):
134
- self .subcluster_sections .add_section (section )
135
- for key , value in configuration .items (section ):
136
- self .subcluster_sections .set (section , key , value )
112
+ self .configuration = configuration # save for later: the ce_attributes module reads the whole config.
137
113
138
114
if utilities .ce_installed () and not subcluster .check_config (configuration ):
139
115
self .log ("On a CE but no valid 'Subcluster', 'Resource Entry', or 'Pilot' sections defined."
@@ -147,7 +123,7 @@ def csgbool(section, option):
147
123
# configure(), but at this point we don't have a way of knowing what
148
124
# default_allowed_vos should be.
149
125
if self .ce_collector_required_rpms_installed and self .htcondor_gateway_enabled and classad is not None :
150
- subcluster .resource_catalog_from_config (self . subcluster_sections , default_allowed_vos = ["*" ])
126
+ subcluster .resource_catalog_from_config (configuration , default_allowed_vos = ["*" ])
151
127
152
128
self .log ('InfoServicesConfiguration.parse_configuration completed' )
153
129
@@ -171,14 +147,12 @@ def configure(self, attributes):
171
147
if classad is None :
172
148
self .log ("Cannot configure HTCondor CE info services: unable to import HTCondor Python bindings."
173
149
"\n Ensure the 'classad' Python module is installed and accessible to Python scripts."
174
- "\n If using HTCondor from RPMs, install the 'condor-python ' RPM."
150
+ "\n If using HTCondor from RPMs, install the 'python3-condor ' RPM."
175
151
"\n If not, you may need to add the directory containing the Python bindings to PYTHONPATH."
176
152
"\n HTCondor version must be at least 8.2.0." , level = logging .WARNING )
177
153
else :
178
154
try :
179
- self .resource_catalog = subcluster .resource_catalog_from_config (
180
- self .subcluster_sections ,
181
- default_allowed_vos = ["*" ])
155
+ self .ce_attributes_str = ce_attributes .get_ce_attributes_str (self .configuration )
182
156
except exceptions .SettingError as err :
183
157
self .log ("Error in info services configuration: %s" % err , level = logging .ERROR )
184
158
return False
@@ -230,27 +204,10 @@ def _write_ce_collector_attributes_file(self, attributes_file):
230
204
CE-Collector to advertise
231
205
232
206
"""
233
- schedd_attrs_list = ["$(SCHEDD_ATTRS)" ]
234
- attributes_file_lines = []
235
-
236
- for name , value in [
237
- ('OSG_Resource' , self .osg_resource ),
238
- ('OSG_ResourceGroup' , self .osg_resource_group ),
239
- ('OSG_BatchSystems' , "," .join (self .enabled_batch_systems ))
240
- ]:
241
- attributes_file_lines .append ("%s = %s" % (name , utilities .classad_quote (value )))
242
- schedd_attrs_list .append (name )
243
-
244
- if self .resource_catalog :
245
- attributes_file_lines .append (self .resource_catalog .compose_text ())
246
- schedd_attrs_list .append ('OSG_ResourceCatalog' )
247
-
248
207
attributes_file_contents = (
249
208
"# Do not edit - file generated by osg-configure\n "
250
- + "\n " .join (attributes_file_lines ) + "\n "
251
- + "SCHEDD_ATTRS = " + " " .join (schedd_attrs_list ) + "\n "
209
+ + self .ce_attributes_str + "\n "
252
210
)
253
-
254
211
return utilities .atomic_write (attributes_file , attributes_file_contents )
255
212
256
213
def _write_ce_collector_file (self , info_services_file ):
0 commit comments