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

Fix for #251 - Strict Allocations #256

Closed rmhasan closed 7 years ago

rmhasan commented 7 years ago

Fix for #251. This PR, adds a simple implementation of the get_next_network method, which also performs strict allocation. I added 3 test cases to the test_networks.py script in model_tests folder. I had to modify a couple tests because their expected results were based on loose allocation. I changed the results to those expected for strict allocation. Please refer to commit rmhasan@714f63ec0dbb8017156eb0cacda16efff8a9feab.

rmhasan commented 7 years ago

Looks like I might need to modify some of the tests. I'll take a look at the errors brought up in the travis cl build.

rmhasan commented 7 years ago

As asked in issue #251, Lets say you have the three following networks for a site.

10.2.1.0/24
10.2.1.0/25
10.2.1.192/27

And you want to execute the command nsot networks list -s 2 -c 10.1.2.0/24 next_network -p 26 -n 3 would you want 10.2.1.128/26 to be listed. It is the parent of 10.2.1.192/27.

rmhasan commented 7 years ago

Hi @jathanism and @nickpegg I finished all my work on this pull request. I added three tests to test_networks.py in the model_tests sub directory. If you want me to do any more tests please let me know. Can someone please review this pull request.

rmhasan commented 7 years ago

rebased for v1.1 release

jathanism commented 7 years ago

@rmhasan Thank you. We will take a look at this soon, I promise. I appreciate your contribution!

rmhasan commented 7 years ago

Hi @jathanism I made some changes so that strict allocation is optional and a pull request in pynsot to pass a -s/--strict-allocation flag to the next_network and next_address actions. The PR can be found at dropbox/pynsot#128 .

jathanism commented 7 years ago

@rmhasan Cool! Thanks! One other thing I noticed. Can you please update your pull request base to dropbox:develop? I'm really trying to get a look at this today if at all possible.

rmhasan commented 7 years ago

Hi @jathanism , I made the changes you and @nickpegg suggested. And I changed the base of the PR to dropbox:develop for both this PR and the PR I created in pynsot, dropbox/pynsot#128.

nickpegg commented 7 years ago

The latest commits look good to me. @rmhasan thanks for this contribution!

@jathanism: if it looks good to you, let's ship this thing!

rmhasan commented 7 years ago

Hi @jathanism and @nickpegg, there are security vulnerabilities with django-smart-selects versions 1.2.8 and below. I opened PR #263. I modified the requirements.txt file in this branch to use django-smart-selects==1.2.9 as well.