Skip to content

Commit

Permalink
Merge branch 'master' into SOFTWARE-5095
Browse files Browse the repository at this point in the history
  • Loading branch information
matyasselmeci authored Mar 23, 2022
2 parents 64b9bfc + d14c3dc commit 9b13e57
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 53 deletions.
15 changes: 7 additions & 8 deletions src/templates/generate_downtime_form.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,9 @@ Resource Downtime YAML Generator
{{ render_dtfield(form.description) }}
{{ render_dtfield(form.severity) }}

<div class="form-row">
{{ render_dtfield(form.start_date, type="date", class_="col-sm-6", placeholder="YYYY-MM-DD") }}
{{ render_dtfield(form.start_time, type="text", class_="col-sm-6", placeholder="HH:MM (24-hour UTC)", asterisk=false) }}
</div>
<div class="form-row">
{{ render_dtfield(form.end_date, type="date", class_="col-sm-6", placeholder="YYYY-MM-DD") }}
{{ render_dtfield(form.end_time, type="text", class_="col-sm-6", placeholder="HH:MM (24-hour UTC)", asterisk=false) }}
</div>
{{ render_dtfield(form.utc_offset) }}
{{ render_dtfield(form.start_datetime) }}
{{ render_dtfield(form.end_datetime) }}

{{ render_dtbutton(form.generate) }}
</form>
Expand Down Expand Up @@ -189,5 +184,9 @@ Resource Downtime YAML Generator
$( "#resource" ).change( function() {
$( "#change_resource" ).click();
} );
/* Preset UTC offsets */
$( "[name='utc_offset'] > [value=" + new Date().getTimezoneOffset() + "]" ).each( (i, e) => {
e.selected = true
})
</script>
{% endblock %}
15 changes: 7 additions & 8 deletions src/templates/generate_resource_group_downtime_form.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,9 @@ Resource Group Downtime YAML Generator
{{ render_dtfield(form.description) }}
{{ render_dtfield(form.severity) }}

<div class="form-row">
{{ render_dtfield(form.start_date, type="date", class_="col-sm-6", placeholder="YYYY-MM-DD") }}
{{ render_dtfield(form.start_time, type="text", class_="col-sm-6", placeholder="HH:MM (24-hour UTC)", asterisk=false) }}
</div>
<div class="form-row">
{{ render_dtfield(form.end_date, type="date", class_="col-sm-6", placeholder="YYYY-MM-DD") }}
{{ render_dtfield(form.end_time, type="text", class_="col-sm-6", placeholder="HH:MM (24-hour UTC)", asterisk=false) }}
</div>
{{ render_dtfield(form.utc_offset) }}
{{ render_dtfield(form.start_datetime) }}
{{ render_dtfield(form.end_datetime) }}

{{ render_dtbutton(form.generate) }}
</form>
Expand Down Expand Up @@ -207,5 +202,9 @@ Resource Group Downtime YAML Generator
$( "#resource_group" ).change( function() {
$( "#change_resource_group" ).click();
} );
/* Preset UTC offsets */
$( "[name='utc_offset'] > [value=" + new Date().getTimezoneOffset() + "]" ).each( (i, e) => {
e.selected = true
})
</script>
{% endblock %}
153 changes: 126 additions & 27 deletions src/webapp/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,119 @@
from flask_wtf import FlaskForm
from wtforms import SelectField, SelectMultipleField, StringField, \
TimeField, TextAreaField, SubmitField
from wtforms.ext.dateutil.fields import DateField
from wtforms.fields.html5 import DateTimeLocalField
from wtforms.validators import InputRequired

from . import models

