Skip to content

Commit a4636cc

Browse files
authored
Merge pull request #411 from i3dnet-akoopen/patch-2
Equinix fix matching maintenance_id in alternative email subject line
2 parents 2f1a078 + 9c75b7f commit a4636cc

9 files changed

Lines changed: 535 additions & 1 deletion

File tree

changes/411.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Equinix parser: match maintenance_id for alternative email subject line, when the maintenance_id is not matched between square brackets

circuit_maintenance_parser/parsers/equinix.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,25 @@ def parse_subject(self, subject: str) -> List[Dict]:
147147
148148
Args:
149149
subject (str): subject of email
150-
e.g. 'Scheduled software upgrade in metro connect platform-SG Metro Area Network Maintenance -19-OCT-2021 [5-212760022356]'.
150+
e.g. 'COMPLETED - Remedial Emergency Maintenance - SG Metro Area Network Maintenance - 04-APR-2026 [CHG0124084]'.
151+
alternative format: 'Service Impacting - Remedial - Dark Fiber Activity - SG Metro Area - Network Maintenance - 03-MAY-2026 - CHG0125903'
152+
older format: 'Scheduled software upgrade in metro connect platform-SG Metro Area Network Maintenance -19-OCT-2021 [5-212760022356]'
151153
152154
153155
Returns:
154156
List[Dict]: Returns the data object with summary and status fields.
155157
"""
156158
data = {}
159+
# Try and match maintenance_id for string between brackets, e.g.: [CHG0124084]
157160
maintenance_id = re.search(r"\[([^[]*)\]$", subject)
158161
if maintenance_id:
159162
data["maintenance_id"] = maintenance_id[1]
163+
else:
164+
# If not matched between brackets, look for maintenance_id in format of CHG[0-9]+
165+
maintenance_id = re.search(r"CHG\d+", subject)
166+
if maintenance_id:
167+
data["maintenance_id"] = maintenance_id.group()
168+
160169
data["summary"] = subject.strip().replace("\n", "")
161170
if "completed" in subject.lower():
162171
data["status"] = Status.COMPLETED

tests/unit/data/equinix/equinix10.eml

Lines changed: 459 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[
2+
{
3+
"account": "133337",
4+
"circuits": [
5+
{
6+
"circuit_id": "13333371-A",
7+
"impact": "OUTAGE"
8+
},
9+
{
10+
"circuit_id": "13333372-A",
11+
"impact": "OUTAGE"
12+
}
13+
],
14+
"end": 1777752000,
15+
"start": 1777737600
16+
}
17+
]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[
2+
{
3+
"account": "133337",
4+
"circuits": [
5+
{
6+
"circuit_id": "13333371-A",
7+
"impact": "OUTAGE"
8+
},
9+
{
10+
"circuit_id": "13333372-A",
11+
"impact": "OUTAGE"
12+
}
13+
],
14+
"end": 1777752000,
15+
"maintenance_id": "CHG0125903",
16+
"organizer": "servicedesk@equinix.com",
17+
"provider": "equinix",
18+
"sequence": 1,
19+
"stamp": 1776816428,
20+
"start": 1777737600,
21+
"status": "CONFIRMED",
22+
"summary": "Service Impacting - Remedial - Dark Fiber Activity - SG Metro Area - Network Maintenance - 03-MAY-2026 - CHG0125903",
23+
"uid": "0"
24+
}
25+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Service Impacting - Remedial - Dark Fiber Activity - SG Metro Area - Network Maintenance - 03-MAY-2026 - CHG0125903
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"maintenance_id": "CHG0125903",
4+
"status": "CONFIRMED",
5+
"summary": "Service Impacting - Remedial - Dark Fiber Activity - SG Metro Area - Network Maintenance - 03-MAY-2026 - CHG0125903"
6+
}
7+
]

tests/unit/test_e2e.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,11 @@
373373
[("email", Path(dir_path, "data", "equinix", "equinix9.eml"))],
374374
[Path(dir_path, "data", "equinix", "equinix9_result_combined.json")],
375375
),
376+
(
377+
Equinix,
378+
[("email", Path(dir_path, "data", "equinix", "equinix10.eml"))],
379+
[Path(dir_path, "data", "equinix", "equinix10_result_combined.json")],
380+
),
376381
# EUNetworks
377382
(
378383
EUNetworks,

tests/unit/test_parsers.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,16 @@ def default(self, o):
372372
Path(dir_path, "data", "equinix", "equinix9.eml"),
373373
Path(dir_path, "data", "equinix", "equinix9_result.json"),
374374
),
375+
(
376+
HtmlParserEquinix,
377+
Path(dir_path, "data", "equinix", "equinix10.eml"),
378+
Path(dir_path, "data", "equinix", "equinix10_result.json"),
379+
),
380+
(
381+
SubjectParserEquinix,
382+
Path(dir_path, "data", "equinix", "equinix11_subject.eml"),
383+
Path(dir_path, "data", "equinix", "equinix11_subject_result.json"),
384+
),
375385
# Global Cloud Xchange
376386
(
377387
HtmlParserGcx1,

0 commit comments

Comments
 (0)