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

[Snap] Implement Network Settings #3155

Open
benfrancis opened this issue Aug 21, 2024 · 8 comments · May be fixed by #3168
Open

[Snap] Implement Network Settings #3155

benfrancis opened this issue Aug 21, 2024 · 8 comments · May be fixed by #3168
Labels
snap Issues relating to the snap package story
Milestone

Comments

@benfrancis
Copy link
Member

As a user I want to be able to configure my network settings when using the snap package so that I can connect my gateway to a network.

Currently clicking on Network Settings in the web interface when using the snap package on Ubuntu displays a message which says "Network settings are not supported for this platform." This is because network settings are not implemented for Ubuntu, or Ubuntu Core.

This will require implementing network settings using NetworkManager in linux-ubuntu.ts and/or creating a linux-ubuntu-core.ts in /src/platforms.

See https://github.com/krellian/kiosk/blob/master/services/models/network.js for inspiration.

This will likely also require the snap to be permitted to use an additional interface.

@benfrancis benfrancis added story snap Issues relating to the snap package labels Aug 21, 2024
@benfrancis benfrancis added this to the 2.0 milestone Aug 21, 2024
@benfrancis benfrancis changed the title [Snap] Implement Network Settings for snap package [Snap] Implement Network Settings Aug 22, 2024
@benfrancis
Copy link
Member Author

@ogra1 The way I have been planning to implement this is to request the network-manager interface and configure networking by communicating with NetworkManager over D-Bus from Node.js. I previously did something similar for Krellian Kiosk, but it's quite low level and fiddly to implement and I found the documentation of the NetworkManager D-Bus API quite difficult to understand.

I note that there appear to be multiple interfaces for modifying network settings so before I make a start on this, is there a simpler approach I should be considering?

The WebThings Gateway user manual should give you an idea of the kinds of settings which need to be modified from Node.js.

There are other settings that will need implementing later including configuring mDNS, and a Wi-Fi hotspot during first time setup.

@benfrancis
Copy link
Member Author

Potential approaches to implementing networking on Ubuntu Core:

@benfrancis
Copy link
Member Author

  • network-manager interface "enables access to NetworkManager, providing privileged access to configure and observe networking." - Does this just mean via DBus, or also the nmcli command line interface?
    • dbus npm module to provide raw access to dbus

FYI I've made a start using this approach in #3168 so we'll see how it goes.

@dilyn-corner
Copy link
Contributor

"enables access to NetworkManager, providing privileged access to configure and observe networking." - Does this just mean via DBus, or also the nmcli command line interface?

If you include nmcli in the snap, you should be able to use it. You can see what the network-manager snap does to accomplish its tasks in this matter.

@benfrancis
Copy link
Member Author

benfrancis commented Oct 22, 2024

@dilyn-corner wrote:

If you include nmcli in the snap, you should be able to use it. You can see what the network-manager snap does to accomplish its tasks in this matter.

Hah, it would have been useful to know that ~1,000 lines of code ago! But by the looks of it that requires building nmcli from source inside my snap, which seems a bit excessive. And my assumption was that the DBus API would be more stable than the command line interface. So possibly simpler from the application code point of view, but definitely more complicated from a multi-architecture build point of view.

Having spent a large proportion of the last few weeks implementing network settings for the gateway using the DBus API (which is now nearly finished) I guess I'm kind of committed to that route now, so I'll have to see how it goes.

@dilyn-corner
Copy link
Contributor

😅 I do agree that the dbus API is probably more stable and it is usually the way I'd recommend going.

@benfrancis
Copy link
Member Author

@dilyn-corner / @ogra1 I'm seeing something odd I can't explain.

I'm setting a static IP address (and subnet and gateway) via the NetworkManager D-Bus API on Ubuntu Desktop, using org.freedesktop.NetworkManager.Settings.Connection.Update(). It appears to save the settings successfully and when I view network settings in the Ubuntu Settings UI or with nmcli it shows the new settings. However, if I then check my current IP address using ip a or hostname -I I see the old IP address.

What am I missing?

@benfrancis
Copy link
Member Author

Huh, it appears that Update() does not actually update the settings, you have to call Reapply() on the Device object or re-active the connection in order for the changes to take effect...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
snap Issues relating to the snap package story
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

2 participants