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

nmcli: two fixes needed to make wifi.wake-on-wlan settings work properly #5431

Merged
merged 4 commits into from
Feb 24, 2023

Conversation

jikamens
Copy link
Contributor

SUMMARY
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

nmcli

ADDITIONAL INFORMATION

There are two commits in this PR, both of which are necessary to make wifi.wake-on-wlan settings work properly with this module, and one of which is necessary to make any wifi.* setting work properly. See the descriptions of the fixes in the individual commits.

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module net_tools new_contributor Help guide this first time contributor plugins plugin (any type) small_patch Hopefully easy to review labels Oct 28, 2022
@felixfontein felixfontein added check-before-release PR will be looked at again shortly before release and merged if possible. backport-4 labels Oct 28, 2022
@felixfontein
Copy link
Collaborator

Thanks for your contribution! Can you please add a changelog fragment and potentially also add tests for this (to avoid regressions)? The tests can be found in tests/unit/plugins/modules/net_tools/test_nmcli.py. Thanks!

@jikamens
Copy link
Contributor Author

I added ChangeLog fragments. I unfortunately don't have time to deal with tests.

@ansibullbot ansibullbot added needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Oct 28, 2022
@felixfontein felixfontein changed the title Two fixes needed to make wifi.wake-on-wlan settings work properly nmcli: two fixes needed to make wifi.wake-on-wlan settings work properly Oct 29, 2022
@felixfontein
Copy link
Collaborator

I've changed the fragments to conform to our standard. I don't use or know nmcli so I hope someone with more knowledge will review the code changes.

@felixfontein
Copy link
Collaborator

Please note that in #5461 the collection repository was restructured to remove the directory tree in plugins/modules/, and the corresponding tree in tests/unit/plugins/modules/. Your PR modifies files in this directory structure, and unfortunately now has some conflicts, potentially because of this. Please rebase with the current main branch to remove the conflicts.

@ansibullbot ansibullbot added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Nov 3, 2022
@numeratorjik
Copy link

Rebased.

@ansibullbot ansibullbot removed needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Nov 3, 2022
@ansibullbot ansibullbot added the stale_ci CI is older than 7 days, rerun before merging label Nov 16, 2022
@jikamens
Copy link
Contributor Author

@ThomasGebert I cleaned up the earlier code and added two more commits because I found two more bugs while doing final testing on this. :-/ Can you take another look?

jikamens added a commit to jikamens/community.general that referenced this pull request Feb 22, 2023
@ansibullbot ansibullbot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Feb 22, 2023
ThomasGebert

This comment was marked as duplicate.

ThomasGebert

This comment was marked as outdated.

plugins/modules/nmcli.py Outdated Show resolved Hide resolved
@jikamens
Copy link
Contributor Author

I think with the addresses change pulled onto a different branch this PR is now ready to merge.

@ansibullbot ansibullbot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels Feb 23, 2023
@felixfontein
Copy link
Collaborator

@ThomasGebert if you're happy I'll merge.

Copy link
Contributor

@ThomasGebert ThomasGebert left a comment

Choose a reason for hiding this comment

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

lgtm

@ansibullbot ansibullbot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR label Feb 24, 2023
@felixfontein felixfontein removed the check-before-release PR will be looked at again shortly before release and merged if possible. label Feb 24, 2023
@felixfontein felixfontein merged commit 490899f into ansible-collections:main Feb 24, 2023
@patchback
Copy link

patchback bot commented Feb 24, 2023

Backport to stable-5: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-5/490899f87faee52e3f300533f6ae9a2c150103e6/pr-5431

