Merge "Using base32 encoding to generate DNS records"

This commit is contained in:
Jenkins 2014-01-17 10:55:44 +00:00 committed by Gerrit Code Review
commit e2ba287b71
2 changed files with 3 additions and 3 deletions

View File

@ -140,7 +140,7 @@ class DesignateInstanceEntryFactory(driver.DnsInstanceEntryFactory):
def create_entry(self, instance):
zone = DesignateDnsZone(id=DNS_DOMAIN_ID, name=DNS_DOMAIN_NAME)
# Constructing the hostname by hashing the instance ID.
name = base64.urlsafe_b64encode(hashlib.md5(instance).digest())[:11]
name = base64.b32encode(hashlib.md5(instance).digest())[:11]
hostname = ("%s.%s" % (name, zone.name))
#Removing the leading dot if present
if hostname.endswith('.'):

View File

@ -188,7 +188,7 @@ class DesignateInstanceEntryFactoryTest(testtools.TestCase):
driver.DNS_DOMAIN_ID = '00000000-0000-0000-0000-000000000000'
driver.DNS_DOMAIN_NAME = 'trove.com'
driver.DNS_TTL = 3600
hashed_id = base64.urlsafe_b64encode(hashlib.md5(instance_id).digest())
hashed_id = base64.b32encode(hashlib.md5(instance_id).digest())
hashed_id_concat = hashed_id[:11]
exp_hostname = ("%s.%s" % (hashed_id_concat, driver.DNS_DOMAIN_NAME))
factory = driver.DesignateInstanceEntryFactory()
@ -205,7 +205,7 @@ class DesignateInstanceEntryFactoryTest(testtools.TestCase):
driver.DNS_DOMAIN_ID = '00000000-0000-0000-0000-000000000000'
driver.DNS_DOMAIN_NAME = 'trove.com.'
driver.DNS_TTL = 3600
hashed_id = base64.urlsafe_b64encode(hashlib.md5(instance_id).digest())
hashed_id = base64.b32encode(hashlib.md5(instance_id).digest())
hashed_id_concat = hashed_id[:11]
exp_hostname = ("%s.%s" %
(hashed_id_concat, driver.DNS_DOMAIN_NAME))[:-1]