diff options
author | Andy Grover <agrover@redhat.com> | 2013-01-03 08:40:26 -0800 |
---|---|---|
committer | Andy Grover <agrover@redhat.com> | 2013-01-03 08:40:26 -0800 |
commit | 53876e897a1f47d980bad9d3c322d33bf39dde26 (patch) | |
tree | 467dff42b6c05af526000929793e70347dd57265 | |
parent | 99a61802dbad5b705ed2110e1c337164767e483a (diff) | |
download | rtslib-fb-53876e897a1f47d980bad9d3c322d33bf39dde26.tar.gz |
Do not throw exception if disabling a disabled TPG
Also, just call enable = False in TPG.delete().
Signed-off-by: Andy Grover <agrover@redhat.com>
-rw-r--r-- | rtslib/target.py | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/rtslib/target.py b/rtslib/target.py index 2638dcf..d3d6584 100644 --- a/rtslib/target.py +++ b/rtslib/target.py @@ -1054,8 +1054,8 @@ class TPG(CFSNode): def _set_enable(self, boolean): ''' - Enables or disables the TPG. Raises an error if trying to disable a TPG - without an enable attribute (but enabling works in that case). + Enables or disables the TPG. If the TPG doesn't support the enable + attribute, do nothing. ''' self._check_self() path = "%s/enable" % self.path @@ -1064,8 +1064,6 @@ class TPG(CFSNode): fwrite(path, str(int(boolean))) except IOError, e: raise RTSLibError("Cannot change enable state: %s" % e) - elif not boolean: - raise RTSLibError("TPG cannot be disabled.") def _get_nexus(self): ''' @@ -1140,9 +1138,7 @@ class TPG(CFSNode): ''' self._check_self() - path = "%s/enable" % self.path - if os.path.isfile(path): - self.enable = False + self.enable = False for acl in self.node_acls: acl.delete() |