update to latest swift code

More updates will most likely be needed but these updates
allow for some basic of functionality.

Change-Id: I40ce259a0954be490ece06e93dc0a652c4cf3362
Signed-off-by: Thiago da Silva <thiago@redhat.com>
This commit is contained in:
Thiago da Silva 2015-09-04 15:08:01 -04:00
parent 1164a57616
commit 0a11da7bb0
3 changed files with 23 additions and 17 deletions

View File

@ -100,11 +100,12 @@ class RadosFileSystem(object):
def write(self, obj, offset, data): def write(self, obj, offset, data):
try: try:
return self._ioctx.write(obj, data, offset) self._ioctx.write(obj, data, offset)
except self._fs.RADOS.NoSpace: except self._fs.RADOS.NoSpace:
raise DiskFileNoSpace() raise DiskFileNoSpace()
except Exception: except Exception:
raise DiskFileError() raise DiskFileError()
return len(data)
def read(self, obj, off): def read(self, obj, off):
return self._ioctx.read(obj, offset=off) return self._ioctx.read(obj, offset=off)
@ -163,6 +164,9 @@ class DiskFileWriter(object):
metadata['name'] = self._name metadata['name'] = self._name
self._fs.put_object(self._name, metadata) self._fs.put_object(self._name, metadata)
def commit(self, timestamp):
pass
class DiskFileReader(object): class DiskFileReader(object):
""" """

View File

@ -51,7 +51,8 @@ class ObjectController(server.ObjectController):
container, obj, **kwargs) container, obj, **kwargs)
def async_update(self, op, account, container, obj, host, partition, def async_update(self, op, account, container, obj, host, partition,
contdevice, headers_out, objdevice): contdevice, headers_out, objdevice, policy,
logger_thread_locals=None):
""" """
Sends or saves an async update. Sends or saves an async update.
@ -66,7 +67,7 @@ class ObjectController(server.ObjectController):
request request
:param objdevice: device name that the object is in :param objdevice: device name that the object is in
""" """
headers_out['user-agent'] = 'obj-server %s' % os.getpid() headers_out['user-agent'] = 'object-server %s' % os.getpid()
full_path = '/%s/%s/%s' % (account, container, obj) full_path = '/%s/%s/%s' % (account, container, obj)
if all([host, partition, contdevice]): if all([host, partition, contdevice]):
try: try:

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
import mock import mock
from mock import call from mock import call, patch
import cPickle as pickle import cPickle as pickle
import unittest import unittest
from hashlib import md5 from hashlib import md5
@ -397,23 +397,24 @@ class TestRadosDiskFile(unittest.TestCase):
writes = [] writes = []
def ioctx_write(obj, data, offset): def mock_write(self, obj, offset, data):
writes.append((data, offset)) writes.append((data, offset))
return 2 return 2
self.ioctx.write = ioctx_write with patch('swift_ceph_backend.rados_diskfile.'
with self.df.create() as writer: 'RadosFileSystem._radosfs.write', mock_write):
assert(writer.write(fcont) == len(fcont)) with self.df.create() as writer:
assert(writer.write(fcont) == len(fcont))
check_list = [ check_list = [
(fcont, 0), (fcont, 0),
(fcont[2:], 2), (fcont[2:], 2),
(fcont[4:], 4), (fcont[4:], 4),
(fcont[6:], 6), (fcont[6:], 6),
(fcont[8:], 8)] (fcont[8:], 8)]
assert(writes == check_list) assert(writes == check_list)
self._assert_if_rados_not_opened() self._assert_if_rados_not_opened()
self._assert_if_rados_not_closed() self._assert_if_rados_not_closed()
def test_df_writer_put(self): def test_df_writer_put(self):
meta = {'Content-Length': 0, meta = {'Content-Length': 0,