]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd.py: fix list when there are no images
authorJosh Durgin <josh.durgin@dreamhost.com>
Mon, 7 Nov 2011 17:08:00 +0000 (09:08 -0800)
committerJosh Durgin <josh.durgin@dreamhost.com>
Mon, 7 Nov 2011 17:10:08 +0000 (09:10 -0800)
It should return [], not [''].

Reported-by: Eric Chen <Eric_YH_Chen@wistron.com>
Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
src/pybind/rbd.py
src/test/pybind/test_rbd.py

index a2f852a05bcd7a78c6f313845cfbe3ef376795a5..4b18605820eda1f30eee17621f8a6cf834a6b1c3 100644 (file)
@@ -149,7 +149,7 @@ class RBD(object):
                 break
             elif ret != -errno.ERANGE:
                 raise make_ex(ret, 'error listing images')
-        return c_names.raw.rstrip('\0').split('\0')
+        return filter(lambda name: name != '', c_names.raw.split('\0'))
 
     def remove(self, ioctx, name):
         """
index b99274d0cc1c52364216b0538dbb12ed63b4e4d7..e6ee9c526e92deca44e69b3c18cc81dc70d3db3c 100644 (file)
@@ -54,6 +54,9 @@ def test_context_manager():
 def test_remove_dne():
     assert_raises(ImageNotFound, remove_image)
 
+def test_list_empty():
+    eq([], RBD().list(ioctx))
+
 @with_setup(create_image, remove_image)
 def test_list():
     eq([IMG_NAME], RBD().list(ioctx))