我正在尝试在 Cisco IOS 配置上使用 CiscoConfParse,其中接口的地址超过 IPv6 地址,而我只获得第一个 IP 地址。下面的代码、输入文件和输出我在这里做错了什么?任何指导表示赞赏。
confparse = CiscoConfParse("ipv6_ints.txt")
# extract the interface name and description
# first, we get all interface commands from the configuration
interface_cmds = confparse.find_objects(r"^interface ")
# iterate over the resulting IOSCfgLine objects
for interface_cmd in interface_cmds:
# get the interface name (remove the interface command from the configuration line)
intf_name = interface_cmd.text[len("interface "):]
result["interfaces"][intf_name] = {}
IPv6_REGEX = (r"ipv6\saddress\s(\S+)")
for cmd in interface_cmd.re_search_children(IPv6_REGEX):
ipv6_addr = interface_cmd.re_match_iter_typed(IPv6_REGEX, result_type=IPv6Obj)
result["interfaces"][intf_name].update({
"ipv6": {
"ipv6 address": ipv6_addr.compressed,
}
})
print("\nEXTRACTED PARAMETERS\n")
print(json.dumps(result, indent=4))
输入文件