Skip to content

Commit

Permalink
fix issue with ix-f feeds that have vlan_list or if_list set to null #…
Browse files Browse the repository at this point in the history
  • Loading branch information
vegu committed Oct 18, 2022
1 parent 10bb2ab commit c341982
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
19 changes: 19 additions & 0 deletions peeringdb_server/ixf.py
Expand Up @@ -442,10 +442,29 @@ def sanitize(self, data):
# This fixes instances where ixps provide two separate entries for
# vlans in vlan_list for ipv4 and ipv6 (AMS-IX for example)
for member in member_list:

# handle `null` properties inside connection list

for conn in member.get("connection_list", []):

# handle case where ix-f feed has set `vlan_list` to `null` (#1244)
# treat same as if it wasn't set at all

if conn.get("vlan_list", []) is None:
conn.pop("vlan_list")

# handle case where ix-f feed has set `if_list` to `null` (#1244)
# treat same as if it wasn't set at all

if conn.get("if_list", []) is None:
conn.pop("if_list")

asn = member.get("asnum")

connection_list = self.match_vlans_across_connections(
member.get("connection_list", [])
)

for conn in connection_list:

conn["vlan_list"] = self.sanitize_vlans(conn.get("vlan_list", []))
Expand Down
@@ -0,0 +1,39 @@
{
"timestamp": "2020-07-13T09:23:47Z",
"version": "1.0",
"ixp_list": [
{
"shortname": "Test Exchange",
"ixp_id": 1,
"ixf_id": 1
}
],
"member_list": [
{
"asnum": 1001,
"member_type": "peering",
"name": "Netflix",
"url": "http://netflix.com/",
"contact_email": [
"peering@netflix.com",
"mrpeering@netflix.com"
],
"contact_phone": [
"+1 1234 5678"
],
"contact_hours": "8/5",
"peering_policy": "open",
"peering_policy_url": "https://www.netflix.com/openconnect/",
"member_since": "2009-02-04T00:00:00Z",
"connection_list": [
{
"ixp_id": 42,
"connected_since": "2009-02-04T00:00:00Z",
"state": "connected",
"if_list": null,
"vlan_list": null
}
]
}
]
}
32 changes: 32 additions & 0 deletions tests/test_ixf_member_import_protocol.py
Expand Up @@ -2330,6 +2330,38 @@ def test_vlan_null_ips(entities, save):
assert_no_emails(ix=ixlan.ix)


@pytest.mark.django_db
def test_vlan_null_vlan_list_and_if_list(entities, save):
"""
The IX-F data contains a vlan_list and if_list as null
Importer should treat them the same as if they werent set at all (#1244)
"""

data = setup_test_data("ixf.member.null.vlan_list_and_if_list")
ixlan = entities["ixlan"][0]

importer = ixf.Importer()
importer.sanitize(data)

if not save:
return assert_idempotent(importer, ixlan, data, save=False)

importer.update(ixlan, data=data)
importer.notify_proposals()

assert importer.ixlan.ixf_ixp_import_error_notified is None
assert importer.ixlan.ixf_ixp_import_error is None
assert_no_emails(ix=ixlan.ix)

# Assert idempotent / lock
importer.sanitize(data)
importer.update(ixlan, data=data)

assert importer.ixlan.ixf_ixp_import_error_notified is None
assert importer.ixlan.ixf_ixp_import_error is None
assert_no_emails(ix=ixlan.ix)


@pytest.mark.django_db
def test_vlan_list_empty(entities, save):
"""
Expand Down

0 comments on commit c341982

Please sign in to comment.