Fix exception in df-db under Python3

Exception is thrown when running df-db dump with Python3

Change-Id: I8b5b7715a429150f1e12277e066d24c8ea0039a3
Closes-Bug: #1808295
This commit is contained in:
Shachar Snapiri 2018-12-13 10:18:23 +02:00 committed by Omer Anson
parent f016d8433f
commit 7c4a297080
1 changed files with 10 additions and 3 deletions

View File

@ -15,6 +15,7 @@ from socket import timeout as SocketTimeout
import etcd3gw as etcd
from oslo_log import log
import six
import urllib3
from urllib3 import connection
from urllib3 import exceptions
@ -114,7 +115,10 @@ class EtcdDbDriver(db_api.DbApi):
return key
def get_key(self, table, key, topic=None):
return self._get_key(self._make_key(table, key), key)
key = self._get_key(self._make_key(table, key), key)
if not six.PY2:
key = key.decode("utf-8")
return key
def _get_key(self, table_key, key):
value = self.client.get(table_key)
@ -147,8 +151,11 @@ class EtcdDbDriver(db_api.DbApi):
directory = self.client.get_prefix(self._make_key(table))
table_name_size = len(table) + 2
for entry in directory:
key = entry[1]["key"]
res.append(key[table_name_size:])
_key = entry[1]["key"]
key = _key[table_name_size:]
if not six.PY2:
key = key.decode("utf-8")
res.append(key)
return res
def _allocate_unique_key(self, table):