-
Couldn't load subscription status.
- Fork 2
Network update and first method comments #1
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
base: main
Are you sure you want to change the base?
Conversation
Changed network definition with more fitting defaults Compined ipv4_subnet and ipv4 into ipv4_cidr to be more consistent with other uses of ipv4 updated test.py and range.py for new network setup renamed network.rm() to be consistent with network.destroy_by_name()
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.
Thank you for your contribution; changing the API to simplify handling of IPv4 addresses is a great idea. Also thank you for going through the hassle of writing comments and type hints.
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.
I think it would be good to also change how ipv4 is used with Interfaces so the api is consistent in that matter. So that Interfaces work with the cidr representation as well instead of prefix_length and ipv4
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.
It would probably be wise also do this for ipv6 in general as well right?
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.
yeah but ipv6 is not even fully implemented yet, i open an issue for that #2
cave/src/networks/network/network.py
Outdated
| import ipaddress | ||
| import jinja2 | ||
| import re | ||
| import socket | ||
| import struct |
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.
Do we actually need socket and struct for the IP parsing, maybe ipaddress offers the functionality you need?
added ipv6 cidr changed ipv4 splitting logic cleanup
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.
Some small change requests.
Thank you for your support :) 🐈
| self.ipv6_prefix = ipv6_tuple[1] | ||
| else: | ||
| self.ipv6 = "" | ||
| self.ipv6_subnet = "" |
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.
Did you mean self.ipv6_prefix = "" instead of self.ipv6_subnet = "" ?
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.
Other components of cave (e.g. this line) use the ipv4 and prefix_length properties, so we cannot remove them.
Maybe change Interface to a normal class and do the calculation of ipv4 and prefix_length from ipv4_cidr in the constructor like done in network.py?
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.
We could then also include sanity checks in the constructor e.g. assert "/" in ipv4_cidr, this is not a clean solution but we are just building a prototype here for now.
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.
Would it make sense to introduce a utility module to ease the introduction of functionalities, which are reused throughout cave? This would also ease the introduction of argument validation etc. in the future.
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.
I think for now it is not really necessary
| network=mngt, | ||
| ipv4="10.10.0.3", | ||
| prefix_length=24, | ||
| ipv4_cidr="10.10.0.3", |
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.
Is here a /24 missing?
Changed network definition with more fitting defaults
Combined ipv4_subnet and ipv4 into ipv4_cidr to be more consistent with other uses of ipv4
updated test.py and range.py for new network setup
renamed network.rm() to be consistent with network.destroy_by_name()