summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--designate/backend/impl_pdns4.py82
-rw-r--r--designate/backend/impl_powerdns/__init__.py2
-rw-r--r--devstack/designate_plugins/backend-pdns4181
-rw-r--r--devstack/designate_plugins/backend-pdns4-mysql-db.sql92
-rw-r--r--doc/source/backends/pdns4.rst57
-rw-r--r--doc/source/backends/powerdns.rst3
-rw-r--r--doc/source/backends/sample_yaml_snippets/pdns4.yaml16
-rw-r--r--doc/source/support-matrix.ini12
-rw-r--r--setup.cfg1
9 files changed, 444 insertions, 2 deletions
diff --git a/designate/backend/impl_pdns4.py b/designate/backend/impl_pdns4.py
new file mode 100644
index 0000000..a983d5b
--- /dev/null
+++ b/designate/backend/impl_pdns4.py
@@ -0,0 +1,82 @@
1# Copyright 2016 Hewlett Packard Enterprise Development Company, L.P.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14import urlparse
15
16import requests
17from oslo_log import log as logging
18from oslo_config import cfg
19
20from designate import exceptions
21from designate.backend import base
22
23
24LOG = logging.getLogger(__name__)
25CONF = cfg.CONF
26
27
28class PDNS4Backend(base.Backend):
29 __plugin_name__ = 'pdns4'
30
31 __backend_status__ = 'release-compatible'
32
33 def __init__(self, target):
34 super(PDNS4Backend, self).__init__(target)
35
36 self.api_endpoint = self.options.get('api_endpoint')
37 self.api_token = self.options.get('api_token')
38
39 def _build_url(self, zone=''):
40 r_url = urlparse.urlparse(self.api_endpoint)
41 return "%s://%s/api/v1/servers/localhost/zones%s%s" % (
42 r_url.scheme, r_url.netloc, '/' if zone else '', zone)
43
44 def create_zone(self, context, zone):
45 """Create a DNS zone"""
46
47 masters = \
48 ['%s:%d' % (master.host, master.port) for master in self.masters]
49
50 data = {
51 "name": zone.name,
52 "kind": "slave",
53 "masters": masters,
54
55 }
56 headers = {
57 "X-API-Key": self.api_token
58 }
59
60 try:
61 requests.post(
62 self._build_url(),
63 json=data,
64 headers=headers
65 ).raise_for_status()
66 except requests.HTTPError as e:
67 raise exceptions.Backend(e)
68
69 def delete_zone(self, context, zone):
70 """Delete a DNS zone"""
71
72 headers = {
73 "X-API-Key": self.api_token
74 }
75
76 try:
77 requests.delete(
78 self._build_url(zone.name),
79 headers=headers
80 ).raise_for_status()
81 except requests.HTTPError as e:
82 raise exceptions.Backend(e)
diff --git a/designate/backend/impl_powerdns/__init__.py b/designate/backend/impl_powerdns/__init__.py
index 41ca3f6..908cf22 100644
--- a/designate/backend/impl_powerdns/__init__.py
+++ b/designate/backend/impl_powerdns/__init__.py
@@ -40,7 +40,7 @@ def _map_col(keys, col):
40class PowerDNSBackend(base.Backend): 40class PowerDNSBackend(base.Backend):
41 __plugin_name__ = 'powerdns' 41 __plugin_name__ = 'powerdns'
42 42
43 __backend_status__ = 'integrated' 43 __backend_status__ = 'deprecated'
44 44
45 @classmethod 45 @classmethod
46 def get_cfg_opts(cls): 46 def get_cfg_opts(cls):
diff --git a/devstack/designate_plugins/backend-pdns4 b/devstack/designate_plugins/backend-pdns4
new file mode 100644
index 0000000..37247b8
--- /dev/null
+++ b/devstack/designate_plugins/backend-pdns4
@@ -0,0 +1,181 @@
1# Configure the powerdns backend
2
3# Enable with:
4# DESIGNATE_BACKEND_DRIVER=powerdns
5
6# Dependencies:
7# ``functions`` file
8# ``designate`` configuration
9
10# install_designate_backend - install any external requirements
11# configure_designate_backend - make configuration changes, including those to other services
12# init_designate_backend - initialize databases, etc.
13# start_designate_backend - start any external services
14# stop_designate_backend - stop any external services
15# cleanup_designate_backend - remove transient data and cache
16
17# Save trace setting
18DP_PDNS_XTRACE=$(set +o | grep xtrace)
19set +o xtrace
20
21# Defaults
22# --------
23if is_fedora; then
24 POWERDNS_CFG_DIR=/etc/pdns
25else
26 POWERDNS_CFG_DIR=/etc/powerdns
27fi
28
29# Entry Points
30# ------------
31
32# install_designate_backend - install any external requirements
33function install_designate_backend {
34 if is_ubuntu; then
35 GetOSVersion
36 if [ "$os_CODENAME" = "trusty" ]; then
37 sudo tee /etc/apt/sources.list.d/pdns.list > /dev/null <<EOF
38deb [arch=amd64] http://repo.powerdns.com/ubuntu trusty-auth-40 main
39EOF
40 sudo tee /etc/apt/preferences.d/pdns > /dev/null <<EOF
41Package: pdns-*
42Pin: origin repo.powerdns.com
43Pin-Priority: 600
44EOF
45 curl https://repo.powerdns.com/FD380FBB-pub.asc | sudo apt-key add - &&
46 sudo apt-get update
47 elif [ "$os_CODENAME" = "xenial" ]; then
48 echo "Use PDNS4 from apt repo"
49 else
50 die $LINENO "PDNS4 backend only supports trusty or xenial"
51 fi
52 PDNS=pdns-server
53 else
54 die $LINENO "PDNS4 Backend plugin backend only supports Ubuntu"
55 fi
56
57 if is_service_enabled mysql; then
58 PDNS+=" pdns-backend-mysql"
59 else
60 die $LINENO "PDNS4 backend only supports MySQL"
61 fi
62
63 install_package $PDNS
64 sudo rm -rf $POWERDNS_CFG_DIR/pdns.d
65}
66
67# configure_designate_backend - make configuration changes, including those to other services
68function configure_designate_backend {
69 # Generate Designate pool.yaml file
70 sudo tee $DESIGNATE_CONF_DIR/pools.yaml > /dev/null <<EOF
71---
72- name: default
73 description: DevStack PowerDNS Pool
74 attributes: {}
75
76 ns_records:
77 - hostname: $DESIGNATE_DEFAULT_NS_RECORD
78 priority: 1
79
80 nameservers:
81 - host: $DESIGNATE_SERVICE_HOST
82 port: $DESIGNATE_SERVICE_PORT_DNS
83
84 targets:
85 - type: pdns4
86 description: PowerDNS Database Cluster
87
88 masters:
89 - host: $DESIGNATE_SERVICE_HOST
90 port: $DESIGNATE_SERVICE_PORT_MDNS
91
92 options:
93 host: $DESIGNATE_SERVICE_HOST
94 port: $DESIGNATE_SERVICE_PORT_DNS
95 api_endpoint: http://$DESIGNATE_SERVICE_HOST:8081
96 api_token: changeme
97EOF
98
99 # Generate PowerDNS pdns.conf file
100 sudo tee $POWERDNS_CFG_DIR/pdns.conf > /dev/null <<EOF
101# General Config
102setgid=pdns
103setuid=pdns
104config-dir=$POWERDNS_CFG_DIR
105socket-dir=/var/run
106guardian=yes
107daemon=yes
108disable-axfr=no
109local-address=$DESIGNATE_SERVICE_HOST
110local-port=$DESIGNATE_SERVICE_PORT_DNS
111master=no
112slave=yes
113cache-ttl=0
114query-cache-ttl=0
115negquery-cache-ttl=0
116out-of-zone-additional-processing=no
117webserver=yes
118webserver-address=$DESIGNATE_SERVICE_HOST
119api=yes
120api-key=changeme
121EOF
122
123 if is_service_enabled mysql; then
124 sudo tee -a $POWERDNS_CFG_DIR/pdns.conf > /dev/null <<EOF
125# Launch gmysql backend
126launch=gmysql
127
128# gmysql parameters
129gmysql-host=$DATABASE_HOST
130gmysql-user=$DATABASE_USER
131gmysql-password=$DATABASE_PASSWORD
132gmysql-dbname=designate_pdns
133gmysql-dnssec=yes
134EOF
135 else
136 die $LINENO "PDNS4 backend only supports MySQL"
137 fi
138 restart_service pdns
139}
140
141# init_designate_backend - initialize databases, etc.
142function init_designate_backend {
143 # Stop pdns so that the migration succeeds, if not you get a error
144 # that the schema is still in use.
145 if is_service_enabled postgresql; then
146 stop_designate_backend
147 fi
148
149 # (Re)create designate_pdns database
150 recreate_database designate_pdns utf8
151 if is_service_enabled mysql; then
152 sudo mysql -u root designate_pdns < $DESIGNATE_PLUGINS/backend-pdns4-mysql-db.sql
153 else
154 die $LINENO "PDNS4 backend only supports MySQL"
155 fi
156}
157
158# create_designate_pool_configuration_backend - Perform post-pool config tasks
159function create_designate_pool_configuration_backend {
160 # Init and migrate designate_pdns database
161 :
162}
163
164# start_designate_backend - start any external services
165function start_designate_backend {
166 start_service pdns
167}
168
169
170# stop_designate_backend - stop any external services
171function stop_designate_backend {
172 stop_service pdns
173}
174
175# cleanup_designate_backend - remove transient data and cache
176function cleanup_designate_backend {
177 :
178}
179
180# Restore xtrace
181$DP_PDNS_XTRACE
diff --git a/devstack/designate_plugins/backend-pdns4-mysql-db.sql b/devstack/designate_plugins/backend-pdns4-mysql-db.sql
new file mode 100644
index 0000000..6fc8647
--- /dev/null
+++ b/devstack/designate_plugins/backend-pdns4-mysql-db.sql
@@ -0,0 +1,92 @@
1CREATE TABLE domains (
2 id INT AUTO_INCREMENT,
3 name VARCHAR(255) NOT NULL,
4 master VARCHAR(128) DEFAULT NULL,
5 last_check INT DEFAULT NULL,
6 type VARCHAR(6) NOT NULL,
7 notified_serial INT DEFAULT NULL,
8 account VARCHAR(40) DEFAULT NULL,
9 PRIMARY KEY (id)
10) Engine=InnoDB;
11
12CREATE UNIQUE INDEX name_index ON domains(name);
13
14
15CREATE TABLE records (
16 id INT AUTO_INCREMENT,
17 domain_id INT DEFAULT NULL,
18 name VARCHAR(255) DEFAULT NULL,
19 type VARCHAR(10) DEFAULT NULL,
20 -- Changed to "TEXT", as VARCHAR(65000) is too big for most MySQL installs
21 content TEXT DEFAULT NULL,
22 ttl INT DEFAULT NULL,
23 prio INT DEFAULT NULL,
24 change_date INT DEFAULT NULL,
25 disabled TINYINT(1) DEFAULT 0,
26 ordername VARCHAR(255) BINARY DEFAULT NULL,
27 auth TINYINT(1) DEFAULT 1,
28 PRIMARY KEY (id)
29) Engine=InnoDB;
30
31CREATE INDEX nametype_index ON records(name,type);
32CREATE INDEX domain_id ON records(domain_id);
33CREATE INDEX recordorder ON records (domain_id, ordername);
34
35
36CREATE TABLE supermasters (
37 ip VARCHAR(64) NOT NULL,
38 nameserver VARCHAR(255) NOT NULL,
39 account VARCHAR(40) NOT NULL,
40 PRIMARY KEY (ip, nameserver)
41) Engine=InnoDB;
42
43
44CREATE TABLE comments (
45 id INT AUTO_INCREMENT,
46 domain_id INT NOT NULL,
47 name VARCHAR(255) NOT NULL,
48 type VARCHAR(10) NOT NULL,
49 modified_at INT NOT NULL,
50 account VARCHAR(40) NOT NULL,
51 -- Changed to "TEXT", as VARCHAR(65000) is too big for most MySQL installs
52 comment TEXT NOT NULL,
53 PRIMARY KEY (id)
54) Engine=InnoDB;
55
56CREATE INDEX comments_domain_id_idx ON comments (domain_id);
57CREATE INDEX comments_name_type_idx ON comments (name, type);
58CREATE INDEX comments_order_idx ON comments (domain_id, modified_at);
59
60
61CREATE TABLE domainmetadata (
62 id INT AUTO_INCREMENT,
63 domain_id INT NOT NULL,
64 kind VARCHAR(32),
65 content TEXT,
66 PRIMARY KEY (id)
67) Engine=InnoDB;
68
69CREATE INDEX domainmetadata_idx ON domainmetadata (domain_id, kind);
70
71
72CREATE TABLE cryptokeys (
73 id INT AUTO_INCREMENT,
74 domain_id INT NOT NULL,
75 flags INT NOT NULL,
76 active BOOL,
77 content TEXT,
78 PRIMARY KEY(id)
79) Engine=InnoDB;
80
81CREATE INDEX domainidindex ON cryptokeys(domain_id);
82
83
84CREATE TABLE tsigkeys (
85 id INT AUTO_INCREMENT,
86 name VARCHAR(255),
87 algorithm VARCHAR(50),
88 secret VARCHAR(255),
89 PRIMARY KEY (id)
90) Engine=InnoDB;
91
92CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);
diff --git a/doc/source/backends/pdns4.rst b/doc/source/backends/pdns4.rst
new file mode 100644
index 0000000..46d4e72
--- /dev/null
+++ b/doc/source/backends/pdns4.rst
@@ -0,0 +1,57 @@
1..
2 Copyright 2016 Hewlett Packard Enterprise Development, L.P.
3
4 Licensed under the Apache License, Version 2.0 (the "License"); you may
5 not use this file except in compliance with the License. You may obtain
6 a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 License for the specific language governing permissions and limitations
14 under the License.
15
16.. _backend-pdns4:
17
18PDNS4 Backend
19=============
20
21PDNS4 Configuration
22-------------------
23
24The version PowerDNS in Ubuntu Xenial is pdns4.
25This has a different DB schema, and is incompatible with the legacy PowerDNS
26driver. In PDNS 4 the API was marked stable, and this is what we will use.
27
28You will need to configure PowerDNS, and its database before perfoming these
29steps.
30
31You will need to use a database backend for PowerDNS's API to function.
32
33See `PowerDNS Docs`_ for details.
34
351. Enable the API in the ``pdns.conf`` file.
36
37.. code-block:: ini
38
39 webserver=yes
40 api=yes
41 api-key=changeme
42
432. Configure the PowerDNS Backend using this sample target snippet
44
45.. literalinclude:: sample_yaml_snippets/pdns4.yaml
46 :language: yaml
47
483. Then update the pools in designate
49
50.. code-block:: console
51
52 $ designate-manage pool update
53
54See :ref:`designate_manage_pool` for further details on the ``designate-manage pool``
55command, and :ref:`pools` for information about the yaml file syntax
56
57.. _PowerDNS Docs: https://doc.powerdns.com/md/authoritative/installation/
diff --git a/doc/source/backends/powerdns.rst b/doc/source/backends/powerdns.rst
index 633718f..5ece8f0 100644
--- a/doc/source/backends/powerdns.rst
+++ b/doc/source/backends/powerdns.rst
@@ -18,6 +18,9 @@
18PowerDNS Backend 18PowerDNS Backend
19================ 19================
20 20
21.. warning:: This backend will not work with PowerDNS version 4 or greater. Use the ``pdns4`` backend.
22
23
21 24
22PowerDNS Configuration 25PowerDNS Configuration
23---------------------- 26----------------------
diff --git a/doc/source/backends/sample_yaml_snippets/pdns4.yaml b/doc/source/backends/sample_yaml_snippets/pdns4.yaml
new file mode 100644
index 0000000..0bd63fd
--- /dev/null
+++ b/doc/source/backends/sample_yaml_snippets/pdns4.yaml
@@ -0,0 +1,16 @@
1 targets:
2 - type: pdns4
3 description: PowerDNS4 DNS Server
4
5 # List out the designate-mdns servers from which PowerDNS servers should
6 # request zone transfers (AXFRs) from.
7 masters:
8 - host: 192.0.2.1
9 port: 5354
10
11 # PowerDNS Configuration options
12 options:
13 host: 192.0.2.1
14 port: 53
15 api_endpoint: http://127.0.0.1:8081
16 api_token: changeme
diff --git a/doc/source/support-matrix.ini b/doc/source/support-matrix.ini
index 92c7466..5b0c32a 100644
--- a/doc/source/support-matrix.ini
+++ b/doc/source/support-matrix.ini
@@ -45,6 +45,7 @@ in-tree=True
45[backends] 45[backends]
46backend-impl-bind9=Bind9 46backend-impl-bind9=Bind9
47backend-impl-powerdns-mysql=Power DNS (MySQL) 47backend-impl-powerdns-mysql=Power DNS (MySQL)
48backend-impl-pdns4=Power DNS 4
48backend-impl-designate=Designate to Designate 49backend-impl-designate=Designate to Designate
49backend-impl-dynect=DynECT 50backend-impl-dynect=DynECT
50backend-impl-akamai=Akamai eDNS 51backend-impl-akamai=Akamai eDNS
@@ -61,7 +62,10 @@ backend-impl-msdns-agent=Microsoft DNS (Agent)
61 62
62[backends.backend-impl-bind9] 63[backends.backend-impl-bind9]
63 64
65[backends.backend-impl-pdns4]
66
64[backends.backend-impl-powerdns-mysql] 67[backends.backend-impl-powerdns-mysql]
68notes=This has been replaced by the pdns4 backend for future releases
65 69
66[backends.backend-impl-designate] 70[backends.backend-impl-designate]
67 71
@@ -101,7 +105,7 @@ type=agent
101type=agent 105type=agent
102 106
103[grades] 107[grades]
104valid-grades=integrated,master-compatible,release-compatible,untested,failing,known-broken,experimental 108valid-grades=integrated,master-compatible,release-compatible,untested,failing,known-broken,experimental,deprecated
105 109
106[grades.integrated] 110[grades.integrated]
107title=Integrated 111title=Integrated
@@ -144,3 +148,9 @@ title=Experimental
144notes=Backends that are under development, and may change at any time 148notes=Backends that are under development, and may change at any time
145in-tree=optional 149in-tree=optional
146css-class=warning 150css-class=warning
151
152[grades.deprecated]
153title=Deprecated
154notes=Backends have been superseded, and will be removed in the future
155in-tree=optional
156css-class=warning
diff --git a/setup.cfg b/setup.cfg
index 3b6a346..b99a9e3 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -86,6 +86,7 @@ designate.backend =
86 bind9 = designate.backend.impl_bind9:Bind9Backend 86 bind9 = designate.backend.impl_bind9:Bind9Backend
87 designate = designate.backend.impl_designate:DesignateBackend 87 designate = designate.backend.impl_designate:DesignateBackend
88 powerdns = designate.backend.impl_powerdns:PowerDNSBackend 88 powerdns = designate.backend.impl_powerdns:PowerDNSBackend
89 pdns4 = designate.backend.impl_pdns4:PDNS4Backend
89 dynect = designate.backend.impl_dynect:DynECTBackend 90 dynect = designate.backend.impl_dynect:DynECTBackend
90 akamai = designate.backend.impl_akamai:AkamaiBackend 91 akamai = designate.backend.impl_akamai:AkamaiBackend
91 nsd4 = designate.backend.impl_nsd4:NSD4Backend 92 nsd4 = designate.backend.impl_nsd4:NSD4Backend