diff options
-rw-r--r-- | doc/source/index.rst | 12 | ||||
-rw-r--r-- | glance_store/_drivers/filesystem.py | 4 | ||||
-rw-r--r-- | glance_store/_drivers/http.py | 2 | ||||
-rw-r--r-- | glance_store/_drivers/rbd.py | 3 | ||||
-rw-r--r-- | glance_store/_drivers/s3.py | 2 | ||||
-rw-r--r-- | glance_store/_drivers/swift/store.py | 2 | ||||
-rw-r--r-- | glance_store/_drivers/vmware_datastore.py | 7 | ||||
-rw-r--r-- | glance_store/backend.py | 3 | ||||
-rw-r--r-- | glance_store/common/utils.py | 6 | ||||
-rw-r--r-- | glance_store/tests/base.py | 3 | ||||
-rw-r--r-- | test-requirements.txt | 2 | ||||
-rw-r--r-- | tests/unit/test_cinder_store.py | 14 | ||||
-rw-r--r-- | tests/unit/test_swift_store.py | 1 | ||||
-rw-r--r-- | tests/unit/test_utils.py | 13 | ||||
-rw-r--r-- | tox.ini | 2 |
15 files changed, 50 insertions, 26 deletions
diff --git a/doc/source/index.rst b/doc/source/index.rst index b5a2dcc..bf2ffd8 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -2,7 +2,7 @@ glance_store ============ The glance_store library supports the creation, deletion and gather of data -assets from/to a set of several, different, storage technologies +assets from/to a set of several, different, storage technologies. Contents ======== @@ -13,6 +13,16 @@ Contents Release Notes ============= +0.6.0 +----- + +* Dropped py26 support +* Disable propagating BadStoreConfiguration +* _1454695: Sync with global-requirements +* Handle optional dependency in vmware store + +.. _1454695: https://bugs.launchpad.net/glance-store/+bug/1454695 + 0.5.0 ----- diff --git a/glance_store/_drivers/filesystem.py b/glance_store/_drivers/filesystem.py index 24c3421..e9f849a 100644 --- a/glance_store/_drivers/filesystem.py +++ b/glance_store/_drivers/filesystem.py @@ -256,7 +256,7 @@ class Store(glance_store.driver.Store): :raises: BadStoreConfiguration exception if metadata is not valid. """ try: - with open(metadata_file, 'r') as fptr: + with open(metadata_file, 'rb') as fptr: metadata = jsonutils.load(fptr) if isinstance(metadata, dict): @@ -388,7 +388,7 @@ class Store(glance_store.driver.Store): empty directory path is specified. """ priority = 0 - parts = map(lambda x: x.strip(), datadir.rsplit(":", 1)) + parts = [part.strip() for part in datadir.rsplit(":", 1)] datadir_path = parts[0] if len(parts) == 2 and parts[1]: priority = parts[1] diff --git a/glance_store/_drivers/http.py b/glance_store/_drivers/http.py index a2073de..73946f7 100644 --- a/glance_store/_drivers/http.py +++ b/glance_store/_drivers/http.py @@ -138,7 +138,7 @@ class Store(glance_store.driver.Store): class ResponseIndexable(glance_store.Indexable): def another(self): try: - return self.wrapped.next() + return next(self.wrapped) except StopIteration: return '' diff --git a/glance_store/_drivers/rbd.py b/glance_store/_drivers/rbd.py index 7ff86db..d286487 100644 --- a/glance_store/_drivers/rbd.py +++ b/glance_store/_drivers/rbd.py @@ -25,6 +25,7 @@ import urllib from oslo_config import cfg from oslo_utils import units +import six from glance_store import capabilities from glance_store.common import utils @@ -83,7 +84,7 @@ class StoreLocation(location.StoreLocation): def process_specs(self): # convert to ascii since librbd doesn't handle unicode - for key, value in self.specs.iteritems(): + for key, value in six.iteritems(self.specs): self.specs[key] = str(value) self.fsid = self.specs.get('fsid') self.pool = self.specs.get('pool') diff --git a/glance_store/_drivers/s3.py b/glance_store/_drivers/s3.py index e1d5f3d..5212a9e 100644 --- a/glance_store/_drivers/s3.py +++ b/glance_store/_drivers/s3.py @@ -792,7 +792,7 @@ def get_calling_format(bucket_format=None, def get_mpu_xml(pedict): xml = '<CompleteMultipartUpload>\n' - for pnum, etag in pedict.iteritems(): + for pnum, etag in six.iteritems(pedict): xml += ' <Part>\n' xml += ' <PartNumber>%d</PartNumber>\n' % pnum xml += ' <ETag>%s</ETag>\n' % etag diff --git a/glance_store/_drivers/swift/store.py b/glance_store/_drivers/swift/store.py index 86b8d76..c7f97c0 100644 --- a/glance_store/_drivers/swift/store.py +++ b/glance_store/_drivers/swift/store.py @@ -440,7 +440,7 @@ class BaseStore(driver.Store): class ResponseIndexable(glance_store.Indexable): def another(self): try: - return self.wrapped.next() + return next(self.wrapped) except StopIteration: return '' diff --git a/glance_store/_drivers/vmware_datastore.py b/glance_store/_drivers/vmware_datastore.py index 7eff3ff..bbf9037 100644 --- a/glance_store/_drivers/vmware_datastore.py +++ b/glance_store/_drivers/vmware_datastore.py @@ -356,7 +356,7 @@ class Store(glance_store.Store): def _parse_datastore_info_and_weight(self, datastore): weight = 0 - parts = map(lambda x: x.strip(), datastore.rsplit(":", 2)) + parts = [part.strip() for part in datastore.rsplit(":", 2)] if len(parts) < 2: msg = _('vmware_datastores format must be ' 'datacenter_path:datastore_name:weight or ' @@ -490,7 +490,8 @@ class Store(glance_store.Store): 'image_id': image_id}, self.conf) # NOTE(arnaud): use a decorator when the config is not tied to self cookie = self._build_vim_cookie_header(True) - headers = dict(headers.items() + {'Cookie': cookie}.items()) + headers = dict(headers) + headers['Cookie'] = cookie conn_class = self._get_http_conn_class() conn = conn_class(loc.server_host) url = urlparse.quote('%s?%s' % (loc.path, loc.query)) @@ -548,7 +549,7 @@ class Store(glance_store.Store): def another(self): try: - return self.wrapped.next() + return next(self.wrapped) except StopIteration: return '' diff --git a/glance_store/backend.py b/glance_store/backend.py index 916b3d7..df22729 100644 --- a/glance_store/backend.py +++ b/glance_store/backend.py @@ -16,6 +16,7 @@ import logging from oslo_config import cfg +import six from stevedore import driver from stevedore import extension @@ -311,7 +312,7 @@ def check_location_metadata(val, key=''): for v in val: check_location_metadata(v, key='%s[%d]' % (key, ndx)) ndx = ndx + 1 - elif not isinstance(val, unicode): + elif not isinstance(val, six.text_type): raise exceptions.BackendException(_("The image metadata key %(key)s " "has an invalid type of %(type)s. " "Only dict, list, and unicode are " diff --git a/glance_store/common/utils.py b/glance_store/common/utils.py index 48618dc..d9d64af 100644 --- a/glance_store/common/utils.py +++ b/glance_store/common/utils.py @@ -133,7 +133,7 @@ class CooperativeReader(object): if self.iterator is None: self.iterator = self.__iter__() try: - return self.iterator.next() + return next(self.iterator) except StopIteration: return '' @@ -150,4 +150,6 @@ def exception_to_str(exc): except UnicodeError: error = ("Caught '%(exception)s' exception." % {"exception": exc.__class__.__name__}) - return encodeutils.safe_encode(error, errors='ignore') + if six.PY2: + error = encodeutils.safe_encode(error, errors='ignore') + return error diff --git a/glance_store/tests/base.py b/glance_store/tests/base.py index 4df57ad..6deba08 100644 --- a/glance_store/tests/base.py +++ b/glance_store/tests/base.py @@ -20,6 +20,7 @@ import shutil import fixtures from oslo_config import cfg from oslotest import base +import six import glance_store as store from glance_store import location @@ -66,7 +67,7 @@ class StoreBaseTest(base.BaseTestCase): test by the fixtures cleanup process. """ group = kw.pop('group', 'glance_store') - for k, v in kw.iteritems(): + for k, v in six.iteritems(kw): self.conf.set_override(k, v, group) def register_store_schemes(self, store, store_entry): diff --git a/test-requirements.txt b/test-requirements.txt index c4d2b4b..c0e7bf8 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -29,7 +29,7 @@ oslosphinx>=2.5.0 # Apache-2.0 boto>=2.32.1 # For VMware storage backend. -oslo.vmware>=0.11.1 # Apache-2.0 +oslo.vmware>=0.11.1,!=0.13.0 # Apache-2.0 # Swift Backend httplib2>=0.7.5 diff --git a/tests/unit/test_cinder_store.py b/tests/unit/test_cinder_store.py index c526360..c2b5c15 100644 --- a/tests/unit/test_cinder_store.py +++ b/tests/unit/test_cinder_store.py @@ -14,8 +14,8 @@ # under the License. import mock - from oslo_utils import units +import six import glance_store from glance_store._drivers import cinder @@ -27,7 +27,7 @@ from tests.unit import test_store_capabilities class FakeObject(object): def __init__(self, **kwargs): - for name, value in kwargs.iteritems(): + for name, value in six.iteritems(kwargs): setattr(self, name, value) @@ -52,8 +52,9 @@ class TestCinderStore(base.StoreBaseTest, def test_cinder_get_size(self): fake_client = FakeObject(auth_token=None, management_url=None) - fake_volumes = {'12345678-9012-3455-6789-012345678901': - FakeObject(size=5)} + fake_volume_uuid = '12345678-9012-3455-6789-012345678901' + fake_volume = FakeObject(size=5) + fake_volumes = {fake_volume_uuid: fake_volume} with mock.patch.object(cinder, 'get_cinderclient') as mocked_cc: mocked_cc.return_value = FakeObject(client=fake_client, @@ -68,11 +69,10 @@ class TestCinderStore(base.StoreBaseTest, auth_tok='fake_token', tenant='fake_tenant') - uri = 'cinder://%s' % fake_volumes.keys()[0] + uri = 'cinder://%s' % fake_volume_uuid loc = location.get_location_from_uri(uri, conf=self.conf) image_size = self.store.get_size(loc, context=fake_context) - self.assertEqual(image_size, - fake_volumes.values()[0].size * units.Gi) + self.assertEqual(image_size, fake_volume.size * units.Gi) def test_cinder_delete_raise_error(self): uri = 'cinder://12345678-9012-3455-6789-012345678901' diff --git a/tests/unit/test_swift_store.py b/tests/unit/test_swift_store.py index 3b68e16..40f3253 100644 --- a/tests/unit/test_swift_store.py +++ b/tests/unit/test_swift_store.py @@ -1447,6 +1447,7 @@ class TestChunkReader(base.StoreBaseTest): break self.assertEqual(units.Ki, bytes_read) data_file.close() + infile.close() class TestMultipleContainers(base.StoreBaseTest): diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 6bfb089..e3a4042 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -14,6 +14,7 @@ # under the License. from oslotest import base +import six from glance_store.common import utils @@ -29,9 +30,15 @@ class TestUtils(base.BaseTestCase): ret = utils.exception_to_str(Exception('error message')) self.assertEqual(ret, 'error message') - ret = utils.exception_to_str(Exception('\xa5 error message')) - self.assertEqual(ret, ' error message') - ret = utils.exception_to_str(FakeException('\xa5 error message')) self.assertEqual(ret, "Caught '%(exception)s' exception." % {'exception': 'FakeException'}) + + def test_exception_to_str_ignore(self): + if six.PY3: + # On Python 3, exception messages are unicode strings, they are not + # decoded from an encoding and so it's not possible to test the + # "ignore" error handler + self.skipTest("test specific to Python 2") + ret = utils.exception_to_str(Exception('\xa5 error message')) + self.assertEqual(ret, ' error message') @@ -1,6 +1,6 @@ [tox] minversion = 1.6 -envlist = py26,py27,py33,py34,pep8 +envlist = py27,py33,py34,pep8 skipsdist = True [testenv] |