cloudflare_dns: Fix solo SRV record creation

This commit is contained in:
Michael Gruener 2016-03-25 18:23:52 +01:00
parent 7477fe5141
commit 396d44c4b3

View file

@ -371,19 +371,21 @@ class CloudflareAPI(object):
params[param] = getattr(self,param) params[param] = getattr(self,param)
records = [] records = []
search_value = params['value'] content = params['value']
search_record = params['record'] search_record = params['record']
if params['type'] == 'SRV': if params['type'] == 'SRV':
search_value = str(params['weight']) + '\t' + str(params['port']) + '\t' + params['value'] content = str(params['weight']) + '\t' + str(params['port']) + '\t' + params['value']
search_record = params['service'] + '.' + params['proto'] + '.' + params['record'] search_record = params['service'] + '.' + params['proto'] + '.' + params['record']
if params['solo']: if params['solo']:
search_value = None search_value = None
else:
search_value = content
records = self.get_dns_records(params['zone'],params['type'],search_record,search_value) records = self.get_dns_records(params['zone'],params['type'],search_record,search_value)
for rr in records: for rr in records:
if params['solo']: if params['solo']:
if not ((rr['type'] == params['type']) and (rr['name'] == params['record']) and (rr['content'] == params['value'])): if not ((rr['type'] == params['type']) and (rr['name'] == search_record) and (rr['content'] == content)):
self.changed = True self.changed = True
if not self.module.check_mode: if not self.module.check_mode:
result, info = self._cf_api_call('/zones/{0}/dns_records/{1}'.format(rr['zone_id'],rr['id']),'DELETE') result, info = self._cf_api_call('/zones/{0}/dns_records/{1}'.format(rr['zone_id'],rr['id']),'DELETE')