dropbox / nsot

Network Source of Truth is an open source IPAM and network inventory database
https://nsot.readthedocs.io
Other
399 stars 66 forks source link

Network allocation features return the wrong results. #200

Closed jathanism closed 8 years ago

jathanism commented 8 years ago

Some quirks popped up while debugging the new CLI features for pynsot.

There's definitely a bug in next_address and next_network that's causing assigned or reserved addresses to be offered. There also seems to be a related bug where networks are not offered unless they no longer match any potential children, which is also bad.

These outputs are coming from the pre-release version of pynsot (v0.22)

Examples:

This network is assigned, which is a busy state.

$ nsot networks list -c 10.20.30.1/32
+---------------------------------------------------------------------------------+
| ID   Network      Prefix   Is IP?   IP Ver.   Parent ID   State      Attributes |
+---------------------------------------------------------------------------------+
| 16   10.20.30.1   32       True     4         15          assigned              |
+---------------------------------------------------------------------------------+

Yet it's showing as available:

$ nsot networks list -c 10.20.30.0/24 next_address -n 3
10.20.30.1/32
10.20.30.2/32
10.20.30.3/32

And if you add a random IP address into the mix, the next_network output is also weird

$ nsot networks add -c 10.20.30.104/32
[SUCCESS] Network added!

$ nsot networks list -c 10.20.30.0/24 next_network -n 2 -p 28
10.20.30.96/28
10.20.30.112/28

And then worse yet:

$ nsot networks list -c 10.20.30.0/24 next_address -n 2
10.20.30.105/32
10.20.30.106/32

Huh?