Exemple #1
0
    def create_entry(self, entry):
        dns_zone = entry.dns_zone or self.default_dns_zone
        if dns_zone.id == None:
            raise TypeError("The entry's dns_zone must have an ID specified.")
        name = entry.name  # + "." + dns_zone.name
        LOG.debug("Going to create RSDNS entry %s." % name)
        try:
            future = self.dns_client.records.create(domain=dns_zone.id,
                record_name=name,
                record_data=entry.content,
                record_type=entry.type,
                record_ttl=entry.ttl)
            try:
                #TODO: Bring back our good friend poll_until.
                while(future.ready is False):
                    import time
                    time.sleep(2)
                    LOG.info("Waiting for the dns record_id.. ")

                if len(future.resource) < 1:
                    raise RsDnsError("No DNS records were created.")
                elif len(future.resource) > 1:
                    LOG.error("More than one DNS record created. Ignoring.")
                actual_record = future.resource[0]
                DnsRecord.create(name=name, record_id=actual_record.id)
                LOG.debug("Added RS DNS entry.")
            except RsDnsError as rde:
                LOG.error("An error occurred creating DNS entry!")
                raise
        except Exception as ex:
            LOG.error("Error when creating a DNS record!")
            raise
Exemple #2
0
    def create_entry(self, entry):
        dns_zone = entry.dns_zone or self.default_dns_zone
        if dns_zone.id is None:
            raise TypeError("The entry's dns_zone must have an ID specified.")
        name = entry.name  # + "." + dns_zone.name
        LOG.debug("Going to create RSDNS entry %s." % name)
        try:
            future = self.dns_client.records.create(domain=dns_zone.id,
                                                    record_name=name,
                                                    record_data=entry.content,
                                                    record_type=entry.type,
                                                    record_ttl=entry.ttl)
            try:
                #TODO: Bring back our good friend poll_until.
                while (future.ready is False):
                    import time
                    time.sleep(2)
                    LOG.info("Waiting for the dns record_id.. ")

                if len(future.resource) < 1:
                    raise RsDnsError("No DNS records were created.")
                elif len(future.resource) > 1:
                    LOG.error("More than one DNS record created. Ignoring.")
                actual_record = future.resource[0]
                DnsRecord.create(name=name, record_id=actual_record.id)
                LOG.debug("Added RS DNS entry.")
            except RsDnsError as rde:
                LOG.error("An error occurred creating DNS entry!")
                raise
        except Exception as ex:
            LOG.error("Error when creating a DNS record!")
            raise
Exemple #3
0
 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()
Exemple #4
0
 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()