Feb-07-2019, 12:13 PM
You need to insert some initialization of your dict before loop in line # 39:
The code should look like the following:
The code should look like the following:
# .... result["interfaces"][intf_name].update({ "address": "n/a", "netmask": "n/a", "network": "n/a" }) for cmd in interface_cmd.re_search_children(IPv4_REGEX): # ciscoconfparse provides a helper function for this task ipv4_addr = interface_cmd.re_match_iter_typed(IPv4_REGEX, result_type=IPv4Obj) result["interfaces"][intf_name].update({ "address": ipv4_addr.ip.exploded, "netmask": ipv4_addr.netmask.exploded, "network": ipv4_addr.network.exploded }) # ...