Skip to content

Add additional wireless settings#1602

Merged
imobachgs merged 4 commits intoagama-project:masterfrom
jcronenberg:additional_wireless_settings
Sep 13, 2024
Merged

Add additional wireless settings#1602
imobachgs merged 4 commits intoagama-project:masterfrom
jcronenberg:additional_wireless_settings

Conversation

@jcronenberg
Copy link
Copy Markdown
Contributor

@jcronenberg jcronenberg commented Sep 13, 2024

Problem

Network model was missing some required fields for the wicked migration.

Solution

Added the required fields to both the model and settings. I've also added some fields present in the model to be available via the settings.

Testing

  • Extended existing unit tests
  • Tested manually
sudo agama auth login && AGAMA_TOKEN=`sudo agama auth show`
curl http://localhost/api/network/connections \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $AGAMA_TOKEN" \
    -d '{ "id": "wifi", "method4": "auto", "method6": "auto", "ignoreAutoDns": false, "wireless": { "security": "wpa-psk", "ssid": "test-ssid", "mode": "infrastructure", "groupAlgorithms": [ "wep40", "wep104" ], "pairwiseAlgorithms": [ "tkip", "ccmp" ], "wpaProtocolVersions": [ "wpa" ], "pmf": 2, "hidden": true, "band": "a", "channel": 100, "bssid": "12:34:56:78:9A:BC" }, "status": "down" }'
curl -X POST http://localhost/api/network/system/apply \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $AGAMA_TOKEN"
nmcli con show wifi
# See relevant fields in 802-11-wireless.* and 802-11-wireless-security.* set.

Copy link
Copy Markdown
Contributor

@imobachgs imobachgs left a comment

Choose a reason for hiding this comment

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

In general it looks good, just a few comments. Thanks!

]
},
"hidden": {
"title": "Indicates that the wifi network is not broadcasting it's SSID",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should it be "wifi", "Wi-Fi", wireless... In this schema we have been using "wireless" but we can change it. Just for consistency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think wireless is fine. I changed the descriptions accordingly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OK, we will plan for that.

#[error("Invalid group algorithm: {0}")]
pub struct InvalidGroupAlgorithm(String);

impl FromStr for GroupAlgorithm {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For some time, I have been thinking whether we should use strum (see the EnumString example) to avoid all those trivial conversions.

I am not sure about how error handle would be, but I think it is worth having a closer look.

In any case, it is out of the scope of this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Totally agree, strum would make this a lot simpler 🙂

let group_algorithms: Vec<GroupAlgorithm> = group_algorithms
.get()
.iter()
.map(|x| x.downcast_ref::<str>().unwrap())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Those unwraps are dangerous because is something goes wrong, the whole service would go down. Perhaps you might want to split this chain into smaller functions.

Copy link
Copy Markdown
Contributor Author

@jcronenberg jcronenberg Sep 13, 2024

Choose a reason for hiding this comment

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

This is the testing code. The code for the service does use the proper error handling.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ouch, Friday afternoon, you know 😅

let group_algorithms: Vec<GroupAlgorithm> = group_algorithms
.get()
.iter()
.map(|x| x.downcast_ref::<str>().unwrap())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ouch, Friday afternoon, you know 😅

@imobachgs imobachgs merged commit af3c4f6 into agama-project:master Sep 13, 2024
@jcronenberg jcronenberg deleted the additional_wireless_settings branch September 16, 2024 08:50
@imobachgs imobachgs mentioned this pull request Sep 20, 2024
imobachgs added a commit that referenced this pull request Sep 20, 2024
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Sep 23, 2024
https://build.opensuse.org/request/show/1202589
by user IGonzalezSosa + anag+factory
- Version 10

- Change the license to GPL-2.0-or-later (gh#agama-project/agama#1621).

- Expose the zFCP D-Bus API through HTTP (gh#agama-project/agama#1570).

- For CLI, use HTTP clients instead of D-Bus clients,
  final piece: Storage (gh#agama-project/agama#1600)
  - added StorageHTTPClient

- Add additional wireless settings (gh#agama-project/agama#1602).
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