При использовании следующей конфигурации Cisco IOS как получить IP-адрес интерфейса GigabitEthernet1/3 с помощью CiscoConfParse()?
!
hostname Example
!
interface GigabitEthernet1/1
description Example interface
ip address 192.0.2.1 255.255.255.128
no ip proxy-arp
!
interface GigabitEthernet1/2
shutdown
!
interface GigabitEthernet1/3
ip address 192.0.2.129 255.255.255.128
no ip proxy-arp
!
end
Я пытался использовать это, но оно выдает ошибку AttributeError...
from ciscoconfparse2 import CiscoConfParse
config = """!
hostname Example
!
interface GigabitEthernet1/1
description Example interface
ip address 192.0.2.1 255.255.255.128
no ip proxy-arp
!
interface GigabitEthernet1/2
shutdown
!
interface GigabitEthernet1/3
ip address 192.0.2.129 255.255.255.128
no ip proxy-arp
!
end
"""
parse = CiscoConfParse(config.splitlines(), syntax='ios', factory=False)
intf = parse.find_objects("interface GigabitEthernet1/3")[0]
print(f"GigabitEthernet1/3 address: {intf.ipv4}")
При этом выдается ошибка AttributeError...
AttributeError: The ipv4 attribute does not exist
Подробнее здесь: https://stackoverflow.com/questions/775 ... figuration