diff options
author | Tim Simpson <tim.simpson@rackspace.com> | 2014-01-27 15:54:18 -0600 |
---|---|---|
committer | Tim Simpson <tim.simpson@rackspace.com> | 2014-01-31 17:50:34 -0600 |
commit | 3cdb9ea8171f712cb48c98afbbf871e0ee659a44 (patch) | |
tree | d546f74d96990d6577c13433250d14e1f812cc83 /trove/dns | |
parent | c14553393f83f4f11f7044a32e77289b952b86f5 (diff) | |
download | trove-3cdb9ea8171f712cb48c98afbbf871e0ee659a44.tar.gz |
Changing DNS to pass string to driver
This commit also moves the "get_ip_address" functions out of
instance.views and into the models code under the SimpleInstance class,
where it's renamed get_visible_ip_addresses().
Also, the content field (the ip address) is now passed to the driver
instead of set on the Entry object by the manager, which allows more
flexibility for dealing with various drivers and will hopefully prevent
issues in the future.
Finally, integration tests were added to keep this from breaking
in the future.
Closes-Bug: 1273446
Change-Id: I70bf37838cc5cecfe579fe6001df79d7f6f5d53e
Diffstat (limited to 'trove/dns')
-rw-r--r-- | trove/dns/designate/driver.py | 8 | ||||
-rw-r--r-- | trove/dns/manager.py | 3 | ||||
-rw-r--r-- | trove/dns/rsdns/driver.py | 4 |
3 files changed, 7 insertions, 8 deletions
diff --git a/trove/dns/designate/driver.py b/trove/dns/designate/driver.py index fc0d3d5b..3b93f816 100644 --- a/trove/dns/designate/driver.py +++ b/trove/dns/designate/driver.py @@ -75,7 +75,7 @@ class DesignateDriver(driver.DnsDriver): self.default_dns_zone = DesignateDnsZone(id=DNS_DOMAIN_ID, name=DNS_DOMAIN_NAME) - def create_entry(self, entry): + def create_entry(self, entry, content): """Creates the entry in the driver at the given dns zone.""" dns_zone = entry.dns_zone or self.default_dns_zone if not dns_zone.id: @@ -86,7 +86,7 @@ class DesignateDriver(driver.DnsDriver): # Record name has to end with a '.' by dns standard record = Record(name=entry.name + '.', type=entry.type, - data=entry.content, + data=content, ttl=entry.ttl, priority=entry.priority) client.records.create(dns_zone.id, record) @@ -137,10 +137,10 @@ class DesignateDriver(driver.DnsDriver): class DesignateInstanceEntryFactory(driver.DnsInstanceEntryFactory): """Defines how instance DNS entries are created for instances.""" - def create_entry(self, instance): + 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).digest())[:11] + name = base64.b32encode(hashlib.md5(instance_id).digest())[:11] hostname = ("%s.%s" % (name, zone.name)) #Removing the leading dot if present if hostname.endswith('.'): diff --git a/trove/dns/manager.py b/trove/dns/manager.py index 75aa1fa4..64a6d9f1 100644 --- a/trove/dns/manager.py +++ b/trove/dns/manager.py @@ -52,9 +52,8 @@ class DnsManager(object): """ entry = self.entry_factory.create_entry(instance_id) if entry: - entry.content = content LOG.debug("Creating entry address %s." % str(entry)) - self.driver.create_entry(entry) + self.driver.create_entry(entry, content) else: LOG.debug("Entry address not found for instance %s" % instance_id) diff --git a/trove/dns/rsdns/driver.py b/trove/dns/rsdns/driver.py index 7a9bc904..e05f43bb 100644 --- a/trove/dns/rsdns/driver.py +++ b/trove/dns/rsdns/driver.py @@ -117,7 +117,7 @@ class RsDnsDriver(object): msg = "TTL value '--dns_ttl=%s' should be greater than 300" raise Exception(msg % DNS_TTL) - def create_entry(self, entry): + def create_entry(self, entry, content): dns_zone = entry.dns_zone or self.default_dns_zone if dns_zone.id is None: raise TypeError("The entry's dns_zone must have an ID specified.") @@ -127,7 +127,7 @@ class RsDnsDriver(object): future = self.dns_client.records.create( domain=dns_zone.id, record_name=name, - record_data=entry.content, + record_data=content, record_type=entry.type, record_ttl=entry.ttl) try: |