UTCOFFSET_CHOICES = [
('-840', '+14:00'),
('-825', '+13:45'),
('-810', '+13:30'),
('-795', '+13:15'),
('-780', '+13:00'),
('-765', '+12:45'),
('-750', '+12:30'),
('-735', '+12:15'),
('-720', '+12:00'),
('-705', '+11:45'),
('-690', '+11:30'),
('-675', '+11:15'),
('-660', '+11:00'),
('-645', '+10:45'),
('-630', '+10:30'),
('-615', '+10:15'),
('-600', '+10:00'),
('-585', '+9:45'),
('-570', '+9:30'),
('-555', '+9:15'),
('-540', '+9:00'),
('-525', '+8:45'),
('-510', '+8:30'),
('-495', '+8:15'),
('-480', '+8:00'),
('-465', '+7:45'),
('-450', '+7:30'),
('-435', '+7:15'),
('-420', '+7:00'),
('-405', '+6:45'),
('-390', '+6:30'),
('-375', '+6:15'),
('-360', '+6:00'),
('-345', '+5:45'),
('-330', '+5:30'),
('-315', '+5:15'),
('-300', '+5:00'),
('-285', '+4:45'),
('-270', '+4:30'),
('-255', '+4:15'),
('-240', '+4:00'),
('-225', '+3:45'),
('-210', '+3:30'),
('-195', '+3:15'),
('-180', '+3:00'),
('-165', '+2:45'),
('-150', '+2:30'),
('-135', '+2:15'),
('-120', '+2:00'),
('-105', '+1:45'),
('-90', '+1:30'),
('-75', '+1:15'),
('-60', '+1:00'),
('-45', '+0:45'),
('-30', '+0:30'),
('-15', '+0:15'),
('0', '-0:00'),
('15', '-0:15'),
('30', '-0:30'),
('45', '-0:45'),
('60', '-1:00'),
('75', '-1:15'),
('90', '-1:30'),
('105', '-1:45'),
('120', '-2:00'),
('135', '-2:15'),
('150', '-2:30'),
('165', '-2:45'),
('180', '-3:00'),
('195', '-3:15'),
('210', '-3:30'),
('225', '-3:45'),
('240', '-4:00'),
('255', '-4:15'),
('270', '-4:30'),
('285', '-4:45'),
('300', '-5:00'),
('315', '-5:15'),
('330', '-5:30'),
('345', '-5:45'),
('360', '-6:00'),
('375', '-6:15'),
('390', '-6:30'),
('405', '-6:45'),
('420', '-7:00'),
('435', '-7:15'),
('450', '-7:30'),
('465', '-7:45'),
('480', '-8:00'),
('495', '-8:15'),
('510', '-8:30'),
('525', '-8:45'),
('540', '-9:00'),
('555', '-9:15'),
('570', '-9:30'),
('585', '-9:45'),
('600', '-10:00'),
('615', '-10:15'),
('630', '-10:30'),
('645', '-10:45'),
('660', '-11:00'),
('675', '-11:15'),
('690', '-11:30'),
('705', '-11:45'),
('720', '-12:00')
]

class GenerateResourceGroupDowntimeForm(FlaskForm):
scheduled = SelectField("Scheduled (registered at least 24 hours in advance)",
[InputRequired()], choices=[
Expand All @@ -24,10 +132,9 @@ class GenerateResourceGroupDowntimeForm(FlaskForm):
])
description = StringField("Description (the reason and/or impact of the outage)", [InputRequired()])

start_date = DateField("Start Date/Time (UTC)", [InputRequired()])
start_time = TimeField("&nbsp;", [InputRequired()])
end_date = DateField("End Date/Time (UTC)", [InputRequired()])
end_time = TimeField("&nbsp;", [InputRequired()])
start_datetime = DateTimeLocalField("Local Start Datetime", format='%Y-%m-%dT%H:%M', validators=[InputRequired()])
end_datetime = DateTimeLocalField("Local End Datetime", format='%Y-%m-%dT%H:%M', validators=[InputRequired()])
utc_offset = SelectField("UTC Offset", choices=UTCOFFSET_CHOICES)

facility = SelectField("Facility", choices=[], default="")
change_facility = SubmitField()
Expand Down Expand Up @@ -55,29 +162,25 @@ def validate(self):

if not super().validate():
return False
if self.start_date.data > self.end_date.data:
self.end_date.errors.append("End date/time must be after start date/time")
if self.start_datetime.data > self.end_datetime.data:
self.end_datetime.errors.append("End date/time must be after start date/time")
return False
elif self.start_date.data == self.end_date.data:
if self.start_time.data >= self.end_time.data:
self.end_time.errors.append("End date/time must be after start date/time")
return False

days_in_future = (self.get_start_datetime() - datetime.datetime.utcnow()).days
if days_in_future < 1 and self.scheduled.data == "SCHEDULED":
self.infos += "Note: Downtime registered less than one day in advance " \
"is considered unscheduled by WLCG policy."
"is considered unscheduled by WLCG policy."
elif days_in_future >= 1 and self.scheduled.data == "UNSCHEDULED":
self.infos += "Note: Downtime registered at least one day in advance " \
"is considered scheduled by WLCG policy."
"is considered scheduled by WLCG policy."

return True

def get_start_datetime(self):
return datetime.datetime.combine(self.start_date.data, self.start_time.data)
return self.start_datetime.data - datetime.timedelta(minutes=int(self.utc_offset.data))

def get_end_datetime(self):
return datetime.datetime.combine(self.end_date.data, self.end_time.data)
return self.end_datetime.data - datetime.timedelta(minutes=int(self.utc_offset.data))

def get_yaml(self, resources, service_names_by_resource) -> str:

Expand Down Expand Up @@ -118,10 +221,10 @@ class GenerateDowntimeForm(FlaskForm):
])
description = StringField("Description (the reason and/or impact of the outage)", [InputRequired()])

