-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix] Fixed subnet /32 & /128 pie chart error #129 #134
[fix] Fixed subnet /32 & /128 pie chart error #129 #134
Conversation
f2597fd
to
7d37e02
Compare
Coverage is decreasing, I need to work on this 😅 |
Only for subnet /32, it returns single host that's why we encountered tis bug To fix this we can use _prefixlen with subnet.subnet.max_prefixlen inside count() Fixes openwisp#129
Done 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Aryamanz29 there's no new test for testing this fix explicitly. Can you add a test that fails without this fix?
@pandafy Done requested changes 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Aryamanz29 the solution work and the code is good. I haven't tried the test yet but I will.
I have one request: I am not sure why I didn't test the same for IPv6 too but it seems to me that the problem happens there too with /128 subnets, can you fix that as well please? The solution and test used can be equivalent.
Sure, I'll check with /128 subnets and update 👍 |
Update : |
PR now ready for testing 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good progress @Aryamanz29, we're almost there, I noticed an issue with the visualization though, it happens both on IPv4 and IPv6:
In this case I created the IP address for this subnet to ensure the pie chart shows correctly.
However, the "subnet visual display" below is showing an address that doesn't belong to the subnet,
It should be showing 192.168.0.250
but it's instead showing the next address, it happens also on IPv6 can you fix that please?
@nemesisdesign openwisp-ipam/openwisp_ipam/api/views.py Line 132 in 4f15237
because of extra +1 in host (But don't know why we're adding +1 here 🤔 ), It always shows the next address. After removing, It looks good 👇
|
import ipaddress
subnet128 = ipaddress.ip_network('2001:db00::/128')
subnet32 = ipaddress.ip_network('198.168.0.250/32')
subnet8 = ipaddress.ip_network('10.0.0.0/8')
print(list(subnet128.hosts()))
print(list(subnet32.hosts()))
# Contains 16777214 hosts
print(list(subnet8.hosts())[:5]) (env) ➜ ipam-test py test.py
[IPv6Address('2001:db00::')]
[IPv4Address('198.168.0.250')]
[IPv4Address('10.0.0.1'), IPv4Address('10.0.0.2'), IPv4Address('10.0.0.3'), IPv4Address('10.0.0.4'), IPv4Address('10.0.0.5')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work @Aryamanz29, there's one outstanding issue which I highlighted below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍
subnet /32
pie chart.Fixes [bug] Subnet /32 gives error in pie chart #129
See comment #129 (comment)