Skip to content

Network functions refactor and bugfixes#1383

Merged
holmanb merged 2 commits into
canonical:mainfrom
holmanb:holmanb/network-refactor
Apr 15, 2022
Merged

Network functions refactor and bugfixes#1383
holmanb merged 2 commits into
canonical:mainfrom
holmanb:holmanb/network-refactor

Conversation

@holmanb
Copy link
Copy Markdown
Member

@holmanb holmanb commented Apr 15, 2022

Network functions refactor and bug fixes

- replace common functionality with standard library implementations
- add is_ip_network() for validating addresses in form: "192.168.1.1/24"
- add validation to _normalize_net_keys
- fix eni tests that formerly tested invalid ipv6 addresses (caught by
  stricter validation)
- other refactorization and name standardization

Fixing is_ipv6_addr() broke a lot of tests, which demonstrated that it was implemented incorrectly and used incorrectly.

@holmanb holmanb force-pushed the holmanb/network-refactor branch from b00bdc2 to 226a066 Compare April 15, 2022 18:50
@holmanb holmanb requested a review from TheRealFalcon April 15, 2022 18:57
addr_part, _, maybe_prefix = addr.partition("/")
net[addr_key] = addr_part
try:
prefix = int(maybe_prefix)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this try/except was redundant: ipv{4,6}_mask_to_net_prefix() can handle an argument already in prefix form.

- replace common functionality with standard library implementations
- add is_ip_network() for validating addresses in form: "192.168.1.1/24"
- add validation to _normalize_net_keys
- fix eni tests that formerly tested invalid ipv6 addresses (caught by
  stricter validation)
- other refactorization and name standardization
@holmanb holmanb force-pushed the holmanb/network-refactor branch from 226a066 to 7d7ff5f Compare April 15, 2022 19:22
Copy link
Copy Markdown
Contributor

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice refactoring, thanks! One spelling error inline, but I trust you can fix that without needing a re-review. Now just waiting for the https://xkcd.com/1172/ bugs.

Comment thread cloudinit/net/__init__.py Outdated
@holmanb holmanb merged commit 171490d into canonical:main Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants