-
Notifications
You must be signed in to change notification settings - Fork 201
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
Netplan state diff #386
Netplan state diff #386
Conversation
Thanks for providing the PPA test builds! The I personally like the inline mode of Could you maybe prepare screenshots of the different modes presented in this PR, so we could bring it up for discussion during the next Netplan sync? |
60ce1b7
to
9b7954b
Compare
0c2cf1c
to
7fe90f8
Compare
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 very much for working on this and going the extra mile of making all the required data available via libnetplan's API!
This is not yet a full review, as I'm running out of time here, but I wanted to leave some initial comments.
This PR will get in conflict with #385 (due to the export of the iterators via Python's ctypes, vs cffi). I wonder if we should already start rebasing it on top of that other PR?
netplan_cli/cli/state.py
Outdated
route = route + f' table {self.table}' | ||
return route | ||
|
||
def __eq__(self, route): |
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.
note: This will be interesting, comparing routes is tricky. I'll need to have a closer look into that.
7fe90f8
to
c956af8
Compare
c956af8
to
4c6d7a8
Compare
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 for rebasing on top of the CFFI bindings! This is still a big PR and we might not be able to get it fully landed for inclusion in v0.107 today.
e6c31fc
to
7490e8f
Compare
011f078
to
2c785e3
Compare
Hi Lukas, thanks for reviewing this PR. I tried to address the issues you've found and answer your questions. I think it's looking a bit better now. |
2c785e3
to
fd8f80a
Compare
045b336
to
a24d267
Compare
There are some fields that exist in Netplan but not in the system and vice-versa, such as on-link and protocol. Using the default dataclass methods makes it harder to compare objects.
a24d267
to
669e1cb
Compare
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 addressing my comments!
I have one tiny nitpick inline, which I'd like to see fixed. But after that, I think this should be ready for merging.
65da003
to
6418296
Compare
The state_diff submodule is responsible for comparing system's and netplan's states and calculating the differences. The new class NetplanDiffState must be instantiated with both states. The method get_full_state() will return both system's and netplan's states without calculating the differences. The diff calculation will be added in the next commits.
The get_diff() will calculate the differences between system's and Netplan's states and return a report to the caller. This commit adds support for checking what interfaces are present only in one of the states.
get_diff() will compare and report differences in the addresses present in the system and Netplan. Addresses detected as dynamically assigned will not be reported as missing as they will not be defined in Netplan.
A number of heuristics are implemented to eliminate routes we don't want to compare, such as routes installed dynamically, as they will not be found in Netplan.
It will be used to serialize the state and diff.
For netplan interfaces add the name and type. For system interfaces add the name, type and index.
Also add a few integrations tests that use tools/diff.py to test the diff against a running system configured with Netplan.
6418296
to
5fddf54
Compare
Description
This is the first iteration of the
diff
feature. At the moment, only a few number of resources are analyzed:A number of heuristics were used to eliminate configuration we don't want to compare. These are basically settings that are very likely assigned automatically, such as IPs and routes assigned via DHCP. The reason for that is that this information will not be found in Netplan.
For example: if the interface has
dhcp4
enabled and an empty list of addresses in Netplan, we don't report to the user that the IP that is assigned, via DHCP, to that interface in the system is not present in Netplan. We do report though the case where the interface has no IPs but DHCP is enabled in Netplan and when extra IPs are found.Experimental user interface
It still doesn't include a user interface for the data presentation, but I have an experimental one available in a separate branch.
I added a new experimental command,
netplan diff
, to enable people to look at one of the suggestions for the user interface. I also added a--diff
tonetplan status
that makes the diff be shown along with the original information. None of this is definitive and can be changed/removed as I get peoples opinions.I packaged it in a PPA. It's available here: https://launchpad.net/~danilogondolfo/+archive/ubuntu/netplan-diff/
Please, install the PPA and try running
netplan status --all --diff
andnetplan diff
and let me know your opinion :)netplan diff
accepts the parameter-s
which you can use to change the table style. There are 6 styles available, from 0 to 5.Checklist
make check
successfully.make check-coverage
).