Package: python-ceph
Architecture: linux-any
Section: python
-Depends: ${python:Depends}, librados2, librbd1, librgw1
+Depends: ${python:Depends}, librados2, librbd1
Description: Python libraries for the Ceph distributed filesystem
Ceph is a distributed storage and network file system designed to provide
excellent performance, reliability, and scalability.
+++ /dev/null
-"""librgw Python ctypes wrapper
-Copyright 2011, New Dream Network
-"""
-from ctypes import CDLL, c_char_p, c_void_p,\
- byref, c_int
-import ctypes
-
-class Rgw(object):
- """librgw python wrapper"""
- def __init__(self):
- self.lib = CDLL('librgw.so.1')
- self.rgw = c_void_p(0)
- ret = self.lib.librgw_create(byref(self.rgw), 0)
- if (ret != 0):
- raise Exception("librgw_create failed with error %d" % ret)
- def __del__(self):
- self.lib.librgw_shutdown(self.rgw)
- def acl_bin2xml(self, blob):
- blob_buf = ctypes.create_string_buffer(blob[:])
- xml = c_char_p(0)
- ret = self.lib.librgw_acl_bin2xml(self.rgw, byref(blob_buf), len(blob), byref(xml))
- if (ret != 0):
- raise Exception("acl_bin2xml failed with error %d" % ret)
- rets = ctypes.string_at(xml)
- self.lib.librgw_free_xml(self.rgw, xml)
- return rets
- def acl_xml2bin(self, xml):
- blen = c_int(0)
- blob = c_void_p(0)
- ret = self.lib.librgw_acl_xml2bin(self.rgw, c_char_p(xml),
- byref(blob), byref(blen))
- if (ret != 0):
- raise Exception("acl_bin2xml failed with error %d" % ret)
- rets = ctypes.string_at(blob, blen)
- self.lib.librgw_free_bin(self.rgw, blob)
- return rets
+++ /dev/null
-from nose.tools import eq_ as eq, assert_raises
-from rgw import Rgw
-
-def test_rgw():
- rgw = Rgw()
- xml = """<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
- <Owner>
- <ID>foo</ID>
- <DisplayName>MrFoo</DisplayName>
- </Owner>
- <AccessControlList>
- <Grant>
- <Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"CanonicalUser\">
- <ID>bar</ID>
- <DisplayName>display-name</DisplayName>
- </Grantee>
- <Permission>FULL_CONTROL</Permission>
- </Grant>
- </AccessControlList>
-</AccessControlPolicy>"""
- blob = rgw.acl_xml2bin(xml)
- converted_xml = rgw.acl_bin2xml(blob)
- converted_blob = rgw.acl_xml2bin(converted_xml)
- eq(blob, converted_blob)