Skip to content
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

Implement netplan get/set CLI and DBus API #163

Merged
merged 35 commits into from Sep 30, 2020
Merged

Implement netplan get/set CLI and DBus API #163

merged 35 commits into from Sep 30, 2020

Conversation

slyon
Copy link
Collaborator

@slyon slyon commented Sep 10, 2020

Description

Implements the netplan get [nested.key] / set nested.key=value CLI and io.netplan.Netplan.Get() / Set(String configDelta, String originHint) DBus API.

It allows to get/set values from/to the merged netplan configuration as scalar, sequence or mappings.

Validation of settings, added via netplan set ..., is done by calling into the libnetplan parser using Python ctypes. Whereas the netplan get [...] command makes use of netplan's Python parser (config_manager). This is to keep it simple for now, unifying the parsers will be for another time...

Examples

netplan get
netplan get ethernets.eth0.dhcp4
netplan set ethernets.eth0.dhcp4=true --origin-hint=99_snapd --root-dir=/tmp
netplan set "network.ethernets.eth0={addresses: [1.2.3.4/24], dhcp4: true}"

busctl call io.netplan.Netplan /io/netplan/Netplan io.netplan.Netplan Get
busctl call io.netplan.Netplan /io/netplan/Netplan io.netplan.Netplan Set ss "network.ethernets.eth3={addresses: [5.6.7.8/24], dhcp4: no}" ""

Checklist

  • Runs make check successfully.
  • Retains 100% code coverage (make check-coverage).
  • New/changed keys in YAML format are documented.
  • (Optional) Closes an open bug in Launchpad.

@slyon slyon changed the title UC20: netplan set [Draft] UC20: netplan set Sep 10, 2020
@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2020

Codecov Report

Merging #163 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #163      +/-   ##
==========================================
+ Coverage   88.16%   88.19%   +0.02%     
==========================================
  Files           9        9              
  Lines        2771     2778       +7     
==========================================
+ Hits         2443     2450       +7     
  Misses        328      328              
Impacted Files Coverage Δ
src/parse.c 92.57% <100.00%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8286ce...b3a3d50. Read the comment docs.

@slyon slyon force-pushed the slyon/uc20-set branch 2 times, most recently from fc9522f to a9e694a Compare September 18, 2020 15:25
@slyon slyon changed the title [Draft] UC20: netplan set Implement netplan get/set CLI and DBus API Sep 22, 2020
@slyon slyon marked this pull request as ready for review September 22, 2020 11:10
Copy link
Collaborator

@sil2100 sil2100 left a comment

Choose a reason for hiding this comment

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

Thank you for yet another awesome PR! Love the test coverage btw. This is generally good to go, although I left a few comments inline regarding possible changes and/or improvements.

netplan/cli/commands/set.py Outdated Show resolved Hide resolved
netplan/cli/commands/get.py Show resolved Hide resolved
netplan/cli/commands/set.py Outdated Show resolved Hide resolved
netplan/cli/commands/set.py Outdated Show resolved Hide resolved
netplan/cli/commands/set.py Outdated Show resolved Hide resolved
src/parse.c Show resolved Hide resolved
netplan/cli/commands/set.py Outdated Show resolved Hide resolved
netplan/cli/commands/set.py Outdated Show resolved Hide resolved
@slyon
Copy link
Collaborator Author

slyon commented Sep 30, 2020

Thanks again for your very constructive review! I cleaned & fixed up according to your comments.

Ready for merge \o/

@slyon slyon merged commit a1497d1 into master Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants