Skip to content

Commit

Permalink
Support 202408
Browse files Browse the repository at this point in the history
- IX media type field deprecated peeringdb/#1555
- Add location of Physical IX-Port & Router Port peeringdb/#607
  • Loading branch information
20c-ed authored and vegu committed Oct 7, 2024
1 parent 5ffb835 commit adbd530
Show file tree
Hide file tree
Showing 9 changed files with 849 additions and 562 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
### Added
- help text for info_traffic
- ORM configuration options exposed
- NetworkIXLan.ix_side field added
- NetworkIXLan.net_side field added
### Fixed
- missing migrations
- facility voltage value migration to fix peeringdb-py#86 on old databases
### Changed
- Facility.property label for Lessee changed to "Leased or Rented"
- Facility.property help text clarified
- social media service `twitter` renamed to `x`
### Deprecated
- InternetExchange.media field has been deprecated and will default to `Ethernet` until it will be removed in v3 of the PeeringDB API.


## 3.4.0
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ Unreleased:
added:
- help text for info_traffic
- ORM configuration options exposed
- NetworkIXLan.ix_side field added
- NetworkIXLan.net_side field added
fixed:
- missing migrations
- facility voltage value migration to fix peeringdb-py#86 on old databases
changed:
- Facility.property label for Lessee changed to "Leased or Rented"
- Facility.property help text clarified
- social media service `twitter` renamed to `x`
deprecated: []
deprecated:
- InternetExchange.media field has been deprecated and will default to `Ethernet` until it will be removed in v3 of the PeeringDB API.
removed: []
security: []
3.4.0:
Expand Down
1,252 changes: 695 additions & 557 deletions poetry.lock

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Internet",
]
Expand Down Expand Up @@ -63,11 +64,11 @@ twine = ">=3.3"
[tool.poetry.plugins."markdown.extensions"]
pymdgen = "pymdgen.md:Extension"


[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.isort]
profile = "black"
multi_line_output = 3

61 changes: 61 additions & 0 deletions src/django_peeringdb/migrations/0034_fix_voltage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Generated by Django 4.2.7 on 2024-08-07 19:37

from django.db import migrations


def _from_db_value(value, expression, connection):
# for bypass clean_choices validation
if value is None:
return None
if not value or value == "[]":
return []
return value.split(",")


def forward(apps, schema_editor):
Facility = apps.get_model("django_peeringdb", "Facility")
updated_field = Facility._meta.get_field("updated")
updated_field_auto_now = updated_field.auto_now
from_db_value = Facility._meta.get_field("available_voltage_services").from_db_value
invalid_voltage_values = ["120 VAC", "208 VAC", "240 VAC"]

try:
# overide from_db_value method
# because this method calls "clean_choices" resulting in a validation error when retrieving all facilites.
Facility._meta.get_field(
"available_voltage_services"
).from_db_value = _from_db_value
facilities = Facility.handleref.all()
for facility in facilities:
voltage = facility.available_voltage_services
removed = []

for invalid_voltage_value in invalid_voltage_values:
try:
voltage.remove(invalid_voltage_value)
removed.append(invalid_voltage_value)
except ValueError:
pass

if removed:
facility.available_voltage_services = voltage
print(f"Removed {removed} from {facility}")
facility.save()
finally:
Facility._meta.get_field(
"available_voltage_services"
).from_db_value = from_db_value
updated_field.auto_now = updated_field_auto_now


class Migration(migrations.Migration):
dependencies = [
(
"django_peeringdb",
"0033_alter_facility_property_alter_ixlan_rs_asn_and_more",
),
]

operations = [
migrations.RunPython(forward, migrations.RunPython.noop),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.16 on 2024-09-29 14:10

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("django_peeringdb", "0034_fix_voltage"),
]

operations = [
migrations.AlterField(
model_name="internetexchange",
name="media",
field=models.CharField(
choices=[
("Ethernet", "Ethernet"),
("ATM", "ATM"),
("Multiple", "Multiple"),
],
default="Ethernet",
max_length=128,
verbose_name="Media Type",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 4.2.16 on 2024-09-19 12:23

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("django_peeringdb", "0035_alter_ix_media_field_add_default_value"),
]

operations = [
migrations.AddField(
model_name="networkixlan",
name="net_side",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="net_side_set",
to="django_peeringdb.facility",
),
),
migrations.AddField(
model_name="networkixlan",
name="ix_side",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="ix_side_set",
to="django_peeringdb.facility",
),
),
]
4 changes: 3 additions & 1 deletion src/django_peeringdb/models/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ class InternetExchangeBase(HandleRefModel):
region_continent = models.CharField(
_("Continental Region"), max_length=255, choices=const.REGIONS
)
media = models.CharField(_("Media Type"), max_length=128, choices=const.MEDIA)
media = models.CharField(
_("Media Type"), max_length=128, choices=const.MEDIA, default="Ethernet"
)
proto_unicast = models.BooleanField(_("Unicast IPv4"), default=False)
proto_multicast = models.BooleanField(_("Multicast"), default=False)
proto_ipv6 = models.BooleanField(_("Unicast IPv6"), default=False)
Expand Down
15 changes: 15 additions & 0 deletions src/django_peeringdb/models/concrete.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,21 @@ class NetworkIXLan(NetworkIXLanBase):
on_delete=models.CASCADE,
)

net_side = models.ForeignKey(
Facility,
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="net_side_set",
)
ix_side = models.ForeignKey(
Facility,
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="ix_side_set",
)

def __str__(self):
return f"{self.net} @ {self.ixlan}"

Expand Down

0 comments on commit adbd530

Please sign in to comment.