Hello community,

here is the log from the commit of package python-rtslib-fb for 
openSUSE:Factory checked in at 2017-07-06 00:04:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-rtslib-fb (Old)
 and      /work/SRC/openSUSE:Factory/.python-rtslib-fb.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-rtslib-fb"

Thu Jul  6 00:04:03 2017 rev:11 rq:508175 version:2.1.63

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-rtslib-fb/python-rtslib-fb.changes        
2017-04-28 09:13:47.721919345 +0200
+++ /work/SRC/openSUSE:Factory/.python-rtslib-fb.new/python-rtslib-fb.changes   
2017-07-06 00:04:05.148498031 +0200
@@ -1,0 +2,7 @@
+Thu Jun  8 21:37:20 UTC 2017 - [email protected]
+
+- Enable Persistent Reservations (bsc#1042944):
+  * Add patch Switch-target-driver-DB-root-dir-to-etc-target.patch
+  * Add /etc/target/pr and /etc/target/alua to SPEC file
+
+-------------------------------------------------------------------

New:
----
  Switch-target-driver-DB-root-dir-to-etc-target.patch

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

Other differences:
------------------
++++++ python-rtslib-fb.spec ++++++
--- /var/tmp/diff_new_pack.xDFs7F/_old  2017-07-06 00:04:05.728416333 +0200
+++ /var/tmp/diff_new_pack.xDFs7F/_new  2017-07-06 00:04:05.732415770 +0200
@@ -18,6 +18,7 @@
 
 %define oname rtslib-fb
 %define realver 2.1.fb63
+%define dbdir /etc/target
 
 Name:           python-%{oname}
 Version:        2.1.63
@@ -27,6 +28,7 @@
 License:        Apache-2.0
 Group:          Development/Languages/Python
 Source:         %{oname}-%{realver}.tar.xz
+Patch1:         Switch-target-driver-DB-root-dir-to-etc-target.patch
 Conflicts:      python-rtslib
 BuildRequires:  fdupes
 BuildRequires:  python-devel
@@ -54,6 +56,7 @@
 
 %prep
 %setup -q -n %{oname}-%{realver}
+%patch1 -p1
 
 %build
 %__python setup.py build
@@ -73,6 +76,9 @@
 %__install -m644 doc/saveconfig.json.5 %{buildroot}%{_mandir}/man5
 %__install -d -m755 %{buildroot}%{_mandir}/man8
 %__install -m644 doc/targetctl.8 %{buildroot}%{_mandir}/man8
+%__install -d -m755 %{buildroot}/%{dbdir}
+%__install -d -m755 %{buildroot}/%{dbdir}/pr
+%__install -d -m755 %{buildroot}/%{dbdir}/alua
 
 %clean
 [ "%{buildroot}" != "/" ] && %__rm -rf %{buildroot}
@@ -85,6 +91,9 @@
 %dir %{_sysconfdir}/target
 %doc %{_mandir}/man5/saveconfig.json.5.gz
 %doc %{_mandir}/man8/targetctl.8.gz
+%dir %{dbdir}
+%dir %{dbdir}/pr
+%dir %{dbdir}/alua
 
 %files doc
 %defattr(-,root,root,-)

++++++ Switch-target-driver-DB-root-dir-to-etc-target.patch ++++++
>From f823033e5c6beced0590a00064e1e7a55e76a995 Mon Sep 17 00:00:00 2001
From: Lee Duncan <[email protected]>
Date: Tue, 13 Jun 2017 09:45:30 -0700
Subject: [PATCH] Switch target driver DB root dir to /etc/target

This switches the kernel target driver directory from
the default of /var/target to /etc/target, if the
"dbroot" sysfs attribute is present. If not, the default
of /var/target is maintained. This has to be done
by rtslib/root.py since this module loads the
target_core_mod module, where the dbroot value
must be updated before any target_core_* drivers
register with target_core_mod.
---
 rtslib/root.py | 24 ++++++++++++++++++++++++
 rtslib/tcm.py  |  3 ++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/rtslib/root.py b/rtslib/root.py
index 99a25b778cd1..ee7b1039bd06 100644
--- a/rtslib/root.py
+++ b/rtslib/root.py
@@ -28,6 +28,7 @@ from .fabric import FabricModule
 from .tcm import so_mapping, bs_cache, StorageObject
 from .utils import RTSLibError, RTSLibALUANotSupported, modprobe, 
mount_configfs
 from .utils import dict_remove, set_attributes
+from .utils import fread, fwrite
 from .alua import ALUATargetPortGroup
 
 default_save_file = "/etc/target/saveconfig.json"
@@ -57,6 +58,12 @@ class RTSRoot(CFSNode):
     '''
 
     # RTSRoot private stuff
+
+    # this should match the kernel target driver default db dir
+    _default_dbroot = "/var/target"
+    # this is where the target DB is to be located (instead of the default)
+    _preferred_dbroot = "/etc/target"
+
     def __init__(self):
         '''
         Instantiate an RTSRoot object. Basically checks for configfs setup and
@@ -75,6 +82,8 @@ class RTSRoot(CFSNode):
             modprobe('target_core_mod')
             self._create_in_cfs_ine('any')
 
+        self._set_dbroot_if_needed()
+
     def _list_targets(self):
         self._check_self()
         for fabric_module in self.fabric_modules:
@@ -148,6 +157,19 @@ class RTSRoot(CFSNode):
     def __str__(self):
         return "rtslib"
 
+    def _set_dbroot_if_needed(self):
+        dbroot_path = self.path + "/dbroot"
+        if not os.path.exists(dbroot_path):
+            self._dbroot = self._default_dbroot
+            return
+        self._dbroot = fread(dbroot_path)
+        if self._dbroot != self._preferred_dbroot:
+            fwrite(dbroot_path, self._preferred_dbroot+"\n")
+            self._dbroot = fread(dbroot_path)
+
+    def _get_dbroot(self):
+        return self._dbroot
+
     # RTSRoot public stuff
 
     def dump(self):
@@ -320,6 +342,8 @@ class RTSRoot(CFSNode):
             doc="Get the list of all FabricModule objects.")
     alua_tpgs = property(_list_alua_tpgs,
             doc="Get the list of all ALUA TPG objects.")
+    dbroot = property(_get_dbroot,
+            doc="Get the target database root")
 
 def _test():
     '''Run the doctests.'''
diff --git a/rtslib/tcm.py b/rtslib/tcm.py
index 82ef34e0634e..73bfbe3b8359 100644
--- a/rtslib/tcm.py
+++ b/rtslib/tcm.py
@@ -78,7 +78,8 @@ class StorageObject(CFSNode):
         need to read it in and squirt it back into configfs when we configure
         the storage object. BLEH.
         """
-        aptpl_dir = "/var/target/pr"
+        from .root import RTSRoot
+        aptpl_dir = "%s/pr" % RTSRoot().dbroot
 
         try:
             lines = fread("%s/aptpl_%s" % (aptpl_dir, self.wwn)).split()
-- 
2.12.3


Reply via email to