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.next_network() returns the wrong result #216

Closed jathanism closed 8 years ago

jathanism commented 8 years ago

There's an issue where Network.next_network() is not returning the correct value. It's a technically correct network, but not semantically correct.

Consider this example:

$ nsot networks list -c 10.20.0.0/16 next_network -p 21
10.20.0.0/21

This is incorrect, because look at the existing children for this network:

$ nsot networks list -c 10.20.0.0/16 -N children
10.20.0.0/24
10.20.1.0/24
10.20.2.0/24
10.20.3.0/24
10.20.4.0/24
10.20.5.0/24
10.20.6.0/24
10.20.7.0/24
10.20.8.0/24
10.20.9.0/24
10.20.10.0/24
10.20.11.0/24
10.20.12.0/24
10.20.13.0/24
10.20.14.0/24
10.20.15.0/24
10.20.16.0/24
10.20.17.0/24
10.20.18.0/24
10.20.19.0/24
10.20.20.0/24
10.20.21.0/24
10.20.22.0/24
10.20.23.0/24
10.20.24.0/24
10.20.25.0/24
10.20.26.0/24
10.20.27.0/24
10.20.28.0/24
10.20.29.0/24
10.20.32.0/21
10.20.40.0/21
10.20.48.0/21
10.20.56.0/21
10.20.64.0/21
10.20.72.0/21
10.20.80.0/21
10.20.88.0/21
10.20.96.0/21
10.20.104.0/21
10.20.112.0/21
10.20.120.0/21
10.20.128.0/21
10.20.136.0/21
10.20.144.0/21
10.20.152.0/21
10.20.160.0/21
10.20.168.0/21
10.20.176.0/21
10.20.184.0/21
10.20.224.0/24
10.20.225.0/24
10.20.226.0/24
10.20.227.0/24
10.20.228.0/24
10.20.229.0/24
10.20.230.0/24
10.20.231.0/24

The correct response should be 10.20.192.0/21.

We need to fix it so that it considers any proposed network with children to be "dirty" or ineligible for allocation.