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

Add additional wireless settings #1602

Merged

Conversation

jcronenberg
Copy link
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
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!

@@ -164,6 +164,66 @@
"mesh",
"ap"
]
},
"hidden": {
"title": "Indicates that the wifi network is not broadcasting it's SSID",
Copy link
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
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
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.

rust/agama-lib/share/profile.schema.json Outdated Show resolved Hide resolved
#[error("Invalid group algorithm: {0}")]
pub struct InvalidGroupAlgorithm(String);

impl FromStr for GroupAlgorithm {
Copy link
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
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
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
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
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
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
1 check passed
@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