Add a configurable timeout for calls to Cloud DNS API

Pyrax polls for a completed status internally, with a default timeout
of 5 seconds. Sometimes these requests take longer than 5 seconds to
complete, producing a DNSCallTimedOut exception. This makes that
timeout configurable.

Change-Id: I5af9f809c0214f2f1e32622041a46aeeb331e6b5
This commit is contained in:
Paul Glass
2015-04-22 22:19:36 +00:00
parent 2b5e4bb171
commit 3f5bf21c88
3 changed files with 9 additions and 2 deletions

View File

@@ -160,6 +160,11 @@ class DNSConfig(data_interfaces.ConfigSectionInterface):
"""Int value to set timeout for dns polling."""
return int(self.get('retry_timeout'))
@property
def dns_api_timeout(self):
"""The timeout when waiting for Cloud DNS API requests to complete"""
return int(self.get('dns_api_timeout'))
@property
def authoritative_nameserver(self):
"""The authoritative nameserver to query, must be an ip address."""

View File

@@ -25,12 +25,13 @@ class RackspaceDNSClient(object):
"""Client Objects for Rackspace DNS call."""
def __init__(self, user_name, api_key, test_domain):
def __init__(self, user_name, api_key, test_domain, dns_api_timeout=15):
super(RackspaceDNSClient, self).__init__()
pyrax.settings.set('identity_type', 'rackspace')
pyrax.set_credentials(user_name, api_key)
self.dns_client = pyrax.cloud_dns
self.dns_client.set_timeout(dns_api_timeout)
self.test_domain = test_domain
self.domain = self.dns_client.find(name=test_domain)