dne-dna-code
dne-dna-code copied to clipboard
intro-mdp/mission01/netconf_functions.py doesn't handle multiple addresses
trafficstars
When running the solution, I get the following error:
Device: ios-xe-mgmt.cisco.com
Interface: GigabitEthernet2
Traceback (most recent call last):
File "netconf_configure_ips.py", line 62, in <module>
check_ip(device)
File "/Users/mbrainar/coding/DevNet/dnav3-code/intro-mdp/mission01/netconf_functions.py", line 81, in check_ip
ipv4["ip"], ipv4["config"]["prefix-length"]
TypeError: list indices must be integers or slices, not str
I believe it is because the instance of ios-xe-mgmt.cisco.com has multiple addresses configured on GigabitEthernet2:
<ipv4 xmlns="http://openconfig.net/yang/interfaces/ip">
<addresses>
<address>
<ip>10.255.255.1</ip>
<config>
<ip>10.255.255.1</ip>
<prefix-length>24</prefix-length>
</config>
</address>
<address>
<ip>10.255.255.10</ip>
<config>
<ip>10.255.255.10</ip>
<prefix-length>31</prefix-length>
</config>
</address>
<address>
<ip>10.255.255.12</ip>
<config>
<ip>10.255.255.12</ip>
<prefix-length>24</prefix-length>
</config>
</address>
</addresses>
</ipv4>
Just an FYI, but the openconfig model in theory allows multiple IP addresses on a subinterface. The first should be assigned as the primary IP and other should be added as secondary IP addresses. However, the problem above seems to be more about a Python coding error.