diff options
author | Victor Sergeyev <vsergeyev@mirantis.com> | 2014-12-30 13:50:27 +0200 |
---|---|---|
committer | Victor Sergeyev <vsergeyev@mirantis.com> | 2015-05-06 11:51:44 +0300 |
commit | 70062322a240353989babeddfb904b487a42d668 (patch) | |
tree | b914ca4a6c2a9df5f79f14a7abdc5c716dc128c5 /ironic/common/hash_ring.py | |
parent | 1961523996f1f0a88f2e3871c902dd7426ba25f5 (diff) | |
download | ironic-70062322a240353989babeddfb904b487a42d668.tar.gz |
Run tests in py34 environment
A lot of fixes to be compatible with python 3:
- fix encoding/decoding errors
- fix issues with comparison
- use `reload`, `reraise`, ext. modules from six
- use items() instead of iteritems()
- add a new file with py3 specific test requirements
- drop passing the arbitrary arguments to object.__new__ method.
See bug [1] for more details.
- add a workaround to bug in `mock` library
- add py33 and py34 test environment to tox.ini
[1] http://bugs.python.org/issue1683368
Change-Id: I90936cb6b6eaaf4b5e1ce67732caec3c8bdc1cc2
Diffstat (limited to 'ironic/common/hash_ring.py')
-rw-r--r-- | ironic/common/hash_ring.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/ironic/common/hash_ring.py b/ironic/common/hash_ring.py index ed774626b..b95bba103 100644 --- a/ironic/common/hash_ring.py +++ b/ironic/common/hash_ring.py @@ -18,6 +18,7 @@ import hashlib import threading from oslo_config import cfg +import six from ironic.common import exception from ironic.common.i18n import _ @@ -105,6 +106,8 @@ class HashRing(object): def _get_partition(self, data): try: + if six.PY3 and data is not None: + data = data.encode('utf-8') key_hash = hashlib.md5(data) hashed_key = self._hash2int(key_hash) position = bisect.bisect(self._partitions, hashed_key) @@ -180,7 +183,7 @@ class HashRingManager(object): rings = {} d2c = self.dbapi.get_active_driver_dict() - for driver_name, hosts in d2c.iteritems(): + for driver_name, hosts in d2c.items(): rings[driver_name] = HashRing(hosts) return rings |