Backported as #6050

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Feb 24, 2023
…rly (#5431)

* nmcli: Convert current value of wifi.wake-on-wlan before comparing

The new value of wifi.wake-on-wlan is specified as an integer, but in
the nmcli output it's specified as a hex string followed by a textual
description of it. Therefore, to determine properly whether it's being
changed we need to pull the hex string out of the current value,
convert it into an integer, and finally convert the integer back to a
string so that we can compare it to the new specified value. Without
this change, whenever wifi.wake-on-wlan is specified in the module
arguments the module will think the value is being changed even when
it isn't.

* nmcli: Handle wifi options correctly when connection type not specified

When an nmcli task does not specify the connection type and the module
ask nmcli for it, the module needs to convert nmcli's
`802-11-wireless` to `wifi`, the term for this connection type used by
the module.

* nmcli: Correctly detect values changed to the integer 0

If the user specifies a value of 0 (without quotes) in a task, we
should interpret that as an actual value, not empty, when comparing
the new value to the old one. Otherwise we incorrectly conclude that
there was no change.

* Changelog fragment for #5431

(cherry picked from commit 490899f)
@patchback
Copy link

patchback bot commented Feb 24, 2023

Backport to stable-6: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-6/490899f87faee52e3f300533f6ae9a2c150103e6/pr-5431

Backported as #6051

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@felixfontein
Copy link
Collaborator

@jikamens thanks a lot for fixing this!
@ThomasGebert thanks a lot for reviewing this!

patchback bot pushed a commit that referenced this pull request Feb 24, 2023
…rly (#5431)

* nmcli: Convert current value of wifi.wake-on-wlan before comparing

The new value of wifi.wake-on-wlan is specified as an integer, but in
the nmcli output it's specified as a hex string followed by a textual
description of it. Therefore, to determine properly whether it's being
changed we need to pull the hex string out of the current value,
convert it into an integer, and finally convert the integer back to a
string so that we can compare it to the new specified value. Without
this change, whenever wifi.wake-on-wlan is specified in the module
arguments the module will think the value is being changed even when
it isn't.

* nmcli: Handle wifi options correctly when connection type not specified

When an nmcli task does not specify the connection type and the module
ask nmcli for it, the module needs to convert nmcli's
`802-11-wireless` to `wifi`, the term for this connection type used by
the module.

* nmcli: Correctly detect values changed to the integer 0

If the user specifies a value of 0 (without quotes) in a task, we
should interpret that as an actual value, not empty, when comparing
the new value to the old one. Otherwise we incorrectly conclude that
there was no change.

* Changelog fragment for #5431

(cherry picked from commit 490899f)
felixfontein pushed a commit that referenced this pull request Feb 24, 2023
…e wifi.wake-on-wlan settings work properly (#6050)

nmcli: two fixes needed to make wifi.wake-on-wlan settings work properly (#5431)

* nmcli: Convert current value of wifi.wake-on-wlan before comparing

The new value of wifi.wake-on-wlan is specified as an integer, but in
the nmcli output it's specified as a hex string followed by a textual
description of it. Therefore, to determine properly whether it's being
changed we need to pull the hex string out of the current value,
convert it into an integer, and finally convert the integer back to a
string so that we can compare it to the new specified value. Without
this change, whenever wifi.wake-on-wlan is specified in the module
arguments the module will think the value is being changed even when
it isn't.

* nmcli: Handle wifi options correctly when connection type not specified

When an nmcli task does not specify the connection type and the module
ask nmcli for it, the module needs to convert nmcli's
`802-11-wireless` to `wifi`, the term for this connection type used by
the module.

* nmcli: Correctly detect values changed to the integer 0

If the user specifies a value of 0 (without quotes) in a task, we
should interpret that as an actual value, not empty, when comparing
the new value to the old one. Otherwise we incorrectly conclude that
there was no change.

* Changelog fragment for #5431

(cherry picked from commit 490899f)

Co-authored-by: Jonathan Kamens <[email protected]>
felixfontein pushed a commit that referenced this pull request Feb 24, 2023
…e wifi.wake-on-wlan settings work properly (#6051)

nmcli: two fixes needed to make wifi.wake-on-wlan settings work properly (#5431)

* nmcli: Convert current value of wifi.wake-on-wlan before comparing

The new value of wifi.wake-on-wlan is specified as an integer, but in
the nmcli output it's specified as a hex string followed by a textual
description of it. Therefore, to determine properly whether it's being
changed we need to pull the hex string out of the current value,
convert it into an integer, and finally convert the integer back to a
string so that we can compare it to the new specified value. Without
this change, whenever wifi.wake-on-wlan is specified in the module
arguments the module will think the value is being changed even when
it isn't.

* nmcli: Handle wifi options correctly when connection type not specified

When an nmcli task does not specify the connection type and the module
ask nmcli for it, the module needs to convert nmcli's
`802-11-wireless` to `wifi`, the term for this connection type used by
the module.

* nmcli: Correctly detect values changed to the integer 0

If the user specifies a value of 0 (without quotes) in a task, we
should interpret that as an actual value, not empty, when comparing
the new value to the old one. Otherwise we incorrectly conclude that
there was no change.

* Changelog fragment for #5431

(cherry picked from commit 490899f)

Co-authored-by: Jonathan Kamens <[email protected]>
@jikamens
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module net_tools new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants