Skip to content

Commit

Permalink
Merge pull request #2307 from szok/dns-form-errors
Browse files Browse the repository at this point in the history
DNS change get_domain method
  • Loading branch information
szok committed Mar 21, 2016
2 parents 2707e8e + f20d509 commit f943226
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/ralph/dns/dnsaas.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,19 @@ def update_dns_records(self, record):
return True

@cache()
def get_domain(self, record):
def get_domain(self, domain_name):
"""
Return domain URL base on record name.
Args:
record: Cleaned data from formset
domain_name: Domain name
Return:
Domain URL from API or False if not exists
"""
domain_name = record['name'].split('.', 1)
url = urljoin(
settings.DNSAAS_URL, 'api/domains/?'.format(
urlencode([('name', domain_name[-1])])
urlencode([('name', domain_name)])
)
)
result = self.get_api_result(url)
Expand All @@ -133,7 +132,8 @@ def create_dns_records(self, record):
"""

url = urljoin(settings.DNSAAS_URL, 'api/records/')
domain = self.get_domain(record)
domain_name = record['name'].split('.', 1)
domain = self.get_domain(domain_name[-1])
if not domain:
logger.error(
'Domain not found for record {}'.format(record)
Expand Down

0 comments on commit f943226

Please sign in to comment.