start_date = DateField("Start Date/Time (UTC)", [InputRequired()])
start_time = TimeField("&nbsp;", [InputRequired()])
end_date = DateField("End Date/Time (UTC)", [InputRequired()])
end_time = TimeField("&nbsp;", [InputRequired()])
start_datetime = DateTimeLocalField("Local Start Datetime", format='%Y-%m-%dT%H:%M', validators=[InputRequired()])
end_datetime = DateTimeLocalField("Local End Datetime", format='%Y-%m-%dT%H:%M', validators=[InputRequired()])
utc_offset = SelectField("UTC Offset", choices=UTCOFFSET_CHOICES)

services = SelectMultipleField("Known OSG Services (select one or more)", [InputRequired()], choices=[])

facility = SelectField("Facility", choices=[])
Expand All @@ -148,13 +251,9 @@ def validate(self):

if not super().validate():
return False
if self.start_date.data > self.end_date.data:
self.end_date.errors.append("End date/time must be after start date/time")
if self.start_datetime.data > self.end_datetime.data:
self.end_datetime.errors.append("End date/time must be after start date/time")
return False
elif self.start_date.data == self.end_date.data:
if self.start_time.data >= self.end_time.data:
self.end_time.errors.append("End date/time must be after start date/time")
return False

days_in_future = (self.get_start_datetime() - datetime.datetime.utcnow()).days
if days_in_future < 1 and self.scheduled.data == "SCHEDULED":
Expand All @@ -167,10 +266,10 @@ def validate(self):
return True

def get_start_datetime(self):
return datetime.datetime.combine(self.start_date.data, self.start_time.data)
return self.start_datetime.data - datetime.timedelta(minutes=int(self.utc_offset.data))

def get_end_datetime(self):
return datetime.datetime.combine(self.end_date.data, self.end_time.data)
return self.end_datetime.data - datetime.timedelta(minutes=int(self.utc_offset.data))

def get_yaml(self) -> str:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ Resources:
StorageCapacityMin:
TapeCapacity:
BNL_ATLAS_SE_AWS_East:
Active: true
Active: false
ContactLists:
Administrative Contact:
Primary:
Expand All @@ -395,7 +395,7 @@ Resources:
SRMv2:
Description: SRM V2 Storage Element
Details:
hidden: false
hidden: true
VOOwnership:
ATLAS: 100
WLCGInformation:
Expand All @@ -410,7 +410,7 @@ Resources:
StorageCapacityMin: 0
TapeCapacity: 0
BNL_ATLAS_SE_AWS_West:
Active: true
Active: false
ContactLists:
Administrative Contact:
Primary:
Expand All @@ -430,7 +430,7 @@ Resources:
SRMv2:
Description: SRM V2 Storage Element
Details:
hidden: false
hidden: true
VOOwnership:
ATLAS: 100
WLCGInformation:
Expand All @@ -445,7 +445,7 @@ Resources:
StorageCapacityMin: 0
TapeCapacity: 0
BNL_ATLAS_SE_AWS_West2:
Active: true
Active: false
ContactLists:
Administrative Contact:
Primary:
Expand All @@ -465,7 +465,7 @@ Resources:
SRMv2:
Description: SRM V2 Storage Element
Details:
hidden: false
hidden: true
VOOwnership:
ATLAS: 100
WLCGInformation:
Expand Down
8 changes: 4 additions & 4 deletions topology/University of Michigan/AGLT2/AGLT2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Resources:
VOOwnership:
ATLAS: 10
WLCGInformation:
APELNormalFactor: 11.07
APELNormalFactor: 11.38
AccountingName: US-AGLT2
HEPSPEC: 400
InteropAccounting: true
Expand Down Expand Up @@ -315,7 +315,7 @@ Resources:
VOOwnership:
ATLAS: 90
WLCGInformation:
APELNormalFactor: 10.96
APELNormalFactor: 11.38
AccountingName: US-AGLT2
HEPSPEC: 124200
InteropAccounting: true
Expand Down Expand Up @@ -360,7 +360,7 @@ Resources:
VOOwnership:
ATLAS: 90
WLCGInformation:
APELNormalFactor: 10.96
APELNormalFactor: 11.38
AccountingName: US-AGLT2
HEPSPEC: 124200
InteropAccounting: true
Expand Down Expand Up @@ -405,7 +405,7 @@ Resources:
VOOwnership:
ATLAS: 90
WLCGInformation:
APELNormalFactor: 11.16
APELNormalFactor: 11.38
AccountingName: US-AGLT2
HEPSPEC: 124200
InteropAccounting: true
Expand Down

0 comments on commit 9b13e57

Please sign in to comment.