Accepting request 775439 from home:lee_duncan:branches:Base:System

- Update to version 2.1.51 from 2.1.49, which includes
  the addition of a targetcli daemon, which can be used
  to speed up batch processing. See changes file for
  details.

OBS-URL: https://build.opensuse.org/request/show/775439
OBS-URL: https://build.opensuse.org/package/show/Base:System/targetcli-fb?expand=0&rev=38
This commit is contained in:
Lee Duncan 2020-02-18 18:51:35 +00:00 committed by Git OBS Bridge
parent 2207f820d2
commit ddb82c3654
14 changed files with 113 additions and 317 deletions

View File

@ -1,29 +0,0 @@
From fa71860b0d819a691683c1fdcb70c255653b5851 Mon Sep 17 00:00:00 2001
From: David Disseldorp <ddiss@suse.de>
Date: Tue, 15 Jan 2019 12:04:49 +0100
Subject: [PATCH] Add emulate_pr backstore attribute
Added to the kernel via b49d6f7885306ee636d5c1af52170f3069ccf5f7, the
emulate_pr attribute can be used to disable support for SCSI-2
(RESERVE/RELEASE) and Persistent Reservations.
Signed-off-by: David Disseldorp <ddiss@suse.de>
---
targetcli/ui_backstore.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/targetcli/ui_backstore.py b/targetcli/ui_backstore.py
index efa532f..cc2cf2b 100644
--- a/targetcli/ui_backstore.py
+++ b/targetcli/ui_backstore.py
@@ -670,6 +670,7 @@ class UIStorageObject(UIRTSLibNode):
'emulate_tpws': ('number', 'If set to 1, enable Thin Provisioning Write Same.'),
'emulate_ua_intlck_ctrl': ('number', 'If set to 1, enable Unit Attention Interlock.'),
'emulate_write_cache': ('number', 'If set to 1, turn on Write Cache Enable.'),
+ 'emulate_pr': ('number', 'If set to 1, enable SCSI Reservations.'),
'enforce_pr_isids': ('number', 'If set to 1, enforce persistent reservation ISIDs.'),
'force_pr_aptpl': ('number', 'If set to 1, force SPC-3 PR Activate Persistence across Target Power Loss operation.'),
'fabric_max_sectors': ('number', 'Maximum number of sectors the fabric can transfer at once.'),
--
2.16.4

View File

@ -1,20 +1,22 @@
From 7374ba0e53d8e6af4abbb02bd60f35ed541b94f5 Mon Sep 17 00:00:00 2001
From: David Disseldorp <ddiss@suse.de>
Date: Tue, 10 Apr 2018 16:22:54 +0200
Subject: [PATCH 3/4] Split out blockdev readonly state detection helper
Patch-mainline: never (SUSE-specific)
Subject: Split out blockdev readonly state detection helper
So that it can be reused for RBD backstores.
Note: not accepted upstream, but still needed
here for our rbd stuff. (lduncan@suse.com)
Signed-off-by: David Disseldorp <ddiss@suse.de>
---
targetcli/ui_backstore.py | 40 ++++++++++++++++++++--------------------
targetcli/ui_backstore.py | 40 ++++++++++++++++++++--------------------
1 file changed, 20 insertions(+), 20 deletions(-)
diff --git a/targetcli/ui_backstore.py b/targetcli/ui_backstore.py
index 546d9d2..57dedb1 100644
--- a/targetcli/ui_backstore.py
+++ b/targetcli/ui_backstore.py
@@ -117,6 +117,25 @@ def complete_path(path, stat_fn):
@@ -119,6 +119,25 @@ def complete_path(path, stat_fn):
return sorted(filtered,
key=lambda s: '~'+s if s.endswith('/') else s)
@ -40,7 +42,7 @@ index 546d9d2..57dedb1 100644
class UIALUATargetPortGroup(UIRTSLibNode):
'''
@@ -519,25 +538,6 @@ class UIBlockBackstore(UIBackstore):
@@ -536,25 +555,6 @@ class UIBlockBackstore(UIBackstore):
self.so_cls = UIBlockStorageObject
UIBackstore.__init__(self, 'block', parent)
@ -65,8 +67,8 @@ index 546d9d2..57dedb1 100644
-
def ui_command_create(self, name, dev, readonly=None, wwn=None):
'''
Creates an Block Storage object. I{dev} is the path to the TYPE_DISK
@@ -548,7 +548,7 @@ class UIBlockBackstore(UIBackstore):
Creates an Block Storage object. "dev" is the path to the TYPE_DISK
@@ -565,7 +565,7 @@ class UIBlockBackstore(UIBackstore):
ro_string = self.ui_eval_param(readonly, 'string', None)
if ro_string == None:
# attempt to detect block device readonly state via ioctl
@ -75,6 +77,3 @@ index 546d9d2..57dedb1 100644
else:
readonly = self.ui_eval_param(readonly, 'bool', False)
--
2.13.6

