Skip to content

Commit 39a5dcb

Browse files
Improve EXA (GTT) parser (#111)
* Add support for re-scheduled EXA/GTT notifications * Add support for new and completed GTT/EXA notifications * Cleanup * Add subject include_filter for GTT/EXA * Review comment
1 parent b5306a1 commit 39a5dcb

File tree

17 files changed

+587
-8
lines changed

17 files changed

+587
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ By default, there is a `GenericProvider` that support a `SimpleProcessor` using
6464
- Cogent
6565
- Colt
6666
- Equinix
67-
- GTT
67+
- EXA (formerly GTT)
6868
- HGC
6969
- Lumen
7070
- Megaport

circuit_maintenance_parser/parsers/gtt.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
class HtmlParserGTT1(Html):
16-
"""Notifications Parser for GTT notifications."""
16+
"""Notifications Parser for EXA (formerly GTT) notifications."""
1717

1818
def parse_html(self, soup):
1919
"""Execute parsing."""
@@ -33,21 +33,37 @@ def parse_tables(self, tables, data):
3333
if groups:
3434
data["maintenance_id"] = groups.groups()[0]
3535
status = groups.groups()[1]
36-
if status == "Reminder":
36+
if status in ("New", "Reminder"):
3737
data["status"] = Status["CONFIRMED"]
38-
elif status == "Update":
38+
elif status in ("Update", "Rescheduled"):
3939
data["status"] = Status["RE_SCHEDULED"]
4040
elif status == "Cancelled":
4141
data["status"] = Status["CANCELLED"]
4242
# When a email is cancelled there is no start or end time specificed
4343
# Setting this to 0 and 1 stops any errors from pydantic
4444
data["start"] = 0
4545
data["end"] = 1
46+
elif status == "Completed":
47+
data["status"] = Status["COMPLETED"]
4648
elif "Start" in td_element.text:
47-
start = parser.parse(td_element.next_sibling.next_sibling.text)
49+
# In the case of a normal notification, we have:
50+
# <td> <strong>TIME</strong></td>
51+
# But in the case of a reschedule, we have:
52+
# <td> <strong><strike>OLD TIME</strike><font>NEW TIME</font></strong></td>
53+
next_td = td_element.next_sibling.next_sibling
54+
strong = next_td.contents[1]
55+
if strong.string:
56+
start = parser.parse(strong.string)
57+
else:
58+
start = parser.parse(strong.contents[1].string)
4859
data["start"] = self.dt2ts(start)
4960
elif "End" in td_element.text:
50-
end = parser.parse(td_element.next_sibling.next_sibling.text)
61+
next_td = td_element.next_sibling.next_sibling
62+
strong = next_td.contents[1]
63+
if strong.string:
64+
end = parser.parse(strong.string)
65+
else:
66+
end = parser.parse(strong.contents[1].string)
5167
data["end"] = self.dt2ts(end)
5268
num_columns = len(table.find_all("th"))
5369
if num_columns:

circuit_maintenance_parser/provider.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,15 @@ class EUNetworks(GenericProvider):
214214

215215

216216
class GTT(GenericProvider):
217-
"""GTT provider custom class."""
217+
"""EXA (formerly GTT) provider custom class."""
218+
219+
# "Planned Work Notification", "Emergency Work Notification"
220+
_include_filter = {EMAIL_HEADER_SUBJECT: ["Work Notification"]}
218221

219222
_processors: List[GenericProcessor] = [
220223
CombinedProcessor(data_parsers=[EmailDateParser, HtmlParserGTT1]),
221224
]
222-
_default_organizer = "InfraCo.CM@gttcorp.org"
225+
_default_organizer = "InfraCo.CM@exainfra.net"
223226

224227

225228
class HGC(GenericProvider):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GTT Emergency Work Notification TT 11111111 – Update
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GTT Emergency Work Notification TT 11111111 – Reminder
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GTT Emergency Work Notification TT 11111111 – Cancelled

tests/unit/data/gtt/gtt4.html

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<!DOCTYPE html>
2+
<html lang=3D"en">
3+
<head>
4+
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8">
5+
<meta charset=3D"utf-8">
6+
=20
7+
</head>
8+
<body>
9+
<div style=3D"width: 740px; font-family: Verdana, Arial, Helvetica, sans-se=
10+
rif; font-size: 10pt; margin: 0 auto;">
11+
<table border=3D"0" cellpadding=3D"0" cellspacing=3D"0" width=3D"740" s=
12+
tyle=3D"border-collapse: collapse; padding-left: 5px; border: 1px none blac=
13+
k;">
14+
<tr>
15+
<td width=3D"30%" style=3D"border-collapse: collapse; padding-l=
16+
eft: 5px; border: 1px none black;"><img src=3D"https://myportal.exainfra.ne=
17+
t/assets/img/logos/exa-logo-small.png" border=3D"0"></td>
18+
<td width=3D"70%" align=3D"center" style=3D"border-collapse: co=
19+
llapse; padding-left: 5px; border: 1px none black;"><strong><i>Planned Work=
20+
Notification: 60543210 - Rescheduled</i></strong></td>
21+
</tr>
22+
</table>
23+
<p>Please note that the Planned Work is rescheduled.=E2=80=AFPlease see=
24+
details of the work and impact on your service below. </p>
25+
<p>
26+
<strong>Reschedule Reason:</strong><br>
27+
rescheduled by supplier
28+
</p>
29+
<strong>Details:</strong><br>
30+
<table border=3D"1" cellpadding=3D"4" cellspacing=3D"0" style=3D"width:=
31+
100%; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 8pt; bor=
32+
der-collapse: collapse; padding-left: 5px; border: 1px solid black;">
33+
<tr>
34+
<td width=3D"15%" style=3D"border-collapse: collapse; padding-left:=
35+
5px; color: white; font-weight: bold; border: 1px solid black;" bgcolor=3D=
36+
"#2B3C8A">
37+
<strong>Start</strong>
38+
</td>
39+
<td width=3D"85%" style=3D"border-collapse: collapse; padding-left: 5px; bo=
40+
rder: 1px solid black;">
41+
<strong><strike>2021-11-10 03:00:00 GMT </strike><font color=3D'red'>2021-1=
42+
2-08 03:00 GMT</font></strong>
43+
</td>
44+
</tr>
45+
<tr>
46+
<td style=3D"border-collapse: collapse; padding-left: 5px; color: w=
47+
hite; font-weight: bold; border: 1px solid black;" bgcolor=3D"#2B3C8A">
48+
<strong>End</strong>
49+
</td>
50+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: 1px soli=
51+
d black;">
52+
<strong><strike>2021-11-10 11:00:00 GMT </strike><font color=3D'red'>2021-1=
53+
2-08 11:00 GMT</font></strong>
54+
</td>
55+
</tr>
56+
=20
57+
=20
58+
<tr>
59+
<td style=3D"border-collapse: collapse; padding-left: 5px; color: w=
60+
hite; font-weight: bold; border: 1px solid black;" bgcolor=3D"#2B3C8A">
61+
<strong>Location</strong>
62+
</td>
63+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: 1px soli=
64+
d black;">
65+
<strong>Vaden Dr & Country Creek Rd in Oakton, VA</strong>
66+
</td>
67+
</tr>
68+
</table>
69+
70+
<p>
71+
<strong>Planned work Reason:</strong><br>
72+
Network optimization on our partner network
73+
</p>
74+
<table border=3D"1" cellpadding=3D"4" cellspacing=3D"0" style=3D"width:=
75+
100%; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 8pt; bor=
76+
der-collapse: collapse; padding-left: 5px; border: 1px solid black;">
77+
<thead>
78+
<tr>
79+
<th style=3D"border-collapse: collapse; padding-left: 5px; color: w=
80+
hite; font-weight: bold; border: 1px solid black;" width=3D"15%" align=3D"c=
81+
enter" bgcolor=3D"#2B3C8A"><strong>Services Affected</strong></th>
82+
<th style=3D"border-collapse: collapse; padding-left: 5px; color: w=
83+
hite; font-weight: bold; border: 1px solid black;" width=3D"15%" align=3D"c=
84+
enter" bgcolor=3D"#2B3C8A"><strong>SLID/CCSD</strong></th>
85+
<th style=3D"border-collapse: collapse; padding-left: 5px; color: w=
86+
hite; font-weight: bold; border: 1px solid black;" width=3D"10%" align=3D"c=
87+
enter" bgcolor=3D"#2B3C8A"><strong>Customer PON</strong></th>
88+
<th style=3D"border-collapse: collapse; padding-left: 5px; color: w=
89+
hite; font-weight: bold; border: 1px solid black;" width=3D"10%" align=3D"c=
90+
enter" bgcolor=3D"#2B3C8A"><strong>Service Type</strong></th>
91+
<th style=3D"border-collapse: collapse; padding-left: 5px; color: w=
92+
hite; font-weight: bold; border: 1px solid black;" width=3D"15%" align=3D"c=
93+
enter" bgcolor=3D"#2B3C8A"><strong>Expected Impact to your Service</strong>=
94+
</th>
95+
<th style=3D"border-collapse: collapse; padding-left: 5px; color: w=
96+
hite; font-weight: bold; border: 1px solid black;" width=3D"35%" align=3D"c=
97+
enter" bgcolor=3D"#2B3C8A"><strong>Site Address</strong></th>
98+
</tr>
99+
</thead>
100+
=20
101+
<tr>
102+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: =
103+
1px solid black;" align=3D"center">HI/Wavelength/00696969</td>
104+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: =
105+
1px solid black;" align=3D"center">1234567-10987654</td>
106+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: =
107+
1px solid black;" align=3D"center">PO # RGB00012345</td>
108+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: =
109+
1px solid black;" align=3D"center">Wavelength</td>
110+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: =
111+
1px solid black;" align=3D"center">180 min</td>
112+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: =
113+
1px solid black;" align=3D"center">12345 Some St, Ashburn, VA 20147, USA</td>
114+
</tr>
115+
=20
116+
</table>
117+
=20
118+
<p>If you have any questions regarding the planned work, please login t=
119+
o <a href=3D"https://myportal.exainfra.net/sign-in">MyPortal</a> or contact=
120+
our Change Management Team using the email below.</p>
121+
122+
<br>Kind Regards,
123+
<br>EXA Network Operations
124+
125+
</div>
126+
</body>
127+
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXA Emergency Work Notification TT 60543210 – Reschedule
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[
2+
{
3+
"account": "PO # RGB00012345",
4+
"circuits": [
5+
{
6+
"circuit_id": "1234567-10987654",
7+
"impact": "OUTAGE"
8+
}
9+
],
10+
"end": 1638961200,
11+
"maintenance_id": "60543210",
12+
"start": 1638932400,
13+
"status": "RE-SCHEDULED"
14+
}
15+
]

tests/unit/data/gtt/gtt5.html

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<!DOCTYPE html>
2+
<html lang=3D"en">
3+
<head>
4+
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8">
5+
<meta charset=3D"utf-8">
6+
=20
7+
</head>
8+
<body>
9+
<div style=3D"width: 740px; font-family: Verdana, Arial, Helvetica, sans-se=
10+
rif; font-size: 10pt; margin: 0 auto;">
11+
<table border=3D"0" cellpadding=3D"0" cellspacing=3D"0" width=3D"740" s=
12+
tyle=3D"border-collapse: collapse; padding-left: 5px; border: 1px none blac=
13+
k;">
14+
<tr>
15+
<td width=3D"30%" style=3D"border-collapse: collapse; padding-l=
16+
eft: 5px; border: 1px none black;"><img src=3D"https://myportal.exainfra.ne=
17+
t/assets/img/logos/exa-logo-small.png" border=3D"0"></td>
18+
<td width=3D"70%" align=3D"center" style=3D"border-collapse: co=
19+
llapse; padding-left: 5px; border: 1px none black;"><strong><i>Planned Work=
20+
Notification: 60543210 - Completed</i></strong></td>
21+
</tr>
22+
</table>
23+
24+
<br>
25+
<strong>Final Update:</strong><br>
26+
***Completed*** This notice is to inform you that the Planned Maintenan=
27+
ce has concluded.
28+
<br><br>
29+
<strong>Details:</strong><br>
30+
<table border=3D"1" cellpadding=3D"4" cellspacing=3D"0" style=3D"width:=
31+
100%; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 8pt; bor=
32+
der-collapse: collapse; padding-left: 5px; border: 1px solid black;">
33+
<tr>
34+
<td width=3D"15%" style=3D"border-collapse: collapse; padding-left:=
35+
5px; color: white; font-weight: bold; border: 1px solid black;" bgcolor=3D=
36+
"#2B3C8A">
37+
<strong>Start</strong>
38+
</td>
39+
<td width=3D"85%" style=3D"border-collapse: collapse; padding-left: 5px; bo=
40+
rder: 1px solid black;">
41+
<strong>2021-11-13 04:00:00 GMT</strong>
42+
</td>
43+
</tr>
44+
<tr>
45+
<td style=3D"border-collapse: collapse; padding-left: 5px; color: w=
46+
hite; font-weight: bold; border: 1px solid black;" bgcolor=3D"#2B3C8A">
47+
<strong>End</strong>
48+
</td>
49+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: 1px soli=
50+
d black;">
51+
<strong>2021-11-13 10:00:00 GMT</strong>
52+
</td>
53+
</tr>
54+
=20
55+
<tr>
56+
<td style=3D"border-collapse: collapse; padding-left: 5px; color: w=
57+
hite; font-weight: bold; border: 1px solid black;" bgcolor=3D"#2B3C8A">
58+
<strong>Location</strong>
59+
</td>
60+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: 1px soli=
61+
d black;">
62+
<strong>165 Some Street, New Jersey</strong>
63+
</td>
64+
</tr>
65+
</table>
66+
67+
<p>
68+
<strong>Planned work Reason:</strong><br>
69+
Emergency software upgrade on the 165Some Street
70+
</p>
71+
<table border=3D"1" cellpadding=3D"4" cellspacing=3D"0" style=3D"width:=
72+
100%; font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 8pt; bor=
73+
der-collapse: collapse; padding-left: 5px; border: 1px solid black;">
74+
<thead>
75+
<tr>
76+
<th style=3D"border-collapse: collapse; padding-left: 5px; color: w=
77+
hite; font-weight: bold; border: 1px solid black;" width=3D"15%" align=3D"c=
78+
enter" bgcolor=3D"#2B3C8A"><strong>Services Affected</strong></th>
79+
<th style=3D"border-collapse: collapse; padding-left: 5px; color: w=
80+
hite; font-weight: bold; border: 1px solid black;" width=3D"15%" align=3D"c=
81+
enter" bgcolor=3D"#2B3C8A"><strong>SLID/CCSD</strong></th>
82+
<th style=3D"border-collapse: collapse; padding-left: 5px; color: w=
83+
hite; font-weight: bold; border: 1px solid black;" width=3D"10%" align=3D"c=
84+
enter" bgcolor=3D"#2B3C8A"><strong>Customer PON</strong></th>
85+
<th style=3D"border-collapse: collapse; padding-left: 5px; color: w=
86+
hite; font-weight: bold; border: 1px solid black;" width=3D"10%" align=3D"c=
87+
enter" bgcolor=3D"#2B3C8A"><strong>Service Type</strong></th>
88+
<th style=3D"border-collapse: collapse; padding-left: 5px; color: w=
89+
hite; font-weight: bold; border: 1px solid black;" width=3D"15%" align=3D"c=
90+
enter" bgcolor=3D"#2B3C8A"><strong>Expected Impact to your Service</strong>=
91+
</th>
92+
<th style=3D"border-collapse: collapse; padding-left: 5px; color: w=
93+
hite; font-weight: bold; border: 1px solid black;" width=3D"35%" align=3D"c=
94+
enter" bgcolor=3D"#2B3C8A"><strong>Site Address</strong></th>
95+
</tr>
96+
</thead>
97+
=20
98+
<tr>
99+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: =
100+
1px solid black;" align=3D"center">HI/Wavelength/00696969</td>
101+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: =
102+
1px solid black;" align=3D"center">1815743-10987654</td>
103+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: =
104+
1px solid black;" align=3D"center">PO # RGD00012345</td>
105+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: =
106+
1px solid black;" align=3D"center">Wavelength</td>
107+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: =
108+
1px solid black;" align=3D"center">90 min</td>
109+
<td style=3D"border-collapse: collapse; padding-left: 5px; border: =
110+
1px solid black;" align=3D"center">23456 Some St, Ashburn, VA 20147, USA</td>
111+
</tr>
112+
=20
113+
</table>
114+
=20
115+
<p>If you have any questions regarding the planned work or if you are s=
116+
till experiencing a service outage, please login to <a href=3D"https://mypo=
117+
rtal.exainfra.net/sign-in">MyPortal</a> or contact our Change Management Te=
118+
am using the email below.</p>
119+
120+
<br>Kind Regards,
121+
<br>EXA Network Operations
122+
123+
</div>
124+
</body>
125+
</html>

0 commit comments

Comments
 (0)