From b10c921a2d3bf2b84531ee7303a494919de67ae5 Mon Sep 17 00:00:00 2001
From: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Date: Fri, 1 Jun 2018 14:05:14 +0530
Subject: [PATCH] saveconfig: handle no attr exception in _parse_info()
$ targetcli / saveconfig
'NoneType' object has no attribute 'group'
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
---
rtslib/tcm.py | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/rtslib/tcm.py b/rtslib/tcm.py
index 4feb738..4ed96b4 100644
--- a/rtslib/tcm.py
+++ b/rtslib/tcm.py
@@ -184,8 +184,11 @@ class StorageObject(CFSNode):
def _parse_info(self, key):
self._check_self()
info = fread("%s/info" % self.path)
- return re.search(".*%s: ([^: ]+).*" \
- % key, ' '.join(info.split())).group(1)
+ try:
+ return re.search(".*%s: ([^: ]+).*" \
+ % key, ' '.join(info.split())).group(1)
+ except AttributeError:
+ return None
def _get_status(self):
self._check_self()
@@ -994,8 +997,11 @@ class _Backstore(CFSNode):
def _parse_info(self, key):
self._check_self()
info = fread("%s/hba_info" % self.path)
- return re.search(".*%s: ([^: ]+).*" \
- % key, ' '.join(info.split())).group(1)
+ try:
+ return re.search(".*%s: ([^: ]+).*" \
+ % key, ' '.join(info.split())).group(1)
+ except AttributeError:
+ return None
def _get_version(self):
self._check_self()
--
1.8.3.1