mirror of
https://github.com/thatmattlove/hyperglass.git
synced 2026-04-17 21:38:27 +00:00
Fix: Make Huawei BGP parser conform to MikroTik approach
- Remove custom __init__ from HuaweiBGPRouteTable class - Use standard BGPRouteTable inheritance like MikroTik does - Add BGPRoute import and instantiate BGPRoute objects in bgp_table() - Enable proper Pydantic validation for both table and routes - Ensure consistent behavior across all BGP parsers - Update .gitignore to exclude dev-build.sh and dev-docker/
This commit is contained in:
parent
4414d2ec03
commit
d025630b83
2 changed files with 6 additions and 10 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -2,6 +2,8 @@
|
|||
hyperglass/hyperglass/static
|
||||
TODO*
|
||||
.env
|
||||
dev-build.sh
|
||||
dev-docker/
|
||||
|
||||
test.py
|
||||
.DS_Store
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from pydantic import ConfigDict, field_validator, model_validator
|
|||
|
||||
# Project
|
||||
from hyperglass.log import log
|
||||
from hyperglass.models.data.bgp_route import BGPRouteTable
|
||||
from hyperglass.models.data.bgp_route import BGPRoute, BGPRouteTable
|
||||
|
||||
# Local
|
||||
from ..main import HyperglassModel
|
||||
|
|
@ -318,15 +318,9 @@ def _extract_route_entries(lines: t.List[str]) -> t.List[HuaweiRouteEntry]:
|
|||
|
||||
|
||||
class HuaweiBGPRouteTable(BGPRouteTable):
|
||||
"""Custom BGP Route Table for Huawei that bypasses validation."""
|
||||
"""Canonical Huawei BGP Route Table."""
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
"""Initialize without calling parent validation."""
|
||||
# Set attributes directly without validation using object.__setattr__
|
||||
object.__setattr__(self, "vrf", kwargs.get("vrf", "default"))
|
||||
object.__setattr__(self, "count", kwargs.get("count", 0))
|
||||
object.__setattr__(self, "routes", kwargs.get("routes", []))
|
||||
object.__setattr__(self, "winning_weight", kwargs.get("winning_weight", "low"))
|
||||
# No custom __init__ needed; inherit from BGPRouteTable (which should be a Pydantic model)
|
||||
|
||||
|
||||
class HuaweiBGPTable(HuaweiBase):
|
||||
|
|
@ -388,7 +382,7 @@ class HuaweiBGPTable(HuaweiBase):
|
|||
RPKI_STATE_MAP.get("unknown") if route.is_valid else RPKI_STATE_MAP.get("valid")
|
||||
),
|
||||
}
|
||||
routes.append(route_data)
|
||||
routes.append(BGPRoute(**route_data))
|
||||
|
||||
return HuaweiBGPRouteTable(
|
||||
vrf="default",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue