Blame SOURCES/0009-restoreconfig-fix-alua-tpg-config-setup.patch

4959d3
From 515e1b10bbdbeeca4a4f24aa2157beb1bcea3304 Mon Sep 17 00:00:00 2001
4959d3
From: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
4959d3
Date: Wed, 4 Apr 2018 16:30:42 +0530
4959d3
Subject: [PATCH] restoreconfig: fix alua tpg config setup
4959d3
4959d3
Problem:
4959d3
---
4959d3
$ cat myconfig.json
4959d3
{
4959d3
  "storage_objects": [
4959d3
    {
4959d3
      "alua_tpgs": [
4959d3
        {
4959d3
          "alua_access_type": 0,
4959d3
          "name": "glfs_tg_pt_gp",
4959d3
          "tg_pt_gp_id": 1
4959d3
        }
4959d3
      ],
4959d3
      "config": "glfs/test@192.168.124.227/block-store/2e189467-00ae-4388-bbd2-a8b4df154671",
4959d3
      "name": "blockX",
4959d3
      "plugin": "user",
4959d3
      "size": 1073741824
4959d3
    }
4959d3
  ],
4959d3
  "targets": []
4959d3
}
4959d3
4959d3
$ targetcli restoreconfig myconfig.json
4959d3
All configuration cleared
4959d3
'alua_access_state'
4959d3
4959d3
And attributes won't be effected as per myconfig.json:
4959d3
$ targetcli/backstores/user:glfs/blockX/alua/glfs_tg_pt_gp get alua alua_access_type
4959d3
alua_access_type=3
4959d3
4959d3
Fix:
4959d3
---
4959d3
This patch fix the problem by calling setattr for available attribs in the
4959d3
configfile and rest all will be as per kernel defaults.
4959d3
4959d3
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
4959d3
---
4959d3
 rtslib/alua.py | 10 ++++++++--
4959d3
 1 file changed, 8 insertions(+), 2 deletions(-)
4959d3
4959d3
diff --git a/rtslib/alua.py b/rtslib/alua.py
4959d3
index 8a4b30d..9a7af0d 100644
4959d3
--- a/rtslib/alua.py
4959d3
+++ b/rtslib/alua.py
4959d3
@@ -19,6 +19,7 @@ a copy of the License at
4959d3
 
4959d3
 from .node import CFSNode
4959d3
 from .utils import RTSLibError, RTSLibALUANotSupported, fread, fwrite
4959d3
+import six
4959d3
 
4959d3
 alua_rw_params = ['alua_access_state', 'alua_access_status',
4959d3
                   'alua_write_metadata', 'alua_access_type', 'preferred',
4959d3
@@ -393,5 +394,10 @@ class ALUATargetPortGroup(CFSNode):
4959d3
             return
4959d3
 
4959d3
         alua_tpg_obj = cls(storage_obj, name, alua_tpg['tg_pt_gp_id'])
4959d3
-        for param in alua_rw_params:
4959d3
-            setattr(alua_tpg_obj, param, alua_tpg[param])
4959d3
+        for param, value in six.iteritems(alua_tpg):
4959d3
+            if param != 'name' and param != 'tg_pt_gp_id':
4959d3
+                try:
4959d3
+                    setattr(alua_tpg_obj, param, value)
4959d3
+                except:
4959d3
+                    raise RTSLibError("Could not set attribute '%s' for alua tpg '%s'"
4959d3
+                                      % (param, alua_tpg['name']))
4959d3
-- 
4959d3
1.8.3.1
4959d3