Avoid resetting Image.closed until image is successfully opened.
Fixes: #2475
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
self.librbd = CDLL('librbd.so.1')
self.image = c_void_p()
self.name = name
- self.closed = False
if not isinstance(name, str):
raise TypeError('name must be a string')
if snapshot is not None and not isinstance(snapshot, str):
byref(self.image), c_char_p(snapshot))
if ret != 0:
raise make_ex(ret, 'error opening image %s at snapshot %s' % (name, snapshot))
+ self.closed = False
def __enter__(self):
return self