Sync from SUSE:SLFO:Main python-rtslib-fb revision e908b467e38bf65d35f8eadb84fbb3a7
This commit is contained in:
85
Fix-issue-with-Path-open-needs-parenthesis.patch
Normal file
85
Fix-issue-with-Path-open-needs-parenthesis.patch
Normal file
@@ -0,0 +1,85 @@
|
||||
From e70542fec8f78d156cee101bc8680ddabbbbd7f6 Mon Sep 17 00:00:00 2001
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Mon, 24 Mar 2025 11:21:59 -0700
|
||||
Subject: [PATCH] Fix issue with Path(...).open: needs parenthesis
|
||||
|
||||
There are places where the code does this pattern:
|
||||
|
||||
with Path(some_path).open as f:
|
||||
... (do stuff)
|
||||
|
||||
But that generates an error message like:
|
||||
|
||||
/> restoreconfig temp.json
|
||||
Traceback (most recent call last):
|
||||
File "/usr/bin/targetcli", line 8, in <module>
|
||||
sys.exit(main())
|
||||
~~~~^^
|
||||
File "/usr/lib/python3.13/site-packages/targetcli/targetcli_shell.py", line 313, in main
|
||||
shell.run_interactive()
|
||||
~~~~~~~~~~~~~~~~~~~~~^^
|
||||
File "/usr/lib/python3.13/site-packages/configshell/shell.py", line 899, in run_interactive
|
||||
self._cli_loop()
|
||||
~~~~~~~~~~~~~~^^
|
||||
File "/usr/lib/python3.13/site-packages/configshell/shell.py", line 728, in _cli_loop
|
||||
self.run_cmdline(cmdline)
|
||||
~~~~~~~~~~~~~~~~^^^^^^^^^
|
||||
File "/usr/lib/python3.13/site-packages/configshell/shell.py", line 842, in run_cmdline
|
||||
self._execute_command(path, command, pparams, kparams)
|
||||
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
File "/usr/lib/python3.13/site-packages/configshell/shell.py", line 817, in _execute_command
|
||||
result = target.execute_command(command, pparams, kparams)
|
||||
File "/usr/lib/python3.13/site-packages/configshell/node.py", line 1405, in execute_command
|
||||
return method(*pparams, **kparams)
|
||||
File "/usr/lib/python3.13/site-packages/targetcli/ui_root.py", line 207, in ui_command_restoreconfig
|
||||
errors = self.rtsroot.restore_from_file(savefile, clear_existing,
|
||||
target, storage_object)
|
||||
File "/usr/lib/python3.13/site-packages/rtslib/root.py", line 490, in restore_from_file
|
||||
with Path(restore_file).open as f:
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
TypeError: 'method' object does not support the context manager protocol
|
||||
|
||||
Adding empty parenthesis after the "open" fixes the issue.
|
||||
---
|
||||
rtslib/root.py | 4 ++--
|
||||
scripts/convert-to-json | 2 +-
|
||||
2 files changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/rtslib/root.py b/rtslib/root.py
|
||||
index 749a80620e65..b05d380a6c50 100644
|
||||
--- a/rtslib/root.py
|
||||
+++ b/rtslib/root.py
|
||||
@@ -190,7 +190,7 @@ class RTSRoot(CFSNode):
|
||||
current = self.dump()
|
||||
|
||||
try:
|
||||
- with Path(save_file).open as f:
|
||||
+ with Path(save_file).open() as f:
|
||||
saveconf = json.loads(f.read())
|
||||
except OSError as e:
|
||||
if e.errno == errno.ENOENT:
|
||||
@@ -487,7 +487,7 @@ class RTSRoot(CFSNode):
|
||||
if not restore_file:
|
||||
restore_file = default_save_file
|
||||
|
||||
- with Path(restore_file).open as f:
|
||||
+ with Path(restore_file).open() as f:
|
||||
config = json.loads(f.read())
|
||||
return self.restore(config, target, storage_object,
|
||||
clear_existing=clear_existing,
|
||||
diff --git a/scripts/convert-to-json b/scripts/convert-to-json
|
||||
index daa82daf705b..7677350f3040 100755
|
||||
--- a/scripts/convert-to-json
|
||||
+++ b/scripts/convert-to-json
|
||||
@@ -318,7 +318,7 @@ def parse(txt, cur):
|
||||
elif txt[cur] == "fabric":
|
||||
cur = parse_fabric(txt, cur)
|
||||
|
||||
-with Path("/etc/target/scsi_target.lio").open as f:
|
||||
+with Path("/etc/target/scsi_target.lio").open() as f:
|
||||
txt = f.read()
|
||||
txt = split(txt)
|
||||
cur = parse(txt, 0)
|
||||
--
|
||||
2.43.0
|
||||
|
44
Install-targetctl-as-an-entrypoint.patch
Normal file
44
Install-targetctl-as-an-entrypoint.patch
Normal file
@@ -0,0 +1,44 @@
|
||||
From 4677e05cf54eab01bde48dcf3ae1488b6a8241b4 Mon Sep 17 00:00:00 2001
|
||||
From: Alfred Wingate <parona@protonmail.com>
|
||||
Date: Mon, 10 Mar 2025 09:50:53 +0200
|
||||
Subject: [PATCH] Install targetctl as an entrypoint
|
||||
|
||||
scripts = ['scripts/targetctl'] didn't survive the transition to hatch,
|
||||
readd it with required modifications.
|
||||
|
||||
Bug: https://bugs.gentoo.org/950964
|
||||
Fixes: 9eea9a306f83b039629350dace0983f65fa9c64f
|
||||
Signed-off-by: Alfred Wingate <parona@protonmail.com>
|
||||
---
|
||||
pyproject.toml | 5 ++++-
|
||||
scripts/targetctl => rtslib/targetctl.py | 0
|
||||
2 files changed, 4 insertions(+), 1 deletion(-)
|
||||
rename scripts/targetctl => rtslib/targetctl.py (100%)
|
||||
|
||||
diff --git a/pyproject.toml b/pyproject.toml
|
||||
index c07186aa007c..adebb9f104ea 100644
|
||||
--- a/pyproject.toml
|
||||
+++ b/pyproject.toml
|
||||
@@ -31,6 +31,9 @@ paths = ["COPYING"]
|
||||
[project.urls]
|
||||
Homepage = "http://github.com/open-iscsi/rtslib-fb"
|
||||
|
||||
+[project.scripts]
|
||||
+targetctl = "rtslib.targetctl:main"
|
||||
+
|
||||
[tool.hatch.version]
|
||||
source = "vcs"
|
||||
|
||||
@@ -90,4 +93,4 @@ ignore = [
|
||||
]
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
# Magic value used in comparison
|
||||
-"scripts/targetctl" = ["PLR2004"]
|
||||
+"rtslib/targetctl.py" = ["PLR2004"]
|
||||
diff --git a/scripts/targetctl b/rtslib/targetctl.py
|
||||
similarity index 100%
|
||||
rename from scripts/targetctl
|
||||
rename to rtslib/targetctl.py
|
||||
--
|
||||
2.43.0
|
||||
|
26
Remove-use-of-usr-bin-python.patch
Normal file
26
Remove-use-of-usr-bin-python.patch
Normal file
@@ -0,0 +1,26 @@
|
||||
From 631685f400d3bd170a449503ce062a82c58d823a Mon Sep 17 00:00:00 2001
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Mon, 24 Mar 2025 10:00:21 -0700
|
||||
Subject: [PATCH] Remove use of /usr/bin/python
|
||||
|
||||
The targetctl.py script was using /usr/bin/python, even
|
||||
though this package has been ported to python3.
|
||||
|
||||
This makes installing it on modern systems fail.
|
||||
---
|
||||
rtslib/targetctl.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/rtslib/targetctl.py b/rtslib/targetctl.py
|
||||
index e304be0d2f38..124d03f3c1fb 100755
|
||||
--- a/rtslib/targetctl.py
|
||||
+++ b/rtslib/targetctl.py
|
||||
@@ -1,4 +1,4 @@
|
||||
-#!/usr/bin/python
|
||||
+#!/usr/bin/python3
|
||||
'''
|
||||
targetctl
|
||||
|
||||
--
|
||||
2.43.0
|
||||
|
3
_service
3
_service
@@ -3,11 +3,12 @@
|
||||
<param name="scm">git</param>
|
||||
<param name="url">https://github.com/open-iscsi/rtslib-fb.git</param>
|
||||
<param name="subdir"></param>
|
||||
<param name="package-meta">yes</param>
|
||||
<param name="filename">python-rtslib-fb</param>
|
||||
<param name="versionformat">@PARENT_TAG@</param>
|
||||
<param name="versionrewrite-pattern">v(\d*\.\d*\.)fb(\d*)</param>
|
||||
<param name="versionrewrite-replacement">\1\2</param>
|
||||
<param name="revision">v2.1.76</param>
|
||||
<param name="revision">v2.2.2</param>
|
||||
<param name="changesgenerate">enable</param>
|
||||
</service>
|
||||
<service name="recompress" mode="disabled">
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<servicedata>
|
||||
<service name="tar_scm">
|
||||
<param name="url">https://github.com/open-iscsi/rtslib-fb.git</param>
|
||||
<param name="changesrevision">745d51a46e6718e34c59b728fd96ec08bbf906dc</param></service></servicedata>
|
||||
<param name="changesrevision">139c7770600cd7e367ebc7504b991551c7e67bc4</param></service></servicedata>
|
BIN
python-rtslib-fb-v2.1.76.tar.xz
(Stored with Git LFS)
BIN
python-rtslib-fb-v2.1.76.tar.xz
(Stored with Git LFS)
Binary file not shown.
BIN
python-rtslib-fb-v2.2.2.tar.xz
(Stored with Git LFS)
Normal file
BIN
python-rtslib-fb-v2.2.2.tar.xz
(Stored with Git LFS)
Normal file
Binary file not shown.
@@ -1,3 +1,35 @@
|
||||
-------------------------------------------------------------------
|
||||
Sat Mar 22 15:35:05 UTC 2025 - lduncan@suse.com
|
||||
|
||||
- Update to version v2.2.2:
|
||||
* Explicitly set build target wheel packages
|
||||
* Fix the program name in pyproject.toml
|
||||
* Fix and update pre-commit ruf check
|
||||
* Add PyPA publish and pre-commit check workflows
|
||||
* Add rtslib_fb import compability
|
||||
* Silently ignore OSError on close
|
||||
* fixup! Fix various issues found by ruff linter rules
|
||||
* Add ruff rules, pre-commit config
|
||||
* Convert codebase to pathlib
|
||||
* Fix various issues found by ruff linter rules
|
||||
* Refactor code to Python>=3.9 to pass pyupgrade
|
||||
* Fix issues found by ruff pep8-naming rules
|
||||
* Fix issues found by ruff pycodestyle rules
|
||||
* Use f-strings
|
||||
* Fixing issues found by ruff Pyflakes rules
|
||||
* Move to PEP-621; Drop -fb from module name
|
||||
* rtslib: explicitely import "kmod.error" and "kmod.Kmod"
|
||||
* rtslib/LUN: add some ALUA property
|
||||
|
||||
Also, updated the SPEC file, and removed patch no longer needed,
|
||||
since the problem is no longer present:
|
||||
* rtslib-Fix-handling-of-sysfs-RW-attrs-that-are-actually-RO.patch
|
||||
|
||||
Added three commits, one from upstream, the others submitted there:
|
||||
* Install-targetctl-as-an-entrypoint.patch (added from upstream)
|
||||
* Remove-use-of-usr-bin-python.patch (submitted upstream)
|
||||
* Fix-issue-with-Path-open-needs-parenthesis.patch (submitted upstream)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Jun 17 16:09:09 UTC 2024 - Lee Duncan <lduncan@suse.com>
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-rtslib-fb
|
||||
#
|
||||
# Copyright (c) 2024 SUSE LLC
|
||||
# Copyright (c) 2025 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@@ -19,40 +19,40 @@
|
||||
%define dbdir %{_sysconfdir}/target
|
||||
%define oldpython python
|
||||
%define cpkg %{oldpython}-rtslib-fb-common
|
||||
%if 0%{?suse_version} > 1500
|
||||
%bcond_without libalternatives
|
||||
%else
|
||||
%bcond_with libalternatives
|
||||
%endif
|
||||
|
||||
%{?sle15_python_module_pythons}
|
||||
|
||||
Name: python-rtslib-fb
|
||||
Version: 2.1.76
|
||||
Version: 2.2.2
|
||||
Release: 0%{?dist}
|
||||
Summary: API for Linux kernel SCSI target (aka LIO)
|
||||
License: Apache-2.0
|
||||
Group: Development/Languages/Python
|
||||
URL: https://github.com/open-iscsi/rtslib-fb.git
|
||||
Source: python-rtslib-fb-v%{version}.tar.xz
|
||||
Patch2: rtslib-Fix-handling-of-sysfs-RW-attrs-that-are-actually-RO.patch
|
||||
Patch3: rtslib-target-service-for-suse.patch
|
||||
Patch1: rtslib-target-service-for-suse.patch
|
||||
Patch2: Install-targetctl-as-an-entrypoint.patch
|
||||
Patch3: Remove-use-of-usr-bin-python.patch
|
||||
Patch4: Fix-issue-with-Path-open-needs-parenthesis.patch
|
||||
BuildRequires: %{python_module devel}
|
||||
BuildRequires: %{python_module hatch_vcs}
|
||||
BuildRequires: %{python_module hatchling}
|
||||
BuildRequires: %{python_module pip}
|
||||
BuildRequires: %{python_module pyudev}
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: %{python_module wheel}
|
||||
BuildRequires: fdupes
|
||||
BuildRequires: git
|
||||
BuildRequires: python-rpm-macros >= 20210929
|
||||
BuildRequires: pkgconfig(systemd)
|
||||
Requires: %{cpkg}
|
||||
Requires: python-pyudev
|
||||
Provides: python-rtslib = %{version}-%{release}
|
||||
Obsoletes: python-rtslib < %{version}
|
||||
BuildArch: noarch
|
||||
%if %{with libalternatives}
|
||||
BuildRequires: alts
|
||||
Requires: alts
|
||||
%else
|
||||
Requires(post): update-alternatives
|
||||
Requires(postun):update-alternatives
|
||||
%endif
|
||||
Requires(postun): update-alternatives
|
||||
|
||||
%python_subpackages
|
||||
|
||||
%description
|
||||
@@ -61,13 +61,13 @@ SCSI target, present in 3.x Linux kernel versions. rtslib-fb is licensed under
|
||||
the Apache 2.0 license. Contributions are welcome
|
||||
|
||||
%package -n %{cpkg}
|
||||
Summary: Common python-rtslib-fb subpackage for Python 2 or 3
|
||||
Summary: Common python-rtslib-fb subpackage for all Python 3 versions
|
||||
Group: Development/Languages/Python
|
||||
Obsoletes: %{name} < %{version}-%{release}
|
||||
|
||||
%description -n %{cpkg}
|
||||
python-rtslib-fb-common is the invariant base package needed by both
|
||||
python2-rtslib-fb and python3-rtslib-fb.
|
||||
python-rtslib-fb-common is the invariant base package needed by all
|
||||
version of python3*-rtslib-fb.
|
||||
|
||||
%prep
|
||||
%autosetup -p1 -n python-rtslib-fb-v%{version}
|
||||
@@ -78,7 +78,6 @@ python2-rtslib-fb and python3-rtslib-fb.
|
||||
%install
|
||||
%pyproject_install
|
||||
%python_clone -a %{buildroot}/%{_bindir}/targetctl
|
||||
%fdupes %{buildroot}
|
||||
install -d -m755 %{buildroot}%{_mandir}/man5
|
||||
install -m644 doc/saveconfig.json.5 %{buildroot}%{_mandir}/man5
|
||||
install -d -m755 %{buildroot}%{_mandir}/man8
|
||||
@@ -89,6 +88,7 @@ install -d -m755 %{buildroot}/%{dbdir}/alua
|
||||
mkdir -p %{buildroot}/%{_unitdir}/
|
||||
install -m644 systemd/target.service %{buildroot}/%{_unitdir}
|
||||
install -d -m755 %{buildroot}%{_sbindir}
|
||||
%fdupes %{buildroot}
|
||||
ln -s %{_sbindir}/service %{buildroot}/%{_sbindir}/rctarget
|
||||
|
||||
%post
|
||||
@@ -101,8 +101,6 @@ ln -s %{_sbindir}/service %{buildroot}/%{_sbindir}/rctarget
|
||||
|
||||
%pre
|
||||
%{service_add_pre target.service}
|
||||
# If libalternatives is used: Removing old update-alternatives entries.
|
||||
%python_libalternatives_reset_alternative targetctl
|
||||
|
||||
%preun
|
||||
%{stop_on_removal target}
|
||||
@@ -122,9 +120,8 @@ ln -s %{_sbindir}/service %{buildroot}/%{_sbindir}/rctarget
|
||||
|
||||
%files %{python_files}
|
||||
%python_alternative %{_bindir}/targetctl
|
||||
%{python_sitelib}/rtslib
|
||||
%{python_sitelib}/rtslib_fb
|
||||
%{python_sitelib}/rtslib_fb-%{version}*-info
|
||||
%{python_sitelib}/rtslib*
|
||||
%pycache_only %{python_sitelib}/__pycache__
|
||||
|
||||
%files -n %{cpkg}
|
||||
%license COPYING
|
||||
|
@@ -1,65 +0,0 @@
|
||||
From 10f23379b2d3e2226782e2d6185bee22cc586170 Mon Sep 17 00:00:00 2001
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Thu, 15 Oct 2020 14:21:20 -0700
|
||||
Subject: [PATCH] Fix handling of sysfs RW attrs that are actually RO
|
||||
|
||||
Kernel commit 356ba2a8bc8d ("scsi: target: tcmu: Make
|
||||
gr_support and alua_support attributes writable"), made the
|
||||
alua_support and pgr_support sysfs attributes writable
|
||||
so that individual target drivers could change them.
|
||||
This means that the filesystem attributes might saw
|
||||
read-write, but the attributes can in fact be read-only.
|
||||
When a user tries to write to them, in this case,
|
||||
they EINVAL.
|
||||
|
||||
This causes rtslib to throw error messages when one does
|
||||
a "targetctl restore" like these:
|
||||
|
||||
> Storage Object fileio/file01: Cannot set attribute alua_support: [Errno 22] Invalid argument, skipped
|
||||
> Storage Object fileio/file01: Cannot set attribute pgr_support: [Errno 22] Invalid argument, skipped
|
||||
|
||||
While these messages are benign, they will cause confusion, since
|
||||
(1) there's nothing wrong, and (2) they didn't occur before above-
|
||||
mentioned kernel commit.
|
||||
|
||||
This fix tells rtslib to ignore errno 22 for these two attributes.
|
||||
---
|
||||
rtslib/node.py | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/rtslib/node.py b/rtslib/node.py
|
||||
index 415f45d675f9..ed08030002bb 100644
|
||||
--- a/rtslib/node.py
|
||||
+++ b/rtslib/node.py
|
||||
@@ -20,6 +20,7 @@ under the License.
|
||||
|
||||
import os
|
||||
import stat
|
||||
+import errno
|
||||
from .utils import fread, fwrite, RTSLibError, RTSLibNotInCFS
|
||||
|
||||
|
||||
@@ -28,6 +29,10 @@ class CFSNode(object):
|
||||
# Where is the configfs base LIO directory ?
|
||||
configfs_dir = '/sys/kernel/config/target'
|
||||
|
||||
+ # these two attributes can have file permissions of
|
||||
+ # read-write but be read-only
|
||||
+ may_be_ro_attrs = ['alua_support', 'pgr_support']
|
||||
+
|
||||
# CFSNode private stuff
|
||||
|
||||
def __init__(self):
|
||||
@@ -172,7 +177,8 @@ class CFSNode(object):
|
||||
try:
|
||||
fwrite(path, "%s" % str(value))
|
||||
except Exception as e:
|
||||
- raise RTSLibError("Cannot set attribute %s: %s" % (attribute, e))
|
||||
+ if attribute not in self.may_be_ro_attrs or e.errno != errno.EINVAL:
|
||||
+ raise RTSLibError("Cannot set attribute %s: %s" % (attribute, e))
|
||||
|
||||
def get_attribute(self, attribute):
|
||||
'''
|
||||
--
|
||||
2.26.2
|
||||
|
@@ -1,18 +1,24 @@
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Sat Mar 22 10:52:22 AM PDT 2025
|
||||
Subject: [PATCH] blah
|
||||
|
||||
Blah
|
||||
---
|
||||
--- a/systemd/target.service 2019-01-31 11:11:28.517558290 -0800
|
||||
+++ b/systemd/target.service 2020-10-16 09:34:28.888091013 -0700
|
||||
@@ -6,10 +6,13 @@ After=sys-kernel-config.mount network.ta
|
||||
@@ -6,9 +6,12 @@ After=sys-kernel-config.mount network.ta
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
-ExecStart=/usr/bin/targetctl restore
|
||||
-ExecStop=/usr/bin/targetctl clear
|
||||
+Environment=CONFIG_FILE=/etc/target/saveconfig.json
|
||||
+EnvironmentFile=-/etc/sysconfig/target
|
||||
+ExecStart=/usr/bin/targetctl restore $CONFIG_FILE
|
||||
+ExecStop=/usr/bin/targetctl save $CONFIG_FILE
|
||||
ExecStop=/usr/bin/targetctl clear
|
||||
SyslogIdentifier=target
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
-
|
||||
+Alias=targetcli.service
|
||||
|
||||
|
Reference in New Issue
Block a user