summaryrefslogtreecommitdiff
path: root/trove/dns
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2016-05-02 21:17:17 +0200
committerVictor Stinner <vstinner@redhat.com>2016-05-02 22:31:05 +0200
commitbdf664bbdf29e32a0e88cc971826029f418d5fff (patch)
tree17c46de4ca38c0e52337c14c31be4442e32ce839 /trove/dns
parent79f350852e1cb57fdfc493d68cd87d480b36257c (diff)
downloadtrove-bdf664bbdf29e32a0e88cc971826029f418d5fff.tar.gz
Port designate code to Python 3
* Replace map() with list-comprehension to get a list on Python 3. * Unicode dance: encode text to UTF-8 for MD5, decode Base32 from ASCII to get text. * tox.ini: test_designate_driver and test_datastore_versions to Python 3.4 Partially implements: blueprint trove-python3 Change-Id: I1aa5387908b3f108487ed731cee5f7d9bbfd7d69
Diffstat (limited to 'trove/dns')
-rw-r--r--trove/dns/designate/driver.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/trove/dns/designate/driver.py b/trove/dns/designate/driver.py
index 72652eb2..b8de297c 100644
--- a/trove/dns/designate/driver.py
+++ b/trove/dns/designate/driver.py
@@ -23,6 +23,8 @@ import hashlib
from designateclient.v1 import Client
from designateclient.v1.records import Record
from oslo_log import log as logging
+from oslo_utils import encodeutils
+import six
from trove.common import cfg
from trove.common import exception
@@ -142,7 +144,11 @@ class DesignateInstanceEntryFactory(driver.DnsInstanceEntryFactory):
def create_entry(self, instance_id):
zone = DesignateDnsZone(id=DNS_DOMAIN_ID, name=DNS_DOMAIN_NAME)
# Constructing the hostname by hashing the instance ID.
- name = base64.b32encode(hashlib.md5(instance_id).digest())[:11].lower()
+ name = encodeutils.to_utf8(instance_id)
+ name = hashlib.md5(name).digest()
+ name = base64.b32encode(name)[:11].lower()
+ if six.PY3:
+ name = name.decode('ascii')
hostname = ("%s.%s" % (name, zone.name))
# Removing the leading dot if present
if hostname.endswith('.'):