CloudFlare DNS Driver Documentation

CloudFlare, Inc. is a U.S. company that provides a content delivery network and distributed domain name server services.

../../_images/cloudflare.png

Instantiating the driver

To instantiate the driver you need to pass email address associated with your account and API key available on the account page to the driver constructor as shown below.

from libcloud.dns.types import Provider
from libcloud.dns.providers import get_driver

cls = get_driver(Provider.CLOUDFLARE)
driver = cls('<email address>', '<api key>')

API Docs

class libcloud.dns.drivers.cloudflare.CloudFlareDNSDriver(key, secret=None, secure=True, host=None, port=None, **kwargs)[source]
Parameters:
  • key (str) – API key or username to used (required)
  • secret (str) – Secret password to be used (required)
  • secure (bool) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default.
  • host (str) – Override hostname used for connections.
  • port (int) – Override port used for connections.
Returns:

None

create_zone(domain, type='master', ttl=None, extra=None)

Create a new zone.

Parameters:
  • domain (str) – Zone domain name (e.g. example.com)
  • type (str) – Zone type (master / slave).
  • ttl (int) – TTL for new records. (optional)
  • extra (dict) – Extra attributes (driver specific). (optional)
Return type:

Zone

delete_zone(zone)

Delete a zone.

Note: This will delete all the records belonging to this zone.

Parameters:zone (Zone) – Zone to delete.
Return type:bool
ex_blacklist_ip(zone, ip)[source]

Blacklist the provided IP.

ex_disable_development_mode(zone)[source]

Disable development mode.

ex_disable_ipv6_support(zone)[source]

Disable IPv6 support for the provided zone.

ex_enable_development_mode(zone)[source]

Enable development mode. When Development Mode is on the cache is bypassed. Development mode remains on for 3 hours or until when it is toggled back off.

ex_enable_ipv6_support(zone)[source]

Enable IPv6 support for the provided zone.

ex_get_ip_threat_score(ip)[source]

Retrieve current threat score for a given IP. Note that scores are on a logarithmic scale, where a higher score indicates a higher threat.

ex_get_zone_settings(zone)[source]

Retrieve all current settings for a given zone.

ex_purge_cached_file(zone, url)[source]

Purge single file from CloudFlare’s cache.

Parameters:url (str) – URL to the file to purge from cache.
ex_purge_cached_files(zone)[source]

Purge CloudFlare of any cached files.

ex_set_zone_cache_level(zone, level)[source]

Set the zone caching level.

Parameters:level (str) – Caching level. Valid values are: agg (aggresive), basic.
ex_set_zone_security_level(zone, level)[source]

Set the zone Basic Security Level to I’M UNDER ATTACK! / HIGH / MEDIUM / LOW / ESSENTIALLY OFF.

Parameters:level (str) – Security level. Valid values are: help, high, med, low, eoff.
ex_unlist_ip(zone, ip)[source]

Remove provided ip from the whitelist and blacklist.

ex_whitelist_ip(zone, ip)[source]

Whitelist the provided IP.

export_zone_to_bind_format(zone)

Export Zone object to the BIND compatible format.

Parameters:zone (Zone) – Zone to export.
Returns:Zone data in BIND compatible format.
Return type:str
export_zone_to_bind_zone_file(zone, file_path)

Export Zone object to the BIND compatible format and write result to a file.

Parameters:
  • zone (Zone) – Zone to export.
  • file_path (str) – File path where the output will be saved.
get_record(zone_id, record_id)

Return a Record instance.

Parameters:
  • zone_id (str) – ID of the required zone
  • record_id (str) – ID of the required record
Return type:

Record

list_record_types()

Return a list of RecordType objects supported by the provider.

Returns:list of RecordType
list_records(zone)

Return a list of records for the provided zone.

Parameters:zone (Zone) – Zone to list records for.
Returns:list of Record
list_zones()

Return a list of zones.

Returns:list of Zone
update_zone(zone, domain, type='master', ttl=None, extra=None)

Update an existing zone.

Parameters:
  • zone (Zone) – Zone to update.
  • domain (str) – Zone domain name (e.g. example.com)
  • type (str) – Zone type (master / slave).
  • ttl (int) – TTL for new records. (optional)
  • extra (dict) – Extra attributes (driver specific). (optional)
Return type:

Zone