diff --git a/SOURCES/0014-saveconfig-handle-no-attr-exception-in-_parse_info.patch b/SOURCES/0014-saveconfig-handle-no-attr-exception-in-_parse_info.patch new file mode 100644 index 0000000..5d52002 --- /dev/null +++ b/SOURCES/0014-saveconfig-handle-no-attr-exception-in-_parse_info.patch @@ -0,0 +1,48 @@ +From b10c921a2d3bf2b84531ee7303a494919de67ae5 Mon Sep 17 00:00:00 2001 +From: Prasanna Kumar Kalever +Date: Fri, 1 Jun 2018 14:05:14 +0530 +Subject: [PATCH] saveconfig: handle no attr exception in _parse_info() + +$ targetcli / saveconfig +'NoneType' object has no attribute 'group' + +Signed-off-by: Prasanna Kumar Kalever +--- + rtslib/tcm.py | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/rtslib/tcm.py b/rtslib/tcm.py +index 4feb738..4ed96b4 100644 +--- a/rtslib/tcm.py ++++ b/rtslib/tcm.py +@@ -184,8 +184,11 @@ class StorageObject(CFSNode): + def _parse_info(self, key): + self._check_self() + info = fread("%s/info" % self.path) +- return re.search(".*%s: ([^: ]+).*" \ +- % key, ' '.join(info.split())).group(1) ++ try: ++ return re.search(".*%s: ([^: ]+).*" \ ++ % key, ' '.join(info.split())).group(1) ++ except AttributeError: ++ return None + + def _get_status(self): + self._check_self() +@@ -994,8 +997,11 @@ class _Backstore(CFSNode): + def _parse_info(self, key): + self._check_self() + info = fread("%s/hba_info" % self.path) +- return re.search(".*%s: ([^: ]+).*" \ +- % key, ' '.join(info.split())).group(1) ++ try: ++ return re.search(".*%s: ([^: ]+).*" \ ++ % key, ' '.join(info.split())).group(1) ++ except AttributeError: ++ return None + + def _get_version(self): + self._check_self() +-- +1.8.3.1 + diff --git a/SOURCES/0015-saveconfig-fix-missing-import.patch b/SOURCES/0015-saveconfig-fix-missing-import.patch new file mode 100644 index 0000000..3bdbd28 --- /dev/null +++ b/SOURCES/0015-saveconfig-fix-missing-import.patch @@ -0,0 +1,28 @@ +From f5db37f59f69bccbef9ca6b2a792031bc4d70ee2 Mon Sep 17 00:00:00 2001 +From: Prasanna Kumar Kalever +Date: Fri, 1 Jun 2018 15:15:18 +0530 +Subject: [PATCH] saveconfig: fix missing import + +$ targetcli /backstores/user:glfs/test saveconfig +NameError: "global name 'errno' is not defined" + +Signed-off-by: Prasanna Kumar Kalever +--- + rtslib/root.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/rtslib/root.py b/rtslib/root.py +index 13401e5..7ea06fa 100644 +--- a/rtslib/root.py ++++ b/rtslib/root.py +@@ -22,6 +22,7 @@ import os + import stat + import json + import glob ++import errno + + from .node import CFSNode + from .target import Target +-- +1.8.3.1 + diff --git a/SOURCES/0016-saveconfig-way-for-block-level-save-with-delete-comm.patch b/SOURCES/0016-saveconfig-way-for-block-level-save-with-delete-comm.patch new file mode 100644 index 0000000..3e9115f --- /dev/null +++ b/SOURCES/0016-saveconfig-way-for-block-level-save-with-delete-comm.patch @@ -0,0 +1,46 @@ +From 7213c27f03e5cbabb755da8e6cbe39c75c68c351 Mon Sep 17 00:00:00 2001 +From: Prasanna Kumar Kalever +Date: Fri, 1 Jun 2018 15:18:18 +0530 +Subject: [PATCH] saveconfig: way for block-level save with delete command + +currently, we can use block-level save feature for create command and +reconfig of different attributes, but there is no way to use block-level +feature for delete command. + +This patch introduces 'save' flag (False on default), which can trigger +saveconfig internally as part of delete command. + +$ targetcli /backstores/user:glfs delete test save=True +Deleted storage object test. + +Signed-off-by: Prasanna Kumar Kalever +--- + rtslib/tcm.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/rtslib/tcm.py b/rtslib/tcm.py +index 4ed96b4..58952d6 100644 +--- a/rtslib/tcm.py ++++ b/rtslib/tcm.py +@@ -251,7 +251,7 @@ class StorageObject(CFSNode): + + # StorageObject public stuff + +- def delete(self): ++ def delete(self, save=False): + ''' + Recursively deletes a StorageObject object. + This will delete all attached LUNs currently using the StorageObject +@@ -274,6 +274,9 @@ class StorageObject(CFSNode): + + super(StorageObject, self).delete() + self._backstore.delete() ++ if save: ++ from .root import RTSRoot, default_save_file ++ RTSRoot().save_to_file(default_save_file, '/backstores/' + self.plugin + '/' + self._name) + + def is_configured(self): + ''' +-- +1.8.3.1 + diff --git a/SPECS/python-rtslib.spec b/SPECS/python-rtslib.spec index c723deb..4ad7feb 100644 --- a/SPECS/python-rtslib.spec +++ b/SPECS/python-rtslib.spec @@ -9,7 +9,7 @@ License: ASL 2.0 Group: System Environment/Libraries Summary: API for Linux kernel LIO SCSI target Version: 2.1.fb63 -Release: 11%{?dist} +Release: 12%{?dist} URL: https://fedorahosted.org/targetcli-fb/ Source: https://fedorahosted.org/released/targetcli-fb/%{oname}-%{version}.tar.gz Source1: target.service @@ -26,6 +26,9 @@ Patch9: 0010-Support-tcmu-hw-max-sectors.patch Patch10: 0011-saveconfig-dump-control-string-containing-control-va.patch Patch11: 0012-tcmu-add-control-constructor-arg.patch Patch12: 0013-saveconfig-fix-failure-in-absence-of-save-file.patch +Patch13: 0014-saveconfig-handle-no-attr-exception-in-_parse_info.patch +Patch14: 0015-saveconfig-fix-missing-import.patch +Patch15: 0016-saveconfig-way-for-block-level-save-with-delete-comm.patch BuildArch: noarch BuildRequires: python-devel epydoc python-setuptools systemd-units python-six python-pyudev Requires: python-kmod python-six python-pyudev @@ -75,6 +78,9 @@ API for generic Linux SCSI kernel target. %patch10 -p1 %patch11 -p1 %patch12 -p1 +%patch13 -p1 +%patch14 -p1 +%patch15 -p1 %if 0%{?with_python3} rm -rf %{py3dir} @@ -148,6 +154,9 @@ popd %doc doc/html %changelog +* 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