summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2017-02-03 10:29:55 -0800
committerAndy Grover <agrover@redhat.com>2017-02-03 10:29:55 -0800
commit650c37904a08147238dc5f189538259f47099e6e (patch)
tree1c0bc97c176469080d796a198cbef5002c7793ca
parent572e9b41bae87023e5e5845786a15409246253aa (diff)
downloadrtslib-fb-alua-fix.tar.gz
Do not raise exceptions if alua_tg_pt_gp is absentalua-fix
In both get and set cases, do not raise exceptions if there are failures because the configfs entry is missing. Signed-off-by: Andy Grover <agrover@redhat.com>
-rw-r--r--rtslib/target.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/rtslib/target.py b/rtslib/target.py
index 816be74..40deccd 100644
--- a/rtslib/target.py
+++ b/rtslib/target.py
@@ -586,22 +586,22 @@ class LUN(CFSNode):
self._check_self()
path = "%s/alua_tg_pt_gp" % self.path
- info = fread(path)
- if info:
+ try:
+ info = fread(path)
group_line = info.splitlines()[0]
return group_line.split(':')[1].strip()
- return None
+ except IOError as e:
+ # Will not always be present
+ return None
def _set_alua_tg_pt_gp_name(self, group_name):
self._check_self()
path = "%s/alua_tg_pt_gp" % self.path
- info = fread(path)
- if not info:
- # pass through backends will not have setup the default
- # ALUA structs in the kernel.
- raise RTSLibError("This LUN does not support setting the ALUA Target Port Group")
+ # This will not exist for pass-through backends
+ if not os.path.exists(path):
+ return
try:
fwrite(path, group_name)