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 . ce_attributes import BATCH_SYSTEMS , BATCH_SYSTEMS_CASE_MAP
13
+ from osg_configure .modules import ce_attributes
14
14
from osg_configure .modules import subcluster
15
15
from osg_configure .modules import reversevomap
16
16
@@ -52,13 +52,10 @@ def __init__(self, *args, **kwargs):
52
52
53
53
self .ce_collectors = []
54
54
self .ce_collector_required_rpms_installed = utilities .rpm_installed ('htcondor-ce' )
55
- self .osg_resource = ""
56
- self .osg_resource_group = ""
57
- self .enabled_batch_systems = []
58
55
self .htcondor_gateway_enabled = None
59
- self .resource_catalog = None
60
56
self .authorization_method = None
61
- self .subcluster_sections = None
57
+ self .ce_attributes_config = None
58
+ self .ce_attributes_str = ""
62
59
63
60
self .log ("InfoServicesConfiguration.__init__ completed" )
64
61
@@ -77,7 +74,7 @@ def _parse_ce_collectors(self, val):
77
74
else :
78
75
return val .split (',' )
79
76
80
- def parse_configuration (self , configuration ):
77
+ def parse_configuration (self , configuration : ConfigParser ):
81
78
"""
82
79
Try to get configuration information from ConfigParser or SafeConfigParser object given
83
80
by configuration and write recognized settings to attributes dict
@@ -110,38 +107,12 @@ def parse_configuration(self, configuration):
110
107
111
108
self .ce_collectors = self ._parse_ce_collectors (self .options ['ce_collectors' ].value )
112
109
113
- def csg (section , option ):
114
- return utilities .config_safe_get (configuration , section , option , None )
115
-
116
- def csgbool (section , option ):
117
- return utilities .config_safe_getboolean (configuration , section , option , False )
118
-
119
- # We get some values for HTCondor-CE from the Site Information section
120
- self .osg_resource = csg ('Site Information' , 'resource' )
121
- self .osg_resource_group = csg ('Site Information' , 'resource_group' )
122
- # and the enabled batch systems from their respective sections
123
- self .enabled_batch_systems = [bs for bs in BATCH_SYSTEMS if csgbool (bs , 'enabled' )]
124
-
125
- if csgbool ("Bosco" , "enabled" ):
126
- try :
127
- bosco_batch = BATCH_SYSTEMS_CASE_MAP [csg ("Bosco" , "batch" ).lower ()]
128
- if bosco_batch not in self .enabled_batch_systems :
129
- self .enabled_batch_systems .append (bosco_batch )
130
- except (KeyError , AttributeError ):
131
- # This is a warning; the bosco module raises the error.
132
- self .log ("Bosco.batch does not have a recognized value -- should be one of %s" %
133
- list (BATCH_SYSTEMS_CASE_MAP .keys ()),
134
- level = logging .WARNING )
135
-
136
- self .htcondor_gateway_enabled = csgbool ('Gateway' , 'htcondor_gateway_enabled' )
137
-
138
- self .subcluster_sections = ConfigParser .SafeConfigParser ()
110
+ self .htcondor_gateway_enabled = configuration .get ('Gateway' , 'htcondor_gateway_enabled' , fallback = False )
139
111
112
+ self .ce_attributes_config = ConfigParser ()
140
113
for section in configuration .sections ():
141
- if subcluster .is_subcluster_like (section ):
142
- self .subcluster_sections .add_section (section )
143
- for key , value in configuration .items (section ):
144
- self .subcluster_sections .set (section , key , value )
114
+ if subcluster .is_subcluster_like (section ) or section .lower () == "site information" :
115
+ self .ce_attributes_config [section ] = configuration [section ]
145
116
146
117
if utilities .ce_installed () and not subcluster .check_config (configuration ):
147
118
self .log ("On a CE but no valid 'Subcluster', 'Resource Entry', or 'Pilot' sections defined."
@@ -155,7 +126,7 @@ def csgbool(section, option):
155
126
# configure(), but at this point we don't have a way of knowing what
156
127
# default_allowed_vos should be.
157
128
if self .ce_collector_required_rpms_installed and self .htcondor_gateway_enabled and classad is not None :
158
- subcluster .resource_catalog_from_config (self .subcluster_sections , default_allowed_vos = ["*" ])
129
+ subcluster .resource_catalog_from_config (self .ce_attributes_config , default_allowed_vos = ["*" ])
159
130
160
131
self .log ('InfoServicesConfiguration.parse_configuration completed' )
161
132
@@ -179,14 +150,12 @@ def configure(self, attributes):
179
150
if classad is None :
180
151
self .log ("Cannot configure HTCondor CE info services: unable to import HTCondor Python bindings."
181
152
"\n Ensure the 'classad' Python module is installed and accessible to Python scripts."
182
- "\n If using HTCondor from RPMs, install the 'condor-python ' RPM."
153
+ "\n If using HTCondor from RPMs, install the 'python3-condor ' RPM."
183
154
"\n If not, you may need to add the directory containing the Python bindings to PYTHONPATH."
184
155
"\n HTCondor version must be at least 8.2.0." , level = logging .WARNING )
185
156
else :
186
157
try :
187
- self .resource_catalog = subcluster .resource_catalog_from_config (
188
- self .subcluster_sections ,
189
- default_allowed_vos = ["*" ])
158
+ self .ce_attributes_str = ce_attributes .get_ce_attributes_str (self .ce_attributes_config )
190
159
except exceptions .SettingError as err :
191
160
self .log ("Error in info services configuration: %s" % err , level = logging .ERROR )
192
161
return False
@@ -238,27 +207,10 @@ def _write_ce_collector_attributes_file(self, attributes_file):
238
207
CE-Collector to advertise
239
208
240
209
"""
241
- schedd_attrs_list = ["$(SCHEDD_ATTRS)" ]
242
- attributes_file_lines = []
243
-
244
- for name , value in [
245
- ('OSG_Resource' , self .osg_resource ),
246
- ('OSG_ResourceGroup' , self .osg_resource_group ),
247
- ('OSG_BatchSystems' , "," .join (self .enabled_batch_systems ))
248
- ]:
249
- attributes_file_lines .append ("%s = %s" % (name , utilities .classad_quote (value )))
250
- schedd_attrs_list .append (name )
251
-
252
- if self .resource_catalog :
253
- attributes_file_lines .append (self .resource_catalog .compose_text ())
254
- schedd_attrs_list .append ('OSG_ResourceCatalog' )
255
-
256
210
attributes_file_contents = (
257
211
"# Do not edit - file generated by osg-configure\n "
258
- + "\n " .join (attributes_file_lines ) + "\n "
259
- + "SCHEDD_ATTRS = " + " " .join (schedd_attrs_list ) + "\n "
212
+ + self .ce_attributes_str + "\n "
260
213
)
261
-
262
214
return utilities .atomic_write (attributes_file , attributes_file_contents )
263
215
264
216
def _write_ce_collector_file (self , info_services_file ):
0 commit comments