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

HackWeek Project: Learn to develop some Rust terminal UI for Agama #1

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

teclator
Copy link
Owner

@teclator teclator commented Nov 14, 2023

During this HackWeek some of us wanted to play a little bit with some Rust TUI frameworks in order to provide and alternative way to interact with the Agama installer. (see https://hackweek.opensuse.org/23/projects/tui-interface-for-agama)

So, following @ancorgs idea I was learning and playing a little bit with https://github.com/ratatui-org/ratatui and with https://github.com/veeso/tui-realm.

After learning some basics I tried to create an interface for configuring a Bond with some of the system available devices but as the Bond support in Agama is still in process I wasn't able to finish the POC but it is almost done.

In this branch and repository we can see the changes about the bonding support I was working before and during the Hackweek and also the TUI done for creating the bond.

Update: After last changes it already creates a bond configuration.

$nmcli c

NAME                     UUID                                  TYPE      DEVICE  
bond0                    5f032a2d-d992-4633-b0e6-bcda0799b174  bond      bond0   
Wired connection 1       48df1605-fe53-4391-b3b1-5834da02adda  ethernet  ens1    
lo                       5f6f32bc-38a2-465f-855b-36e8d3225429  loopback  lo      
enp0s25                  13c08f4a-d9d9-4db8-a2ee-a72708a1c6aa  ethernet  enp0s25 

$cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v6.5.8-1-default

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: None
MII Status: down
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0

Slave Interface: enp0s25
MII Status: down
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 50:9a:4c:46:cc:0f
Slave queue ID: 0

Screenshots

Screenshot from 2023-11-14 10-25-51

@coveralls
Copy link

coveralls commented Nov 14, 2023

Pull Request Test Coverage Report for Build 6966588901

  • 76 of 137 (55.47%) changed or added relevant lines in 10 files are covered.
  • 253 unchanged lines in 25 files lost coverage.
  • Overall coverage increased (+0.2%) to 75.593%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rust/agama-dbus-server/src/network/nm/model.rs 0 1 0.0%
rust/agama-lib/src/network/client.rs 27 29 93.1%
rust/agama-dbus-server/src/network/system.rs 0 7 0.0%
rust/agama-dbus-server/src/network/nm/dbus.rs 8 17 47.06%
rust/agama-dbus-server/src/network/dbus/interfaces.rs 26 47 55.32%
rust/agama-dbus-server/src/network/nm/client.rs 0 21 0.0%
Files with Coverage Reduction New Missed Lines %
rust/agama-lib/src/network/settings.rs 1 94.74%
web/src/components/overview/Overview.jsx 1 87.5%
web/src/components/overview/SoftwareSection.jsx 1 92.0%
web/src/context/notification.jsx 1 85.19%
web/web/src/components/overview/Overview.jsx 1 85.71%
web/web/src/components/overview/SoftwareSection.jsx 1 95.24%
web/web/src/context/notification.jsx 1 95.83%
rust/agama-lib/src/network/types.rs 2 76.92%
web/src/client/dbus.js 2 58.33%
web/web/src/client/dbus.js 2 61.29%
Totals Coverage Status
Change from base Build 6962713425: 0.2%
Covered Lines: 15053
Relevant Lines: 19649

💛 - Coveralls

teclator added a commit to agama-project/agama that referenced this pull request Dec 15, 2023
This PR adds support for configuring a Bond connection using Agama
auto-installation.

## The model

Initially, we thought each connection struct would take ownership of its
ports (basically, other connections). However, after some discussion
with the networking team, we agreed to keep a "reference" in the
opposite direction (from the port to the controller). At this point,
each connection that belongs to a bond keeps its parent UUID.

## Configuring a port

When using the auto-installation you can define the port with something
like this:

```rust
      {
        id: 'bond0',
        bond: {
            ports: ['eth0', 'eth1'],
            mode: 'active-backup',
            options: "primary=eth1"

        }
      },
      {
        id: 'Wired Adapter 1',
        interface: 'eth1'
      }
```

In NetworkManager, it is mandatory to specify an interface name.
However, Agama will use the `id` if you do not define the `interface`.
About the ports, it is not required to define them (in the example
above, `eth0` is missing). Agama will create a connection automatically.
And, again, you can use the `id` or the `interface` to link both
connections.

## Improving the D-Bus interface

As the list of ports is not part of the `BondConnection` struct, it is
not straightforward to expose that information in the D-Bus interface.
After all, the code that exposes each connection over D-Bus only had
access to the information of its specific connection (actually, it owns
a clone of the connection).

For that reason, starting with the
[Bond](https://github.com/openSUSE/agama/blob/add_bonding_support/rust/agama-dbus-server/src/network/dbus/interfaces.rs#L312)
interface, we implemented a better mechanism (based on message passing)
to interact with the data model. We will open a separate PR to adapt the
rest of interfaces (with more information about the problems it solves).

## What's next?

* #918
* #924 
* Fix a ton of issues detected by Clippy.

## References

* @cfconrad started to work on bonding support on #783.

## Testing

* Tested manually (see teclator#1).
* Added some unit and integration tests.
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.

3 participants