Пример #1
0
    def create_record_set(self, context, dns_domain, dns_name, records):
        designate, designate_admin = get_clients(context)
        v4, v6 = self._classify_records(records)
        try:
            if v4:
                designate.recordsets.create(dns_domain, dns_name, 'A', v4)
            if v6:
                designate.recordsets.create(dns_domain, dns_name, 'AAAA', v6)
        except d_exc.NotFound:
            raise dns_exc.DNSDomainNotFound(dns_domain=dns_domain)
        except d_exc.Conflict:
            raise dns_exc.DuplicateRecordSet(dns_name=dns_name)
        except d_exc.OverQuota:
            raise dns_exc.ExternalDNSOverQuota(resource="recordset")

        if not CONF.designate.allow_reverse_dns_lookup:
            return
        # Set up the PTR records
        recordset_name = '%s.%s' % (dns_name, dns_domain)
        ptr_zone_email = 'admin@%s' % dns_domain[:-1]
        if CONF.designate.ptr_zone_email:
            ptr_zone_email = CONF.designate.ptr_zone_email
        for record in records:
            in_addr_name = netaddr.IPAddress(record).reverse_dns
            in_addr_zone_name = self._get_in_addr_zone_name(in_addr_name)
            in_addr_zone_description = (
                'An %s zone for reverse lookups set up by Neutron.' %
                '.'.join(in_addr_name.split('.')[-3:]))
            try:
                # Since we don't delete in-addr zones, assume it already
                # exists. If it doesn't, create it
                designate_admin.recordsets.create(in_addr_zone_name,
                                                  in_addr_name, 'PTR',
                                                  [recordset_name])
            except d_exc.NotFound:
                # Note(jh): If multiple PTRs get created at the same time,
                # the creation of the zone may fail with a conflict because
                # it has already been created by a parallel job. So we
                # ignore that error and try to create the recordset
                # anyway. That call will still fail in the end if something
                # is really broken. See bug 1891309.
                try:
                    designate_admin.zones.create(
                        in_addr_zone_name,
                        email=ptr_zone_email,
                        description=in_addr_zone_description)
                except d_exc.Conflict:
                    LOG.debug(
                        'Conflict when trying to create PTR zone %s,'
                        ' assuming it exists.', in_addr_zone_name)
                    pass
                designate_admin.recordsets.create(in_addr_zone_name,
                                                  in_addr_name, 'PTR',
                                                  [recordset_name])
Пример #2
0
 def _get_ids_ips_to_delete(self, dns_domain, name, records,
                            designate_client):
     try:
         recordsets = designate_client.recordsets.list(
             dns_domain, criterion={"name": "%s" % name})
     except d_exc.NotFound:
         raise dns_exc.DNSDomainNotFound(dns_domain=dns_domain)
     ids = [rec['id'] for rec in recordsets]
     ips = [str(ip) for rec in recordsets for ip in rec['records']]
     if set(ips) != set(records):
         raise dns_exc.DuplicateRecordSet(dns_name=name)
     return ids
Пример #3
0
 def check_name(self, ip_name):
     LOG.debug('Checking {} name'.format(ip_name))
     url = '{}ip_address_list/WHERE/name=\'{}\''.format(
         CONF.solidserver.url, ip_name)
     try:
         r = requests.get(url,
                          headers=self.headers,
                          verify=CONF.solidserver.verify)
     except:
         LOG.error('Something was terribly wrong')
     if r.status_code != 204:
         raise dns_exc.DuplicateRecordSet(dns_name=ip_name)
Пример #4
0
    def create_record_set(self, context, dns_domain, dns_name, records):
        designate, designate_admin = get_clients(context)
        v4, v6 = self._classify_records(records)
        try:
            if v4:
                designate.recordsets.create(dns_domain, dns_name, 'A', v4)
            if v6:
                designate.recordsets.create(dns_domain, dns_name, 'AAAA', v6)
        except d_exc.NotFound:
            raise dns_exc.DNSDomainNotFound(dns_domain=dns_domain)
        except d_exc.Conflict:
            raise dns_exc.DuplicateRecordSet(dns_name=dns_name)

        if not CONF.designate.allow_reverse_dns_lookup:
            return
        # Set up the PTR records
        recordset_name = '%s.%s' % (dns_name, dns_domain)
        ptr_zone_email = 'admin@%s' % dns_domain[:-1]
        if CONF.designate.ptr_zone_email:
            ptr_zone_email = CONF.designate.ptr_zone_email
        for record in records:
            in_addr_name = netaddr.IPAddress(record).reverse_dns
            in_addr_zone_name = self._get_in_addr_zone_name(in_addr_name)
            in_addr_zone_description = (
                'An %s zone for reverse lookups set up by Neutron.' %
                '.'.join(in_addr_name.split('.')[-3:]))
            try:
                # Since we don't delete in-addr zones, assume it already
                # exists. If it doesn't, create it
                designate_admin.recordsets.create(in_addr_zone_name,
                                                  in_addr_name, 'PTR',
                                                  [recordset_name])
            except d_exc.NotFound:
                designate_admin.zones.create(
                    in_addr_zone_name,
                    email=ptr_zone_email,
                    description=in_addr_zone_description)
                designate_admin.recordsets.create(in_addr_zone_name,
                                                  in_addr_name, 'PTR',
                                                  [recordset_name])