From 226e1daad55813cbe67d9a29c86f64708d332bb1 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 3 Jul 2025 15:32:16 +0000 Subject: [PATCH] mirrors: Add the AS name if available to the export Signed-off-by: Michael Tremer --- src/buildservice/mirrors.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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, -- 2.47.2