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:
@@ -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."""
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user