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