diff --git a/oxi/interface/base.py b/oxi/interface/base.py index ba40d5b..de7c72a 100644 --- a/oxi/interface/base.py +++ b/oxi/interface/base.py @@ -1,3 +1,4 @@ +import ipaddress import re from dataclasses import dataclass from typing import Protocol @@ -81,7 +82,12 @@ class BaseDevice(Protocol): ip_address_match = re.search(r'\s?ip address\s(.+)$', interface_block, re.MULTILINE) if not description_match and not ip_address_match: continue - ip_address = ip_address_match.group(1).replace(' ', '/') if ip_address_match else None + ip_address = ip_address_match.group(1).replace(' ', '/').replace('\r', '') if ip_address_match else None + try: + if ip_address is not None: + ip_address = ipaddress.ip_interface(ip_address) + except ValueError: + continue description = description_match.group(1) if description_match else None interfaces.append(L3Interface( interface=interface_name,