Skip to content

Commit d49b864

Browse files
committed
Drop SiteInformation.sponsor (OSG_SPONSOR) (SOFTWARE-3471)
1 parent d429ec1 commit d49b864

File tree

3 files changed

+1
-98
lines changed

3 files changed

+1
-98
lines changed

config/40-siteinfo.ini

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,3 @@ host_name = UNAVAILABLE
1919
;
2020
; YOU WILL NEED TO CHANGE THIS
2121
resource = UNAVAILABLE
22-
23-
; Set "sponsor" to the sponsor(s) for your cluster.
24-
; If your cluster has multiple sponsors, separate them with commas
25-
; and specify the percentages using this format: "osg:10, atlas:45, cms:45".
26-
;
27-
;sponsor =

osg_configure/configure_modules/siteinformation.py

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ def __init__(self, *args, **kwargs):
3333
configfile.Option(name='host_name',
3434
required=MANDATORY_ON_CE,
3535
mapping='OSG_HOSTNAME'),
36-
'sponsor':
37-
configfile.Option(name='sponsor',
38-
required=OPTIONAL,
39-
default_value='',
40-
mapping='OSG_SPONSOR'),
4136
'resource':
4237
configfile.Option(name='resource',
4338
required=MANDATORY,
@@ -74,6 +69,7 @@ def parse_configuration(self, configuration):
7469
"latitude",
7570
"longitude",
7671
"site_policy",
72+
"sponsor",
7773
])
7874
self.log('SiteInformation.parse_configuration completed')
7975

@@ -112,51 +108,9 @@ def check_attributes(self, attributes):
112108
section=self.config_section,
113109
level=logging.WARNING)
114110

115-
sponsor = self.opt_val("sponsor")
116-
if not utilities.blank(sponsor):
117-
attributes_ok &= self.check_sponsor(sponsor)
118-
119111
self.log('SiteInformation.check_attributes completed')
120112
return attributes_ok
121113

122-
def check_sponsor(self, sponsor):
123-
attributes_ok = True
124-
percentage = 0
125-
for vo in re.split(r'\s*,?\s*', sponsor):
126-
vo_split = vo.split(':')
127-
if len(vo_split) == 1:
128-
percentage += 100
129-
elif len(vo_split) == 2:
130-
vo_percentage = vo_split[1]
131-
try:
132-
percentage += int(vo_percentage)
133-
except ValueError:
134-
self.log("VO percentage (%s) in sponsor field (%s) not an integer"
135-
% (vo_percentage, vo),
136-
section=self.config_section,
137-
option='sponsor',
138-
level=logging.ERROR,
139-
exception=True)
140-
attributes_ok = False
141-
else:
142-
self.log("VO sponsor field is not formated correctly: %s" % vo,
143-
section=self.config_section,
144-
option='sponsor',
145-
level=logging.ERROR)
146-
self.log("Sponsors should be given as sponsor:percentage "
147-
"separated by a space or comma")
148-
attributes_ok = False
149-
150-
if percentage != 100:
151-
self.log("VO percentages in sponsor field do not add up to 100, got %s"
152-
% percentage,
153-
section=self.config_section,
154-
option='sponsor',
155-
level=logging.ERROR)
156-
attributes_ok = False
157-
158-
return attributes_ok
159-
160114
def module_name(self):
161115
"""Return a string with the name of the module"""
162116
return "SiteInformation"

tests/test_siteattributes.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def testParsing1(self):
5353
variables = {'OSG_GROUP': 'OSG-ITB',
5454
'OSG_HOSTNAME': 'example.com',
5555
'OSG_SITE_NAME': 'MY_SITE',
56-
'OSG_SPONSOR': 'osg:100',
5756
}
5857
for var in variables:
5958
self.assertTrue(var in attributes,
@@ -82,7 +81,6 @@ def testParsing2(self):
8281
variables = {'OSG_GROUP': 'OSG',
8382
'OSG_HOSTNAME': 'example.com',
8483
'OSG_SITE_NAME': 'MY_SITE',
85-
'OSG_SPONSOR': 'osg:50 usatlas:50',
8684
}
8785
for var in variables:
8886
self.assertTrue(var in attributes,
@@ -111,7 +109,6 @@ def testParsing3(self):
111109
variables = {'OSG_GROUP': 'OSG',
112110
'OSG_HOSTNAME': 'example.com',
113111
'OSG_SITE_NAME': 'MY_SITE',
114-
'OSG_SPONSOR': 'osg:50 usatlas:50',
115112
}
116113
for var in variables:
117114
self.assertTrue(var in attributes,
@@ -175,48 +172,6 @@ def testInvalidHostname(self):
175172
self.assertFalse(settings.check_attributes(attributes),
176173
"Invalid hostname ignored")
177174

178-
def testInvalidSponsor1(self):
179-
"""
180-
Test the check_attributes where the sponsor percentages
181-
add up to more than 100
182-
"""
183-
184-
config_file = get_test_config("siteattributes/" \
185-
"invalid_sponsor1.ini")
186-
configuration = configparser.SafeConfigParser()
187-
configuration.read(config_file)
188-
189-
settings = siteinformation.SiteInformation(logger=global_logger)
190-
try:
191-
settings.parse_configuration(configuration)
192-
except Exception as e:
193-
self.fail("Received exception while parsing configuration: %s" % e)
194-
195-
attributes = settings.get_attributes()
196-
self.assertFalse(settings.check_attributes(attributes),
197-
"Invalid sponsor ignored")
198-
199-
def testInvalidSponsor2(self):
200-
"""
201-
Test the check_attributes where the sponsor percentages
202-
add up to less than 100
203-
"""
204-
205-
config_file = get_test_config("siteattributes/" \
206-
"invalid_sponsor2.ini")
207-
configuration = configparser.SafeConfigParser()
208-
configuration.read(config_file)
209-
210-
settings = siteinformation.SiteInformation(logger=global_logger)
211-
try:
212-
settings.parse_configuration(configuration)
213-
except Exception as e:
214-
self.fail("Received exception while parsing configuration: %s" % e)
215-
216-
attributes = settings.get_attributes()
217-
self.assertFalse(settings.check_attributes(attributes),
218-
"Invalid sponsor ignored")
219-
220175
def testValidSettings(self):
221176
"""
222177
Test the check_attributes function to see if it oks good attributes

0 commit comments

Comments
 (0)