Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Fix: Static IP address with device specific value converted to dynami…
Browse files Browse the repository at this point in the history
…c IP address #67
  • Loading branch information
jpkrajewski committed Jul 9, 2024
1 parent de4596d commit f588178
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,26 @@ def parse_tunnel_interface(self, data: Dict) -> Optional[Global[bool]]:

def parse_interface_ip_address(self, data: Dict) -> Union[InterfaceDynamicIPv4Address, InterfaceStaticIPv4Address]:
ip_address = data.get("ip", {})

if "address" in ip_address and ip_address["address"].value != "":
return InterfaceStaticIPv4Address(
static=StaticIPv4AddressConfig(
primary_ip_address=self.get_static_ipv4_address(ip_address),
secondary_ip_address=self.get_secondary_static_ipv4_address(ip_address),
)
)

elif "dhcp_client" in ip_address:
return InterfaceDynamicIPv4Address(
dynamic=DynamicDhcpDistance(dynamic_dhcp_distance=ip_address.get("dhcp_distance", as_default(1)))
)

address = data.get("address")
if isinstance(address, Variable):
return InterfaceStaticIPv4Address(
static=StaticIPv4AddressConfig(
primary_ip_address=StaticIPv4Address(
ip_address=address,
)
),
)
return InterfaceDynamicIPv4Address(dynamic=DynamicDhcpDistance())

def get_static_ipv4_address(self, address_configuration: dict) -> StaticIPv4Address:
Expand Down

0 comments on commit f588178

Please sign in to comment.