Blame SOURCES/0011-saveconfig-dump-control-string-containing-control-va.patch

dbfba8
From eff378068812503ee2394baffba37b5cadd9a0f7 Mon Sep 17 00:00:00 2001
dbfba8
From: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
dbfba8
Date: Fri, 6 Apr 2018 13:03:28 +0530
dbfba8
Subject: [PATCH] saveconfig: dump control string containing control=value
dbfba8
 tuples
dbfba8
dbfba8
Problem:
dbfba8
-------
dbfba8
$ targetcli /backstores/user:glfs create blockX1 1073741824 \
dbfba8
  test@192.168.124.227/block-store/e59309bb-d591-4121-a891-e98ff3416446,max_data_area_mb=32
dbfba8
dbfba8
$ targetcli / saveconfig
dbfba8
dbfba8
$ cat /etc/target/saveconfig.json
dbfba8
{
dbfba8
  "storage_objects": [
dbfba8
    {
dbfba8
      "alua_tpgs": [],
dbfba8
      "attributes": {
dbfba8
        ...
dbfba8
      },
dbfba8
      "config": "glfs/test@192.168.124.227/block-store/e59309bb-d591-4121-a891-e98ff3416446",
dbfba8
      "hw_max_sectors": 128,
dbfba8
      "name": "blockX1",
dbfba8
      "plugin": "user",
dbfba8
      "size": 1073741824,
dbfba8
      "wwn": "3aa072d6-a007-45a3-8eac-e85b53655515"
dbfba8
    }
dbfba8
  ],
dbfba8
  "targets": []
dbfba8
}
dbfba8
dbfba8
Note max_data_area_mb is not dumped into the configfile and hence on restart of
dbfba8
target service or node reboot this storageObject property is lost.
dbfba8
dbfba8
Fix:
dbfba8
----
dbfba8
This patch make sure to dump control string containing control=value tuples, like:
dbfba8
$ cat /etc/target/saveconfig.json
dbfba8
{
dbfba8
  ...
dbfba8
  "config": "glfs/test@192.168.124.227/block-store/e59309bb-d591-4121-a891-e98ff3416446",
dbfba8
  "control": "max_data_area_mb=32",
dbfba8
  ...
dbfba8
}
dbfba8
dbfba8
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
dbfba8
---
dbfba8
 rtslib/tcm.py | 14 ++++++++++++++
dbfba8
 1 file changed, 14 insertions(+)
dbfba8
dbfba8
diff --git a/rtslib/tcm.py b/rtslib/tcm.py
dbfba8
index efe685a..4feb738 100644
dbfba8
--- a/rtslib/tcm.py
dbfba8
+++ b/rtslib/tcm.py
dbfba8
@@ -845,6 +845,17 @@ class UserBackedStorageObject(StorageObject):
dbfba8
         self._check_self()
dbfba8
         return int(self._parse_info('HwMaxSectors'))
dbfba8
 
dbfba8
+    def _get_control_tuples(self):
dbfba8
+        self._check_self()
dbfba8
+        tuples = []
dbfba8
+        # 1. max_data_area_mb
dbfba8
+        val = self._parse_info('MaxDataAreaMB')
dbfba8
+        if val != "NULL":
dbfba8
+            tuples.append("max_data_area_mb=%s" % val)
dbfba8
+        # 2. add next ...
dbfba8
+
dbfba8
+        return ",".join(tuples)
dbfba8
+
dbfba8
     def _get_config(self):
dbfba8
         self._check_self()
dbfba8
         val = self._parse_info('Config')
dbfba8
@@ -858,6 +869,8 @@ class UserBackedStorageObject(StorageObject):
dbfba8
 
dbfba8
     hw_max_sectors = property(_get_hw_max_sectors,
dbfba8
             doc="Get the max sectors per command.")
dbfba8
+    control_tuples = property(_get_control_tuples,
dbfba8
+            doc="Get the comma separated string containing control=value tuples.")
dbfba8
     size = property(_get_size,
dbfba8
             doc="Get the size in bytes.")
dbfba8
     config = property(_get_config,
dbfba8
@@ -871,6 +884,7 @@ class UserBackedStorageObject(StorageObject):
dbfba8
         d['size'] = self.size
dbfba8
         d['config'] = self.config
dbfba8
         d['hw_max_sectors'] = self.hw_max_sectors
dbfba8
+        d['control'] = self.control_tuples
dbfba8
 
dbfba8
         return d
dbfba8
 
dbfba8
-- 
dbfba8
1.8.3.1
dbfba8