From: Michael Tremer Date: Thu, 3 Jul 2025 15:32:16 +0000 (+0000) Subject: mirrors: Add the AS name if available to the export X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=226e1daad55813cbe67d9a29c86f64708d332bb1;p=pbs.git mirrors: Add the AS name if available to the export Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/mirrors.py b/src/buildservice/mirrors.py index 576cd319..3afa5c4a 100644 --- a/src/buildservice/mirrors.py +++ b/src/buildservice/mirrors.py @@ -242,6 +242,24 @@ class Mirror(sqlmodel.SQLModel, database.BackendMixin, database.SoftDeleteMixin, asn: int + # AS Name + + @pydantic.computed_field + @property + def as_name(self) -> str | None: + # Return nothing if we don't have an ASN + if self.asn is None: + return None + + # Fetch the AS + network = self.backend.mirrors.location.get_as(self.asn) + + # Return None if we could not find a match + if network is None: + return None + + return network.name + # Addresses IPv6 addresses_ipv6: list[ipaddress.IPv6Address] = sqlmodel.Field(exclude=True,