def delete_entry(self, name, type, dns_zone=None): """Deletes an entry with the given name and type from a dns zone.""" dns_zone = dns_zone or self.default_dns_zone records = self._get_records(dns_zone) matching_record = [rec for rec in records if rec.name == name + '.' and rec.type == type] if not matching_record: raise exception.DnsRecordNotFound(name) LOG.debug("Deleting DNS entry %s." % name) self.dns_client.records.delete(dns_zone.id, matching_record[0].id)
def delete_entry(self, name, type, dns_zone=None): dns_zone = dns_zone or self.default_dns_zone long_name = name db_record = DnsRecord.find_by(name=name) record = self.dns_client.records.get(domain_id=dns_zone.id, record_id=db_record.record_id) if record.name != name or record.type != 'A': LOG.error("Tried to delete DNS record with name=%s, id=%s, but the" " database returned a DNS record with the name %s and " "type %s." % (name, db_record.id, record.name, record.type)) raise exception.DnsRecordNotFound(name) self.dns_client.records.delete(domain_id=dns_zone.id, record_id=record.id) db_record.delete()