def _list_records__fetch_records(self, zone_id): """Returns all available records on a specific zone. """ # Try to get the list of DNS records under a specific zone from # the provider API. # We cannot call list_records() with the zone_id, we need to provide # a zone object. We will get that by calling the get_zone() method. try: records = self.connection.get_zone(zone_id).list_records() log.info("List records returned %d results for %s.", len(records), self.cloud) return records except InvalidCredsError as exc: log.warning("Invalid creds on running list_recordss on %s: %s", self.cloud, exc) raise CloudUnauthorizedError() except ssl.SSLError as exc: log.error("SSLError on running list_recordss on %s: %s", self.cloud, exc) raise CloudUnavailableError(exc=exc) except ZoneDoesNotExistError as exc: log.warning("No zone found for %s in: %s ", zone_id, self.cloud) raise ZoneNotFoundError(exc=exc) except Exception as exc: log.exception("Error while running list_records on %s", self.cloud) raise CloudUnavailableError(exc=exc)
def _create_record__for_zone(self, zone, **kwargs): """ This is the private method called to create a record under a specific zone. The underlying functionality is implement in the same way for all available providers so there shouldn't be any reason to override this. ---- """ try: zone = self.connection.get_zone(zone.zone_id) record = zone.create_record(**kwargs) log.info("Type %s record created successfully for %s.", record.type, self.cloud) return record except InvalidCredsError as exc: log.warning("Invalid creds on running create_record on %s: %s", self.cloud, exc) raise CloudUnauthorizedError() except ssl.SSLError as exc: log.error("SSLError on running create_record on %s: %s", self.cloud, exc) raise CloudUnavailableError(exc=exc) except ZoneDoesNotExistError as exc: log.warning("No zone found for %s in: %s ", zone.zone_id, self.cloud) raise ZoneNotFoundError(exc=exc) except Exception as exc: log.exception("Error while running create_record on %s", self.cloud) raise RecordCreationError( "Failed to create record, " "got error: %s" % exc, exc)
def _delete_zone__for_cloud(self, zone_id): """ We use the zone id to retrieve and delete it for this cloud. """ try: self.connection.get_zone(zone_id).delete() except ZoneDoesNotExistError as exc: log.warning("No zone found for %s in: %s ", zone_id, self.cloud) raise ZoneNotFoundError(exc=exc) except Exception as exc: log.exception("Error while running delete_zone on %s", self.cloud) raise CloudUnavailableError("Failed to delete zone: %s " % exc)
def _delete_record__from_id(self, zone_id, record_id): """ We use the zone and record ids to delete the specific record under the specified zone. """ try: self.connection.get_record(zone_id, record_id).delete() except ZoneDoesNotExistError as exc: log.warning("No zone found for %s in: %s ", zone_id, self.cloud) raise ZoneNotFoundError(exc=exc) except RecordDoesNotExistError as exc: log.warning("No record found for id: %s under zone %s", record_id, zone_id) raise RecordNotFoundError(exc=exc) except Exception as exc: log.exception("Error while running delete_record on %s", self.cloud) raise CloudUnavailableError(exc=exc)