View File

@ -5,9 +5,9 @@
<param name="subdir"></param>
<param name="filename">targetcli-fb</param>
<param name="versionformat">@PARENT_TAG@</param>
<param name="versionrewrite-pattern">v(\d*\.\d*\.)fb(\d*)</param>
<param name="versionrewrite-pattern">v(\d*\.\d*\.)(\d*)</param>
<param name="versionrewrite-replacement">\1\2</param>
<param name="revision">v2.1.fb49</param>
<param name="revision">v2.1.51</param>
<param name="changesgenerate">enable</param>
</service>
<service name="recompress" mode="disabled">

View File

@ -1,4 +1,4 @@
<servicedata>
<service name="tar_scm">
<param name="url">https://github.com/open-iscsi/targetcli-fb.git</param>
<param name="changesrevision">4d08771c0e6bf3cacba2ed3d3127dd10a86a7847</param></service></servicedata>
<param name="changesrevision">06076aba7e9e9bd4a1e84bac61e85265e8075b8e</param></service></servicedata>

View File

@ -1,31 +0,0 @@
From: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
Date: Sat, 11 May 2019 15:15:16 +0200
Subject: Do not remove the first digit when auto-completing the TPG tag
Git-commit: 311ae0fc49174316c991dd3800c12549632e2c64
Instead of removing the first three characters of the "tpg" prefix to
get matches for the TPG tag number, the code removes four characters,
thus erasing the first digit of the TPG tag number.
This patches fixes issue #134.
Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
Acked-by: Lee Duncan <lduncan@suse.com>
---
targetcli/ui_target.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/targetcli/ui_target.py b/targetcli/ui_target.py
index 6895b38e62b8..0c3fe1b708db 100644
--- a/targetcli/ui_target.py
+++ b/targetcli/ui_target.py
@@ -384,7 +384,7 @@ class UIMultiTPGTarget(UIRTSLibNode):
@rtype: list of str
'''
if current_param == 'tag':
- tags = [child.name[4:] for child in self.children]
+ tags = [child.name[3:] for child in self.children]
completions = [tag for tag in tags if tag.startswith(text)]
else:
completions = []

View File

@ -1,78 +0,0 @@
From: Lee Duncan <lduncan@suse.com>
Date: Thu, 15 Aug 2019 08:38:35 -0700
Subject: iscsi discovery_auth enable is a number not a string
Git-commit: dc8d9d83cef8489f3b6aec1609299cdba70eda34
The discovery_auth attribute group in the /iscsi node
has several attributes, and all area treated like strings,
even though "enable" is a number in sysfs, accepting either
zero or one. It would break backwards compatability to
convert this attribute to be a boolean, so at least
treat it like a proper number instead of a string.
This avoids stack dumps like the following when trying
to set this attribute to 'true' or 'false':
> /iscsi> set discovery_auth enable=false
> Traceback (most recent call last):
> File "/usr/bin/targetcli", line 122, in <module>
> main()
> File "/usr/bin/targetcli", line 112, in main
> shell.run_interactive()
> File "/usr/lib/python3.6/site-packages/configshell_fb/shell.py", line 905, in run_interactive
> self._cli_loop()
> File "/usr/lib/python3.6/site-packages/configshell_fb/shell.py", line 734, in _cli_loop
> self.run_cmdline(cmdline)
> File "/usr/lib/python3.6/site-packages/configshell_fb/shell.py", line 848, in run_cmdline
> self._execute_command(path, command, pparams, kparams)
> File "/usr/lib/python3.6/site-packages/configshell_fb/shell.py", line 823, in _execute_command
> result = target.execute_command(command, pparams, kparams)
> File "/usr/lib/python3.6/site-packages/configshell_fb/node.py", line 1406, in execute_command
> return method(*pparams, **kparams)
> File "/usr/lib/python3.6/site-packages/configshell_fb/node.py", line 522, in ui_command_set
> group_setter(param, value)
> File "/usr/lib/python3.6/site-packages/targetcli/ui_target.py", line 134, in ui_setgroup_discovery_auth
> self.rtsnode.discovery_enable_auth = value
> File "/usr/lib/python3.6/site-packages/rtslib_fb/fabric.py", line 243, in _set_discovery_enable_auth
> if int(enable):
> ValueError: invalid literal for int() with base 10: 'false'
Now the output will be:
> Not setting enable! Syntax error, 'false' is not a NUMBER.
Acked-by: Lee Duncan <lduncan@suse.com>
---
targetcli/ui_target.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/targetcli/ui_target.py b/targetcli/ui_target.py
index 0c3fe1b708db..16ccae715688 100644
--- a/targetcli/ui_target.py
+++ b/targetcli/ui_target.py
@@ -34,7 +34,8 @@ from .ui_backstore import complete_path
from .ui_node import UINode, UIRTSLibNode
auth_params = ('userid', 'password', 'mutual_userid', 'mutual_password')
-discovery_params = auth_params + ("enable",)
+int_params = ('enable',)
+discovery_params = auth_params + int_params
class UIFabricModule(UIRTSLibNode):
'''
@@ -47,8 +48,12 @@ class UIFabricModule(UIRTSLibNode):
self.refresh()
if self.rtsnode.has_feature('discovery_auth'):
for param in discovery_params:
- self.define_config_group_param('discovery_auth',
- param, 'string')
+ if param in int_params:
+ self.define_config_group_param('discovery_auth',
+ param, 'number')
+ else:
+ self.define_config_group_param('discovery_auth',
+ param, 'string')
self.refresh()
# Support late params

