Hello community,

here is the log from the commit of package targetcli-fb for openSUSE:Factory 
checked in at 2019-08-20 10:59:30
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/targetcli-fb (Old)
 and      /work/SRC/openSUSE:Factory/.targetcli-fb.new.22127 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "targetcli-fb"

Tue Aug 20 10:59:30 2019 rev:14 rq:724620 version:2.1.49

Changes:
--------
--- /work/SRC/openSUSE:Factory/targetcli-fb/targetcli-fb.changes        
2019-05-22 11:16:23.142516090 +0200
+++ /work/SRC/openSUSE:Factory/.targetcli-fb.new.22127/targetcli-fb.changes     
2019-08-20 10:59:37.368653367 +0200
@@ -1,0 +2,10 @@
+Mon Aug 19 15:32:55 UTC 2019 - Lee Duncan <[email protected]>
+
+- Added the following upstream patches:
+  * targetcli-fb-fix-raise-exception-error-in-save_backups
+  * iscsi-discovery_auth-enable-is-a-number-not-a-string (bsc#1145685)
+  * saveconfig-compress-the-backup-config-files
+  * do-not-remove-the-first-digit-when-auto-completing-the-tpg-tag
+  * add-emulate_pr-backstore-attribute
+
+-------------------------------------------------------------------

New:
----
  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

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ targetcli-fb.spec ++++++
--- /var/tmp/diff_new_pack.5rQXBX/_old  2019-08-20 10:59:38.080653219 +0200
+++ /var/tmp/diff_new_pack.5rQXBX/_new  2019-08-20 10:59:38.080653219 +0200
@@ -56,7 +56,11 @@
 %{?systemd_requires}
 Patch1:         Split-out-blockdev-readonly-state-detection-helper.patch
 Patch2:         rbd-support.patch
-Patch3:         Add-emulate_pr-backstore-attribute.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
 
@@ -87,6 +91,10 @@
 %patch2 -p1
 %endif
 %patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+%patch7 -p1
 
 %build
 %python_build

++++++ do-not-remove-the-first-digit-when-auto-completing-the-tpg-tag ++++++
From: Christophe Vu-Brugier <[email protected]>
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 <[email protected]>
Acked-by: Lee Duncan <[email protected]>
---
 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 = []

++++++ iscsi-discovery_auth-enable-is-a-number-not-a-string ++++++
From: Lee Duncan <[email protected]>
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 <[email protected]>
---
 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

++++++ saveconfig-compress-the-backup-config-files ++++++
From: Prasanna Kumar Kalever <[email protected]>
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 <[email protected]>
Acked-by: Lee Duncan <[email protected]>
---
 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"
 

++++++ targetcli-fb-fix-raise-exception-error-in-save_backups ++++++
From: Leo Zhang <[email protected]>
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 <[email protected]>
Acked-by: Lee Duncan <[email protected]>
---
 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):


Reply via email to