From: Jason Dillaman Date: Wed, 4 Feb 2015 14:46:17 +0000 (-0500) Subject: pybind: fixed runtime errors with librbdpy X-Git-Tag: v0.93~82^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=46f9ca463ef6229b56086adc2741d2df10a1d23f;p=ceph.git pybind: fixed runtime errors with librbdpy There was a typo within the RBD Image get_flags method and several runtime errors relating to the new fadvise flags. Fixes: #10782 Signed-off-by: Jason Dillaman --- diff --git a/src/pybind/rados.py b/src/pybind/rados.py index 88bbde51fc08..41b0c4548e60 100644 --- a/src/pybind/rados.py +++ b/src/pybind/rados.py @@ -17,6 +17,12 @@ ANONYMOUS_AUID = 0xffffffffffffffff ADMIN_AUID = 0 LIBRADOS_ALL_NSPACES = '\001' +LIBRADOS_OP_FLAG_FADVISE_RANDOM = 0x4 +LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL = 0x8 +LIBRADOS_OP_FLAG_FADVISE_WILLNEED = 0x10 +LIBRADOS_OP_FLAG_FADVISE_DONTNEED = 0x20 +LIBRADOS_OP_FLAG_FADVISE_NOCACHE = 0x40 + class Error(Exception): """ `Error` class, derived from `Exception` """ pass diff --git a/src/pybind/rbd.py b/src/pybind/rbd.py index 0a9fb04e772c..334e4c750103 100644 --- a/src/pybind/rbd.py +++ b/src/pybind/rbd.py @@ -534,7 +534,7 @@ class Image(object): :returns: int - the flags bitmask of the image """ flags = c_uint64() - reg = self.librbd.rbd_get_flags(self.image, byref(flags)) + ret = self.librbd.rbd_get_flags(self.image, byref(flags)) if (ret != 0): raise make_ex(ret, 'error getting flags for image' % (self.name)) return flags.value diff --git a/src/test/pybind/test_rbd.py b/src/test/pybind/test_rbd.py index a66b94532428..853b8b2723ec 100644 --- a/src/test/pybind/test_rbd.py +++ b/src/test/pybind/test_rbd.py @@ -8,7 +8,10 @@ import os from contextlib import nested from nose import with_setup, SkipTest from nose.tools import eq_ as eq, assert_raises -from rados import Rados +from rados import (Rados, + LIBRADOS_OP_FLAG_FADVISE_DONTNEED, + LIBRADOS_OP_FLAG_FADVISE_NOCACHE, + LIBRADOS_OP_FLAG_FADVISE_RANDOM) from rbd import (RBD, Image, ImageNotFound, InvalidArgument, ImageExists, ImageBusy, ImageHasSnapshots, ReadOnlyImage, FunctionNotSupported, ArgumentOutOfRange, @@ -300,7 +303,7 @@ class TestImage(object): data = rand_data(256) self.image.write(data, 0) - def test_write_with_fadivse_flags(self): + def test_write_with_fadvise_flags(self): data = rand_data(256) self.image.write(data, 0, LIBRADOS_OP_FLAG_FADVISE_DONTNEED) self.image.write(data, 0, LIBRADOS_OP_FLAG_FADVISE_NOCACHE) @@ -309,10 +312,10 @@ class TestImage(object): data = self.image.read(0, 20) eq(data, '\0' * 20) - def test_read_with_fadivse_flags(self): - data = self.image.read(0, 20, LIBRADOS_OP_FLAG_FADIVSE_DONTNEED) + def test_read_with_fadvise_flags(self): + data = self.image.read(0, 20, LIBRADOS_OP_FLAG_FADVISE_DONTNEED) eq(data, '\0' * 20) - data = self.image.read(0, 20, LIBRADOS_OP_FLAG_FADIVSE_RANDOM) + data = self.image.read(0, 20, LIBRADOS_OP_FLAG_FADVISE_RANDOM) eq(data, '\0' * 20) def test_large_write(self):