View File

@ -1,116 +0,0 @@
From: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Date: Wed, 28 Nov 2018 16:55:38 +0530
Subject: saveconfig: compress the backup config files
Git-commit: 3d9e6c616ca7789d281843caf2d3dfb99dbf78a0
We have noticed saveconfig.json with 100 storage objects and 100 targets
(each holding a single tpg and a portal) consumes disk space around ~500K.
Which is very expensive, and backing-up such 100 saveconfig.json files will
take ~50M of disk space under /etc/target/backup/
And at scale like 1000 storage objects and targets, this will become worst.
Hence this patch attempts to compress(gzip) and store saveconfig.json while
backing-up.
Saved space example:
[root@localhost ~]# targetcli ls | grep -e "user:glfs" -e "iscsi"
| o- user:glfs ......................... [Storage Objects: 100]
o- iscsi ............................... [Targets: 100]
[root@localhost ~]# du -sh /etc/target/saveconfig.json
448K /etc/target/saveconfig.json
[root@localhost ~]# du -sh /etc/target/backup/saveconfig-20181128-18\:20\:43-json.gz
12K /etc/target/backup/saveconfig-20181128-18:20:43-json.gz
Reducing disk usage per backup file from 448K to 12K is very efficient right.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Acked-by: Lee Duncan <lduncan@suse.com>
---
targetcli/ui_root.py | 44 +++++++++++++++++++++++++++++++++++++++-----
1 file changed, 39 insertions(+), 5 deletions(-)
diff --git a/targetcli/ui_root.py b/targetcli/ui_root.py
index 38118bd582f6..6f3a79bf4f66 100644
--- a/targetcli/ui_root.py
+++ b/targetcli/ui_root.py
@@ -24,6 +24,7 @@ import re
import shutil
import stat
import filecmp
+import gzip
from configshell_fb import ExecutionError
from rtslib_fb import RTSRoot
@@ -62,6 +63,38 @@ class UIRoot(UINode):
if fm.wwns == None or any(fm.wwns):
UIFabricModule(fm, self)
+ def _compare_files(self, backupfile, savefile):
+ '''
+ Compare backfile and saveconfig file
+ '''
+ if (os.path.splitext(backupfile)[1] == '.gz'):
+ try:
+ with gzip.open(backupfile, 'rb') as fbkp:
+ fdata_bkp = fbkp.read()
+ except IOError as e:
+ self.shell.log.warning("Could not gzip open backupfile %s: %s"
+ % (backupfile, e.strerror))
+
+ else:
+ try:
+ with open(backupfile, 'rb') as fbkp:
+ fdata_bkp = fbkp.read()
+ except IOError as e:
+ self.shell.log.warning("Could not open backupfile %s: %s"
+ % (backupfile, e.strerror))
+
+ try:
+ with open(savefile, 'rb') as f:
+ fdata = f.read()
+ except IOError as e:
+ self.shell.log.warning("Could not open saveconfig file %s: %s"
+ % (savefile, e.strerror))
+
+ if fdata_bkp == fdata:
+ return True
+ else:
+ return False
+
def _save_backups(self, savefile):
'''
Take backup of config-file if needed.
@@ -72,7 +105,7 @@ class UIRoot(UINode):
backup_dir = os.path.dirname(savefile) + "/backup/"
backup_name = "saveconfig-" + \
- datetime.now().strftime("%Y%m%d-%H:%M:%S") + ".json"
+ datetime.now().strftime("%Y%m%d-%H:%M:%S") + "-json.gz"
backupfile = backup_dir + backup_name
backup_error = None
@@ -88,13 +121,14 @@ class UIRoot(UINode):
return
backed_files_list = sorted(glob(os.path.dirname(savefile) + \
- "/backup/*.json"))
+ "/backup/saveconfig-*json*"))
# Save backup if backup dir is empty, or savefile is differnt from recent backup copy
- if not backed_files_list or not filecmp.cmp(backed_files_list[-1], savefile):
+ if not backed_files_list or not self._compare_files(backed_files_list[-1], savefile):
try:
- shutil.copy(savefile, backupfile)
-
+ with open(savefile, 'rb') as f_in, gzip.open(backupfile, 'wb') as f_out:
+ shutil.copyfileobj(f_in, f_out)
+ f_out.flush()
except IOError as ioe:
backup_error = ioe.strerror or "Unknown error"

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ad5a9438589cb63bbde70ecaf78614686b8b623480297f210bb323972d7acb66
size 30080

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:523e75fa1cc5820baee823f89b1d514b3458fd9c5ce7b438a3af7038c2d467a5
size 33464

View File

@ -1,25 +0,0 @@
From: Leo Zhang <nguzcf@gmail.com>
Date: Wed, 9 Jan 2019 14:20:28 +0800
Subject: targetcli-fb: Fix raise exception error in _save_backups
Git-commit: f6e813454c18e02222473713f53db5be99b84142
Signed-off-by: Leo Zhang <nguzcf@gmail.com>
Acked-by: Lee Duncan <lduncan@suse.com>
---
targetcli/ui_root.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/targetcli/ui_root.py b/targetcli/ui_root.py
index 6f3a79bf4f66..af5554f2dd76 100644
--- a/targetcli/ui_root.py
+++ b/targetcli/ui_root.py
@@ -114,7 +114,7 @@ class UIRoot(UINode):
os.makedirs(backup_dir);
except OSError as exe:
raise ExecutionError("Cannot create backup directory [%s] %s."
- % (backup_dir, exc.strerror))
+ % (backup_dir, exe.strerror))
# Only save backups if savefile exits
if not os.path.exists(savefile):

View File

@ -1,3 +1,51 @@
-------------------------------------------------------------------
Wed Feb 12 17:58:15 UTC 2020 - lduncan@suse.com
- Update to version 2.1.51 from 2.1.49, which includes
the addition of a targetcli daemon, which can be used
to speed up batch processing. With patches:
* version 2.1.51
* targetcli: depreciate the redundant '--tcp' option
* man: add daemon intro at targetcli(8) man page
* systemd-units: fix documentation
* targetclid: add man page entry
* daemon: load the prefs on every new connection
* cli: show useful hint in header area of shell in daemonized mode
* cli: provide a way to disable using daemon
* cli: show better error msg when daemon is not running
* Do not print err msg when signal closes socket.
* Handle systemd socket activation, when present.
* Close socket when receiving a signal to interrupt connection.
* Exit with success when getting a signal.
* Only return response to targetcli when bytes present
* Removed useless semicolons, as they're ignored
* Handle OSError correctly: use strerror to get string
* Tweak systemd socket-activation settings for daemon
* Handle Python 3.7 stricter binary vs. string rules.
* Fix indention for targetclid when processing output.
* version 2.1.50
* iscsi discovery_auth enable is a number not a string
* restoreconfig: add ability to restore/reload single target or storage_object
* Fix a syntax error in some except clauses
* Remove Epydoc markup from command messages
* targetcli: serialize multiple requests
* targetcli: way to enable targetclid as default choice
* targetclid: enable socket based activation
* targetclid: add daemonize component for targetcli
* Do not remove the first digit when auto-completing the TPG tag
* Remove the extra semicolon in _save_backups
* Add emulate_pr backstore attribute
* targetcli-fb: Fix raise exception error in _save_backups
* saveconfig: compress the backup config files
This replaces targetcli-fb-2.1.49.tar.xz with
targetcli-fb-2.1.51.tar.xz, and removes the following patches,
which area already upstream:
* Add-emulate_pr-backstore-attribute.patch
* do-not-remove-the-first-digit-when-auto-completing-the-tpg-tag
* iscsi-discovery_auth-enable-is-a-number-not-a-string
* saveconfig-compress-the-backup-config-files
* targetcli-fb-fix-raise-exception-error-in-save_backups
-------------------------------------------------------------------
Mon Feb 3 16:38:45 UTC 2020 - Dominique Leuenberger <dimstar@opensuse.org>

View File

@ -18,7 +18,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: targetcli-fb
Version: 2.1.49
Version: 2.1.51
Release: 0
Summary: A command shell for managing the Linux LIO kernel target
License: Apache-2.0
@ -26,6 +26,8 @@ Group: System/Management
URL: https://github.com/open-iscsi/%{name}
Source: %{name}-%{version}.tar.xz
Source1: %{name}.service
Source2: targetclid.socket
Source3: targetclid.service
BuildRequires: %{python_module configshell-fb}
BuildRequires: %{python_module devel}
BuildRequires: %{python_module pyparsing}
@ -45,8 +47,8 @@ Requires(postun): update-alternatives
Provides: targetcli = %{version}-%{release}
Provides: targetcli-fb = %{version}-%{release}
%endif
Obsoletes: targetcli
Obsoletes: targetcli-fb
Obsoletes: targetcli < %{version}-%{release}
Obsoletes: targetcli-fb < %{version}-%{release}
BuildArch: noarch
%if 0%{?sle_version} >= 150000
# explicit Provides advertising RBD support
@ -56,11 +58,6 @@ Obsoletes: targetcli-rbd < %{version}
%{?systemd_ordering}
Patch1: Split-out-blockdev-readonly-state-detection-helper.patch
Patch2: rbd-support.patch
Patch3: saveconfig-compress-the-backup-config-files
Patch4: targetcli-fb-fix-raise-exception-error-in-save_backups
Patch5: Add-emulate_pr-backstore-attribute.patch
Patch6: do-not-remove-the-first-digit-when-auto-completing-the-tpg-tag
Patch7: iscsi-discovery_auth-enable-is-a-number-not-a-string
%python_subpackages
@ -90,11 +87,6 @@ python2-targetcli-fb and python3-targetcli-fb.
# RBD support is dependent on LIO changes present in the SLE/Leap kernel
%patch2 -p1
%endif
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%build
%python_build
@ -102,48 +94,62 @@ python2-targetcli-fb and python3-targetcli-fb.
%install
%python_install
%python_clone -a %{buildroot}%{_bindir}/targetcli
%python_clone -a %{buildroot}%{_bindir}/targetclid
install -d -m755 %{buildroot}%{_sysconfdir}/target
install -d -m755 %{buildroot}%{_sysconfdir}/target/backup
install -d -m755 %{buildroot}%{_sbindir}
install -D -m644 targetcli.8 %{buildroot}%{_mandir}/man8/targetcli.8
install -D -m644 %{SOURCE1} %{buildroot}%{_unitdir}/targetcli.service
install -D -m644 targetclid.8 %{buildroot}%{_mandir}/man8/targetclid.8
install -D -m644 %{S:1} %{buildroot}%{_unitdir}/targetcli.service
install -D -m644 %{S:2} %{buildroot}%{_unitdir}/targetclid.socket
install -D -m644 %{S:3} %{buildroot}%{_unitdir}/targetclid.service
%fdupes %{buildroot}
ln -s %{_sbindir}/service %{buildroot}/%{_sbindir}/rctargetcli
ln -s %{_sbindir}/service %{buildroot}/%{_sbindir}/rctargetclid
%post
%python_install_alternative targetcli
%python_install_alternative targetclid
%postun
%python_uninstall_alternative targetcli
%python_uninstall_alternative targetclid
%pre
%{service_add_pre targetcli.service}
%{service_add_pre targetcli.service targetclid.socket targetclid.service}
%preun
%{stop_on_removal targetcli}
%{stop_on_removal targetcld targetcli}
%{service_del_preun targetcli.service targetclid.socket targetclid.service}
%post -n %{name}-common
%{service_add_post targetcli.service}
%{service_add_post targetcli.service targetclid.socket targetclid.service}
%postun -n %{name}-common
%{service_del_postun targetcli.service}
%{service_del_postun targetcli.service targetclid.socket targetclid.service}
%pre -n %{name}-common
%{service_add_pre targetcli.service}
%{service_add_pre targetcli.service targetclid.socket targetclid.service}
%preun -n %{name}-common
%{service_del_preun targetcli.service}
%{service_del_preun targetcli.service targetclid.socket targetclid.service}
%files %{python_files}
%python_alternative %{_bindir}/targetcli
%python_alternative %{_bindir}/targetclid
%{python_sitelib}/*
%files -n %{name}-common
%doc COPYING README.md THANKS
%license COPYING
%doc README.md THANKS
%dir %{_sysconfdir}/target
%dir %{_sysconfdir}/target/backup
%doc %{_mandir}/man8/targetcli.8%{ext_man}
%doc %{_mandir}/man8/targetclid.8%{ext_man}
%{_unitdir}/targetcli.service
%{_unitdir}/targetclid.service
%{_unitdir}/targetclid.socket
%{_sbindir}/rctargetcli
%{_sbindir}/rctargetclid
%changelog

13
targetclid.service Normal file
View File

@ -0,0 +1,13 @@
[Unit]
Description=Targetcli daemon
Documentation=man:targetclid(8)
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/targetclid
Restart=on-failure
[Install]
WantedBy=multi-user.target
Also=targetclid.socket

9
targetclid.socket Normal file
View File

@ -0,0 +1,9 @@
[Unit]
Description=targetclid socket
Documentation=man:targetclid(8)
[Socket]
ListenStream=/var/run/targetclid.sock
[Install]
WantedBy=sockets.target