From b6e9cf5493e2411a19053dc7794daa376dbc0dd3 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Oct 31 2019 12:16:59 +0000 Subject: import python-rtslib-2.1.fb69-3.el7 --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c26a4c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/rtslib-fb-2.1.fb69.tar.gz diff --git a/.python-rtslib.metadata b/.python-rtslib.metadata new file mode 100644 index 0000000..f5dc9d2 --- /dev/null +++ b/.python-rtslib.metadata @@ -0,0 +1 @@ +4148d5c9083d72a952d431809db1adbea93668de SOURCES/rtslib-fb-2.1.fb69.tar.gz diff --git a/SOURCES/0001-Turn-off-unsupported-fabrics.patch b/SOURCES/0001-Turn-off-unsupported-fabrics.patch new file mode 100644 index 0000000..a1754da --- /dev/null +++ b/SOURCES/0001-Turn-off-unsupported-fabrics.patch @@ -0,0 +1,21 @@ +diff --git a/rtslib/fabric.py b/rtslib/fabric.py +index b529f14..8264c37 100644 +--- a/rtslib/fabric.py ++++ b/rtslib/fabric.py +@@ -465,12 +465,12 @@ fabric_modules = { + "iscsi": ISCSIFabricModule, + "loopback": LoopbackFabricModule, + "qla2xxx": Qla2xxxFabricModule, +- "sbp": SBPFabricModule, ++# "sbp": SBPFabricModule, + "tcm_fc": FCoEFabricModule, + # "usb_gadget": USBGadgetFabricModule, # very rare, don't show +- "vhost": VhostFabricModule, +- "xen-pvscsi": XenPvScsiFabricModule, +- "ibmvscsis": IbmvscsisFabricModule, ++# "vhost": VhostFabricModule, ++# "xen-pvscsi": XenPvScsiFabricModule, ++# "ibmvscsis": IbmvscsisFabricModule, + } + + # diff --git a/SOURCES/0002-Fix-comparisons-to-None.patch b/SOURCES/0002-Fix-comparisons-to-None.patch new file mode 100644 index 0000000..327a2e7 --- /dev/null +++ b/SOURCES/0002-Fix-comparisons-to-None.patch @@ -0,0 +1,29 @@ +From 32d8b8ef61a3786ff409bdba7f74ab53987f04c1 Mon Sep 17 00:00:00 2001 +From: Andy Grover +Date: Wed, 28 Oct 2015 09:28:29 -0700 +Subject: [PATCH] Fix comparisons to None + +see https://bugzilla.redhat.com/show_bug.cgi?id=1276044 + +Signed-off-by: Andy Grover +--- + rtslib/node.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/rtslib/node.py b/rtslib/node.py +index c319a5b..e61249d 100644 +--- a/rtslib/node.py ++++ b/rtslib/node.py +@@ -34,10 +34,10 @@ class CFSNode(object): + self._path = self.configfs_dir + + def __eq__(self, other): +- return self._path == other._path ++ return isinstance(other, self.__class__) and self._path == other._path + + def __ne__(self, other): +- return self._path != other._path ++ return not self.__eq__(other) + + def _get_path(self): + return self._path diff --git a/SOURCES/0003-report-the-correct-size-for-partitions.patch b/SOURCES/0003-report-the-correct-size-for-partitions.patch new file mode 100644 index 0000000..dd7b6b8 --- /dev/null +++ b/SOURCES/0003-report-the-correct-size-for-partitions.patch @@ -0,0 +1,35 @@ +From 560ee483a9ff0fbaa130e70573c7f27ba7a413ad Mon Sep 17 00:00:00 2001 +From: Maurizio Lombardi +Date: Fri, 19 Oct 2018 10:52:01 +0200 +Subject: [PATCH] report the correct size for partitions + +If you use a partition instead of the whole device as the backstore device, +rtslib will always report its size as 0 bytes. + +This happens because rtslib tries to read the "queue/logical_block_size" +attribute, which can only be found in the parent's node. +This patch fixes the bug by loading the parent node's attributes if +it detects that the device is a partition. + +Signed-off-by: Maurizio Lombardi +--- + rtslib/utils.py | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/rtslib/utils.py b/rtslib/utils.py +index b4e68fb..eff2205 100644 +--- a/rtslib/utils.py ++++ b/rtslib/utils.py +@@ -134,6 +134,9 @@ def _get_size_for_dev(device): + except (KeyError, UnicodeDecodeError, ValueError): + return 0 + ++ if device['DEVTYPE'] == 'partition': ++ attributes = device.parent.attributes ++ + try: + logical_block_size = attributes.asint('queue/logical_block_size') + except (KeyError, UnicodeDecodeError, ValueError): +-- +1.8.3.1 + diff --git a/SOURCES/0004-save_to_file-function-breaks-symbolic-link-when-savi.patch b/SOURCES/0004-save_to_file-function-breaks-symbolic-link-when-savi.patch new file mode 100644 index 0000000..8412e64 --- /dev/null +++ b/SOURCES/0004-save_to_file-function-breaks-symbolic-link-when-savi.patch @@ -0,0 +1,64 @@ +From 5626a4d593df9384fff5129e7bdb6c909f5f2b11 Mon Sep 17 00:00:00 2001 +From: Maurizio Lombardi +Date: Fri, 8 Feb 2019 14:36:34 +0100 +Subject: [PATCH] save_to_file() function breaks symbolic link when saving + configuration + +Currently the location of the targetcli configuration file is not +configurable (saveconfig.json). The location is : /etc/target +Some users use stateless VMs, with just a persistent device +mounted under /var/lib/diskless. + +In order to circumvent the non configurable location of +saveconfig.json, they create a symbolic link in /etc/target +pointing to /var/lib/diskless + +Unfortunately, the rtslib save_to_file() function breaks +this symbolic link and creates a new regular file in place of it, +due to the creation of a saveconfig.json.temp file which is +then renamed to saveconfig.json using the os.rename() function. + +This patch replace os.rename() with shutil.copyfile() + os.remove(), +using copyfile() instead of rename() will preserve the symbolic link + +Signed-off-by: Maurizio Lombardi +--- + rtslib/root.py | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/rtslib/root.py b/rtslib/root.py +index 5c0a98c..c93e65b 100644 +--- a/rtslib/root.py ++++ b/rtslib/root.py +@@ -23,6 +23,7 @@ import stat + import json + import glob + import errno ++import shutil + + from .node import CFSNode + from .target import Target +@@ -386,7 +387,9 @@ class RTSRoot(CFSNode): + else: + saveconf = self.dump() + +- with open(save_file+".temp", "w+") as f: ++ tmp_file = save_file + ".temp" ++ ++ with open(tmp_file, "w+") as f: + os.fchmod(f.fileno(), stat.S_IRUSR | stat.S_IWUSR) + f.write(json.dumps(saveconf, sort_keys=True, indent=2)) + f.write("\n") +@@ -394,7 +397,8 @@ class RTSRoot(CFSNode): + os.fsync(f.fileno()) + f.close() + +- os.rename(save_file+".temp", save_file) ++ shutil.copyfile(tmp_file, save_file) ++ os.remove(tmp_file) + + def restore_from_file(self, restore_file=None, clear_existing=True, abort_on_error=False): + ''' +-- +2.21.0 + diff --git a/SOURCES/target.service b/SOURCES/target.service new file mode 100644 index 0000000..aa0a51b --- /dev/null +++ b/SOURCES/target.service @@ -0,0 +1,15 @@ +[Unit] +Description=Restore LIO kernel target configuration +Requires=sys-kernel-config.mount +After=sys-kernel-config.mount network.target local-fs.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/targetctl restore +ExecStop=/usr/bin/targetctl clear +SyslogIdentifier=target + +[Install] +WantedBy=multi-user.target + diff --git a/SPECS/python-rtslib.spec b/SPECS/python-rtslib.spec new file mode 100644 index 0000000..8a581e4 --- /dev/null +++ b/SPECS/python-rtslib.spec @@ -0,0 +1,385 @@ +%if 0%{?fedora} +%global with_python3 1 +%endif + +%global oname rtslib-fb + +Name: python-rtslib +License: ASL 2.0 +Group: System Environment/Libraries +Summary: API for Linux kernel LIO SCSI target +Version: 2.1.fb69 +Release: 3%{?dist} +URL: https://fedorahosted.org/targetcli-fb/ +Source: https://fedorahosted.org/released/targetcli-fb/%{oname}-%{version}.tar.gz +Source1: target.service +Patch0: 0001-Turn-off-unsupported-fabrics.patch +Patch1: 0002-Fix-comparisons-to-None.patch +Patch2: 0003-report-the-correct-size-for-partitions.patch +Patch3: 0004-save_to_file-function-breaks-symbolic-link-when-savi.patch +BuildArch: noarch +BuildRequires: python-devel epydoc python-setuptools systemd-units python-six python-pyudev +Requires: python-kmod python-six python-pyudev +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd + +%if 0%{?with_python3} +BuildRequires: python3-devel python-tools python3-setuptools +%endif + +%package doc +Summary: Documentation for python-rtslib +Group: Documentation +Requires: %{name} = %{version}-%{release} + + +%description +API for generic Linux SCSI kernel target. Includes the 'target' +service and targetctl tool for restoring configuration. + +%description doc +API documentation for rtslib, to configure the generic Linux SCSI +multiprotocol kernel target. + +%if 0%{?with_python3} +%package -n python3-rtslib +Summary: API for Linux kernel LIO SCSI target +Group: System Environment/Libraries + +%description -n python3-rtslib +API for generic Linux SCSI kernel target. +%endif + +%prep +%setup -q -n %{oname}-%{version} +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 + +%if 0%{?with_python3} +rm -rf %{py3dir} +cp -a . %{py3dir} +%endif + +%build +%{__python} setup.py build +gzip --stdout doc/targetctl.8 > doc/targetctl.8.gz +gzip --stdout doc/saveconfig.json.5 > doc/saveconfig.json.5.gz +mkdir -p doc/html +epydoc --no-sourcecode --html -n rtslib -o doc/html rtslib/*.py + +%if 0%{?with_python3} +pushd %{py3dir} +2to3 --write --nobackups . +%{__python3} setup.py build +popd +%endif + +%install +%{__python} setup.py install --skip-build --root %{buildroot} +mkdir -p %{buildroot}%{_mandir}/man8/ +mkdir -p %{buildroot}%{_mandir}/man5/ +mkdir -p %{buildroot}%{_unitdir} +mkdir -p %{buildroot}%{_sysconfdir}/target/backup +mkdir -p %{buildroot}%{_localstatedir}/target/pr +mkdir -p %{buildroot}%{_localstatedir}/target/alua +install -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/target.service +install -m 644 doc/targetctl.8.gz %{buildroot}%{_mandir}/man8/ +install -m 644 doc/saveconfig.json.5.gz %{buildroot}%{_mandir}/man5/ + +%if 0%{?with_python3} +pushd %{py3dir} +# We don't want py3-converted scripts overwriting py2 scripts +# Shunt them elsewhere then delete +%{__python3} setup.py install --skip-build --root %{buildroot} --install-scripts py3scripts +rm -rf %{buildroot}/py3scripts +popd +%endif + +%post +%systemd_post target.service + +%preun +%systemd_preun target.service + +%postun +%systemd_postun_with_restart target.service + +%files +%{python_sitelib}/* +%{_bindir}/targetctl +%{_unitdir}/target.service +%doc COPYING README.md doc/getting_started.md +%{_mandir}/man8/targetctl.8.gz +%{_mandir}/man5/saveconfig.json.5.gz +%dir %{_sysconfdir}/target +%dir %{_sysconfdir}/target/backup +%dir %{_localstatedir}/target +%dir %{_localstatedir}/target/pr +%dir %{_localstatedir}/target/alua + +%if 0%{?with_python3} +%files -n python3-rtslib +%{python3_sitelib}/* +%doc COPYING README.md +%endif + +%files doc +%doc doc/html + +%changelog +* Tue May 14 2019 Maurizio Lombardi - 2.1.fb69-3 +- save_to_file() function breaks symbolic link when saving configuration + +* Thu Feb 14 2019 Maurizio Lombardi - 2.1.fb69-2 +- report the correct size for partitions + +* Tue Jan 29 2019 Maurizio Lombardi - 2.1.fb69-1 +- Rebase rtslib to upstream version 2.1.fb69 + +* Wed Aug 08 2018 Maurizio Lombardi - 2.1.fb63-13 +- respin a new release to avoid problems with TPS tests + +* Mon Jun 04 2018 Maurizio Lombardi - 2.1.fb63-12 +- saveconfig: way to block-level save with delete command + +* Tue Apr 24 2018 Maurizio Lombardi - 2.1.fb63-11 +- Fix a failure in absence of save file + +* Thu Apr 19 2018 Maurizio Lombardi - 2.1.fb63-10 +- Add missing patch "tcmu: add control constructor arg" + +* Fri Apr 13 2018 Maurizio Lombardi - 2.1.fb63-9 +- Support tcmu hw max sectors +- saveconfig: dump control string containing control=value tuples + +* Wed Apr 11 2018 Maurizio Lombardi - 2.1.fb63-8 +- Fix ALUA tpg config setup + +* Tue Apr 10 2018 Maurizio Lombardi - 2.1.fb63-7 +- Introduce support to saveconfig at the storage object level + +* Tue Mar 27 2018 Maurizio Lombardi - 2.1.fb63-6 +- enable alua for pscsi/tcmu if kernel reports support + +* Mon Feb 26 2018 Maurizio Lombardi - 2.1.fb63-5 +- rtslib never creates hba directories without a storage object within it, + but if under some circumstance these existed then we should remove them. + +* Wed Feb 21 2018 Maurizio Lombardi - 2.1.fb63-4 +- Allow users to pass in a string into the attributes. + +* Thu Nov 02 2017 Maurizio Lombardi - 2.1.fb63-3 +- Enabled qla2xxx target support to fix #1327710 + +* Wed May 17 2017 Andy Grover - 2.1.fb63-2 +- Add patch 0003 to fix #1440172 + +* Thu Mar 2 2017 Andy Grover - 2.1.fb63-1 +- Rebuild to fix now-fixed issue with redhat-rpm-config in build system + +* Fri Jul 29 2016 Andy Grover - 2.1.fb57-5 +- Rebuild to fix now-fixed issue with redhat-rpm-config in build system + +* Wed Jul 27 2016 Andy Grover - 2.1.fb57-4 +- Add 0003-Fix-regex-in-get_size_for_disk_name.patch + +* Wed Oct 28 2015 Andy Grover - 2.1.fb57-3 +- Add 0002-Fix-comparisons-to-None.patch for #1276044 + +* Mon Aug 24 2015 Andy Grover - 2.1.fb57-2 +- Include missing paths to resolve #1254670 + +* Tue Jul 14 2015 Andy Grover - 2.1.fb57-1 +- Update to latest Fedora version + +* Thu Oct 9 2014 Andy Grover - 2.1.fb50-1 +- Update to latest Fedora version + +* Mon Feb 24 2014 Andy Grover - 2.1.fb46-1 +- Update to latest Fedora version, fixes rhbz #1064753 + +* Wed Jan 15 2014 Andy Grover - 2.1.fb45-1 +- Update to latest Fedora version, to fix rhbz #1048803 + +* Fri Dec 27 2013 Daniel Mach - 2.1.fb44-2 +- Mass rebuild 2013-12-27 + +* Wed Dec 18 2013 Andy Grover - 2.1.fb44-1 +- Update to latest Fedora version + +* Wed Nov 6 2013 Andy Grover - 2.1.fb41-3 +- Don't overwrite py2 scripts with py3 scripts + +* Mon Nov 4 2013 Andy Grover - 2.1.fb41-2 +- Update rtslib-fix-setup.patch with backported fixups +- Add in missing systemd requires + +* Fri Nov 1 2013 Andy Grover - 2.1.fb41-1 +- New upstream version +- Remove obsolete spec stuff: clean, buildroot +- Add target.service + +* Mon Sep 23 2013 Andy Grover - 2.1.fb40-1 +- New upstream version, fixes restore of mappedluns + +* Wed Sep 11 2013 Andy Grover - 2.1.fb39-1 +- New upstream version, fixes fcoe + +* Tue Sep 10 2013 Andy Grover - 2.1.fb38-1 +- New upstream version + +* Sun Aug 04 2013 Fedora Release Engineering - 2.1.fb37-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Tue Jul 23 2013 Andy Grover - 2.1.fb37-1 +- New upstream version +- License now Apache 2.0 + +* Tue Jul 2 2013 Andy Grover - 2.1.fb36-1 +- New upstream version +- Remove fix-tabs.patch + +* Fri Jun 7 2013 Andy Grover - 2.1.fb35-1 +- New upstream version +- add fix-tabs.patch + +* Thu May 9 2013 Andy Grover - 2.1.fb34-1 +- New upstream version + +* Thu May 2 2013 Andy Grover - 2.1.fb33-1 +- New upstream version +- Update source file location + +* Tue Apr 16 2013 Andy Grover - 2.1.fb32-2 +- Add python3 subpackage + +* Tue Apr 9 2013 Andy Grover - 2.1.fb32-1 +- New upstream version + +* Tue Feb 26 2013 Andy Grover - 2.1.fb30-1 +- New upstream version +- Update description and summary +- Remove patch0, upstream doesn't include usb gadget any more + +* Thu Feb 14 2013 Fedora Release Engineering - 2.1.fb28-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Mon Jan 7 2013 Andy Grover - 2.1.fb28-1 +- New upstream version + +* Wed Jan 2 2013 Andy Grover - 2.1.fb27-1 +- Specfiles removed upstream, remove handling +- Refresh no-usb.patch + +* Thu Dec 20 2012 Andy Grover - 2.1.fb26-1 +- New upstream release +- Remove kernel dependency +- Remove python-ethtool and python-ipaddr dependencies + +* Tue Nov 13 2012 Andy Grover - 2.1.fb24-1 +- New upstream release + +* Tue Oct 30 2012 Andy Grover - 2.1.fb23-1 +- New upstream release + +* Thu Sep 6 2012 Andy Grover - 2.1.fb22-1 +- New upstream release + +* Wed Aug 8 2012 Andy Grover - 2.1.fb21-1 +- New upstream release + +* Tue Aug 7 2012 Andy Grover - 2.1.fb20-2 +- Add patch no-usb.patch + +* Tue Aug 7 2012 Andy Grover - 2.1.fb20-1 +- New upstream release. Add kernel version dependency. +- Don't claim python_sitelib + +* Thu Aug 2 2012 Andy Grover - 2.1.fb19-1 +- New upstream release. Add kmod dependency. + +* Tue Jul 31 2012 Andy Grover - 2.1.fb18-1 +- New upstream release. Remove configobj dependency + +* Sat Jul 21 2012 Fedora Release Engineering - 2.1.fb17-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Thu Jun 28 2012 Andy Grover - 2.1.fb17-1 +- New upstream release +- Remove patch retry-target-creation.patch, upstream has alternate + fix. + +* Tue Jun 12 2012 Andy Grover - 2.1.fb15-1 +- New upstream release + +* Wed May 30 2012 Andy Grover - 2.1.fb14-1 +- Update Source URL to proper tarball +- Add patch retry-target-creation.patch +- New upstream release + +* Mon Apr 9 2012 Andy Grover - 2.1.fb13-1 +- New upstream release + +* Wed Feb 29 2012 Andy Grover - 2.1.fb12-2 +- Add -doc package of epydoc-generated html docs + +* Wed Feb 29 2012 Andy Grover - 2.1.fb12-1 +- New upstream release + +* Tue Feb 21 2012 Andy Grover - 2.1.fb11-1 +- New upstream release + +* Fri Feb 10 2012 Andy Grover - 2.1.fb9-1 +- New upstream release + +* Fri Feb 3 2012 Andy Grover - 2.1.fb8-1 +- New upstream release + +* Tue Jan 24 2012 Andy Grover - 2.1.fb7-1 +- New upstream release + +* Tue Jan 24 2012 Andy Grover - 2.1.fb6-1 +- New upstream release + +* Fri Jan 13 2012 Andy Grover - 2.1.fb5-1 +- New upstream release + +* Fri Jan 13 2012 Andy Grover - 2.1.fb4-1 +- New upstream release + +* Tue Jan 10 2012 Andy Grover - 2.1.fb3-1 +- New upstream release + +* Tue Dec 6 2011 Andy Grover - 2.1.fb2-1 +- New upstream release + +* Tue Dec 6 2011 Andy Grover - 2.1.fb1-1 +- Change upstream URL +- New upstream release +- Remove upstreamed patches: + * python-rtslib-git-version.patch + * python-rtslib-use-ethtool.patch + * python-rtslib-update-specpath.patch + +* Mon Nov 14 2011 Andy Grover - 1.99.1.git644eece-8 +- Change archive instructions to use gzip -n +- Fix issues raised in Fedora package review (#744349) + +* Thu Oct 6 2011 Andy Grover - 1.99.1.git644eece-7 +- Remove patch + * python-rtslib-del-unused-specs.patch + +* Wed Aug 17 2011 Andy Grover - 1.99-6 +- Update based on review comments + - Fully document steps to build archive + - Remove commented-out extraneous text + - Remove a repeat in Requires line + - Update git-version.patch to have proper sha1 + - Change location of fabric spec files to /var/lib/target +- Remove unused specs + +* Tue May 10 2011 Andy Grover - 1.99-1 +- Initial packaging