diff options
author | Andy Grover <agrover@redhat.com> | 2012-06-11 10:40:55 -0700 |
---|---|---|
committer | Andy Grover <agrover@redhat.com> | 2012-06-11 10:40:55 -0700 |
commit | 3231e718aa6a41443b747d90d8bf710a244c44ab (patch) | |
tree | 2f3b336e39cac59ea854181fa4df5967d37290b9 | |
parent | a1b91a2fe39b74b3c5e016f20c4fabdb2d4897c8 (diff) | |
download | rtslib-fb-3231e718aa6a41443b747d90d8bf710a244c44ab.tar.gz |
Raise RTSLibError if trying to create invalid entry in configfs
rtslib is designed to only throw RTSLib-defined exceptions. Since
the mkdir can fail, wrap it in a try block and convert any errors to
rtsliberrors.
This should fix https://bugzilla.redhat.com/show_bug.cgi?id=830672
Signed-off-by: Andy Grover <agrover@redhat.com>
-rw-r--r-- | rtslib/node.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/rtslib/node.py b/rtslib/node.py index a7878ec..f2df507 100644 --- a/rtslib/node.py +++ b/rtslib/node.py @@ -61,11 +61,16 @@ class CFSNode(object): elif not self.exists and mode == 'lookup': raise RTSLibNotInCFS("No such %s in configfs: %s." % (self.__class__.__name__, self.path)) - if not self.exists: + if self.exists: + self._fresh = False + return + + try: os.mkdir(self.path) self._fresh = True - else: - self._fresh = False + except: + raise RTSLibError("Could not create %s in configFS." + % self.__class__.__name__) def _exists(self): return os.path.isdir(self.path) |