ceph / ceph-iscsi

Ceph iSCSI tools
GNU General Public License v3.0
63 stars 59 forks source link

rbd-target-api: switch to use distro to get the release version #276

Closed lxbsz closed 7 months ago

lxbsz commented 7 months ago

The 'platform.linux_distribution()' has been deprecated since python 3.7. And we should switch to use the distro.version(), distro.id() and distro.name() instead.

lxbsz commented 7 months ago

You'll also need to add python3-distro to the spec "Requires:" section (it's not a builtin library, but it is distro-packaged).

Okay, just missed the spec. Fixed it.

dmick commented 7 months ago

The package is called "python3-distro"

lxbsz commented 7 months ago

The package is called "python3-distro"

Please see https://packages.fedoraproject.org/pkgs/python-distro/.

Both the python3-distro and python2-distro are subpackages of the python-distro. I have tested it on both centos and fedora and it worked:

[xiubli@localhost src]$ sudo dnf reinstall python-distro
Last metadata expiration check: 3:52:47 ago on Thu 18 Apr 2024 05:50:21 AM CST.
Dependencies resolved.
==============================================================================================================================================================================================================================================================
 Package                                                          Architecture                                             Version                                                          Repository                                                   Size
==============================================================================================================================================================================================================================================================
Reinstalling:
 python3-distro                                                   noarch                                                   1.5.0-7.el9                                                      appstream                                                    37 k

Transaction Summary
==============================================================================================================================================================================================================================================================

Total download size: 37 k
Installed size: 153 k
Is this ok [y/N]: 

Could you forseee any other issue with this @dmick ?

dmick commented 7 months ago

I don't understand why this centos 8.stream host is different:

[dmick@vossi03 tmp]$ dnf provides python-distro Last metadata expiration check: 1:11:40 ago on Wed 17 Apr 2024 06:15:46 PM PDT. Error: No Matches found [dmick@vossi03 tmp]$ dnf search python2-distro Last metadata expiration check: 1:11:57 ago on Wed 17 Apr 2024 06:15:46 PM PDT. No matches found. [dmick@vossi03 tmp]$ dnf search python3-distro Last metadata expiration check: 1:12:05 ago on Wed 17 Apr 2024 06:15:46 PM PDT. ===================== Name Exactly Matched: python3-distro ===================== python3-distro.noarch : Linux Distribution - a Linux OS platform information API ========================= Name Matched: python3-distro ========================= python3-distroinfo.noarch : Parsing and querying distribution metadata stored in : text/YAML files

lxbsz commented 7 months ago

I don't understand why this centos 8.stream host is different:

[dmick@vossi03 tmp]$ dnf provides python-distro Last metadata expiration check: 1:11:40 ago on Wed 17 Apr 2024 06:15:46 PM PDT. Error: No Matches found [dmick@vossi03 tmp]$ dnf search python2-distro Last metadata expiration check: 1:11:57 ago on Wed 17 Apr 2024 06:15:46 PM PDT. No matches found. [dmick@vossi03 tmp]$ dnf search python3-distro Last metadata expiration check: 1:12:05 ago on Wed 17 Apr 2024 06:15:46 PM PDT. ===================== Name Exactly Matched: python3-distro ===================== python3-distro.noarch : Linux Distribution - a Linux OS platform information API ========================= Name Matched: python3-distro ========================= python3-distroinfo.noarch : Parsing and querying distribution metadata stored in : text/YAML files

Okay, so my way won't work for all the cases. I will update it. Thanks for your feedback.