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

nut-scanner: fix device-name collisions in generated conf #2247

Conversation

aquette
Copy link
Member

@aquette aquette commented Dec 23, 2023

When nut-scanner is called separately, to scan different buses, it will generate similar names for each of these:

  • USB scan

[nutdev1]
...

  • NUT scan

[nutdev1]
...

  • ... As a result, one can't just redirect nut-scanner outputs directly to ups.conf, without a 'sed' hack workaround.

Solution: simply refine the device names, like "nutdev-".
Ex: nutdev-usb1, nutdev-usb2, nutdev-nut1, nutdev-snmp1, nutdev-simulation1, ...

Closes: #2243

UPDATE/FYI: As recognized during investigation for #2317 the actual device numbering (in case of multi-bus scanning) is still monotonous, assigned during ups.conf style rendition of discovered configuration (actually not defined outside a renderer). So a single run with many media types enabled would yield e.g. "nutdev-usb1, nutdev-usb2, nutdev-nut3, nutdev-snmp4, nutdev-simulation5, ..."

When nut-scanner is called separately, to scan different buses, it will
generate similar names for each of these:
* USB scan
> [nutdev1]
> ...
* NUT scan
> [nutdev1]
> ...
* ...
As a result, one can't just redirect nut-scanner outputs directly to ups.conf,
without a 'sed' hack workaround.

Solution: simply refine the device names, like "nutdev-<method><id>".
Ex: nutdev-usb1, nutdev-usb2, nutdev-nut1, nutdev-snmp1, nutdev-simulation1, ...

Signed-off-by: Arnaud Quette <[email protected]>
Signed-off-by: Arnaud Quette <[email protected]>
@aquette
Copy link
Member Author

aquette commented Dec 24, 2023

@jimklimov CI issues, unrelated to the PR (trivial) changes
cc @desertwitch for review (interested in an onboarding?)

@desertwitch
Copy link
Contributor

desertwitch commented Dec 24, 2023

Currently have no means to test (stuck on a train) but the principal idea is great and should make chaining different nut-scanner commands, while outputting into one configuration file, much easier and reduce the need to hack around the generated UPS names. This'd also be useful for my use cases.

@aquette
Copy link
Member Author

aquette commented Dec 25, 2023

Note that #2246, as for all my dummy-ups work, is there for when you don't have access to real devices (or for CI). I coded that when on a plane ...
Just touch some .dev files in /etc/nut and try nut-scanner -n

@jimklimov
Copy link
Member

For coding on a plane or a boat, did I already suggest Termux? An Android app that is a debian-ish Linux VM, can build NUT for native ARM for example :)

@aquette
Copy link
Member Author

aquette commented Dec 25, 2023

Got it on all phones and tabs 😉
But home assistant on my rpi gives me remotes access to my editable containers and has a term and file edit through web UI too, quite nice. Give it a try ...

@jimklimov
Copy link
Member

Finally back to the online world, re-read this PR and was like "how did I never hit this, aren't numbers sequential for all found devices on whatever bus?"... and then saw the part about "running separately for different buses". Makes sense and LGTM then :)

@AppVeyorBot
Copy link

@jimklimov
Copy link
Member

@aquette : changes seem to work, NIT complains about test result mismatch (will post a fix in a sec) ;)

Now that we have a ./ci_build.sh here, feel free to use it locally to weed out at least simple hiccups without incurring the wrath of the whole CI farm :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

nut-scanner generated conf can cause device-name collisions
4 participants