Browse Source

Add Agent DevStack Backend

* Add a new backend for DevStack allowing the Agent
  backend to be configured.
* Change the agent to choose a sane port by default, it's extremely
  unlikely anyone is exposing the agent on port 53 intentionally.
* The agent itself is not yet configured, this will come later as it
  involves refactoring most of the BIND non-agent backend into a lib.
* Fail when the user asks for the agent backend, without also enabling
  the agent service.

Change-Id: Iedde58f4f5a2ea89cb9da78aaec1853208af8fc9
Kiall Mac Innes 3 years ago
parent
commit
620fc6ec97

+ 2
- 2
designate/agent/__init__.py View File

@@ -25,9 +25,9 @@ OPTS = [
25 25
     cfg.IntOpt('threads', default=1000,
26 26
                help='Number of agent greenthreads to spawn'),
27 27
     cfg.IPOpt('host', default='0.0.0.0',
28
-              help='The Agent Bind Host'),
28
+              help='The host for the Agent to bind to'),
29 29
     cfg.PortOpt('port', default=5358,
30
-                help='mDNS Port Number'),
30
+                help='The port for the Agent to bind to'),
31 31
     cfg.IntOpt('tcp-backlog', default=100,
32 32
                help='The Agent TCP Backlog'),
33 33
     cfg.FloatOpt('tcp-recv-timeout', default=0.5,

+ 1
- 1
designate/backend/agent.py View File

@@ -58,7 +58,7 @@ class AgentPoolBackend(base.Backend):
58 58
     def __init__(self, target):
59 59
         super(AgentPoolBackend, self).__init__(target)
60 60
         self.host = self.options.get('host', '127.0.0.1')
61
-        self.port = int(self.options.get('port', 53))
61
+        self.port = int(self.options.get('port', 5358))
62 62
         self.timeout = CONF['service:pool_manager'].poll_timeout
63 63
         self.retry_interval = CONF['service:pool_manager'].poll_retry_interval
64 64
         self.max_retries = CONF['service:pool_manager'].poll_max_retries

+ 103
- 0
devstack/designate_plugins/backend-agent View File

@@ -0,0 +1,103 @@
1
+# Configure the agent backend
2
+
3
+# Enable with:
4
+# DESIGNATE_BACKEND_DRIVER=agent
5
+# DESIGNATE_AGENT_BACKEND_DRIVER=<an agent backend>
6
+
7
+# Dependencies:
8
+# ``functions`` file
9
+# ``designate`` configuration
10
+
11
+# install_designate_backend - install any external requirements
12
+# configure_designate_backend - make configuration changes, including those to other services
13
+# init_designate_backend - initialize databases, etc.
14
+# start_designate_backend - start any external services
15
+# stop_designate_backend - stop any external services
16
+# cleanup_designate_backend - remove transient data and cache
17
+
18
+# Save trace setting
19
+DP_AGENT_XTRACE=$(set +o | grep xtrace)
20
+set +o xtrace
21
+
22
+# Get agent backend configuration
23
+# -------------------------------
24
+if [[ -r $DESIGNATE_PLUGINS/backend-agent-$DESIGNATE_AGENT_BACKEND_DRIVER ]]; then
25
+    # Load plugin
26
+    source $DESIGNATE_PLUGINS/backend-agent-$DESIGNATE_AGENT_BACKEND_DRIVER
27
+fi
28
+
29
+# Entry Points
30
+# ------------
31
+
32
+# install_designate_backend - install any external requirements
33
+function install_designate_backend {
34
+    # Install the Agent Backend
35
+    install_designate_agent_backend
36
+}
37
+
38
+# configure_designate_backend - make configuration changes, including those to other services
39
+function configure_designate_backend {
40
+    # Generate Designate pool.yaml file
41
+    sudo tee $DESIGNATE_CONF_DIR/pools.yaml > /dev/null <<EOF
42
+---
43
+- name: default
44
+  description: DevStack Agent Pool
45
+  attributes: {}
46
+
47
+  ns_records:
48
+    - hostname: $DESIGNATE_DEFAULT_NS_RECORD
49
+      priority: 1
50
+
51
+  nameservers:
52
+    - host: $DESIGNATE_SERVICE_HOST
53
+      port: $DESIGNATE_SERVICE_PORT_DNS
54
+
55
+  targets:
56
+    - type: agent
57
+      description: Agent Instance
58
+
59
+      masters:
60
+        - host: $DESIGNATE_SERVICE_HOST
61
+          port: $DESIGNATE_SERVICE_PORT_MDNS
62
+
63
+      options:
64
+        host: $DESIGNATE_SERVICE_HOST
65
+        port: $DESIGNATE_SERVICE_PORT_AGENT
66
+EOF
67
+
68
+    # Configure Agent Settings
69
+    iniset $DESIGNATE_CONF service:agent backend_driver $DESIGNATE_AGENT_BACKEND_DRIVER
70
+    iniset $DESIGNATE_CONF service:agent host $DESIGNATE_SERVICE_HOST
71
+    iniset $DESIGNATE_CONF service:agent port $DESIGNATE_SERVICE_PORT_AGENT
72
+    iniset $DESIGNATE_CONF service:agent masters "$DESIGNATE_SERVICE_HOST:$DESIGNATE_SERVICE_PORT_MDNS"
73
+
74
+    # Configure the Agent Backend
75
+    configure_designate_agent_backend
76
+}
77
+
78
+# init_designate_backend - initialize databases, etc.
79
+function init_designate_backend {
80
+    # Init the Agent Backend
81
+    init_designate_agent_backend
82
+}
83
+
84
+# start_designate_backend - start any external services
85
+function start_designate_backend {
86
+    # Start the Agent Backend
87
+    start_designate_agent_backend
88
+}
89
+
90
+# stop_designate_backend - stop any external services
91
+function stop_designate_backend {
92
+    # Stop the Agent Backend
93
+    stop_designate_agent_backend
94
+}
95
+
96
+# cleanup_designate_backend - remove transient data and cache
97
+function cleanup_designate_backend {
98
+    # Cleanup the Agent Backend
99
+    cleanup_designate_agent_backend
100
+}
101
+
102
+# Restore xtrace
103
+$DP_AGENT_XTRACE

+ 55
- 0
devstack/designate_plugins/backend-agent-fake View File

@@ -0,0 +1,55 @@
1
+# Configure the fake agent backend
2
+
3
+# Enable with:
4
+# DESIGNATE_BACKEND_DRIVER=agent
5
+# DESIGNATE_AGENT_BACKEND_DRIVER=fake
6
+
7
+# install_designate_agent_backend - install any external requirements
8
+# configure_designate_agent_backend - make configuration changes, including those to other services
9
+# init_designate_agent_backend - initialize databases, etc.
10
+# start_designate_agent_backend - start any external services
11
+# stop_designate_agent_backend - stop any external services
12
+# cleanup_designate_agent_backend - remove transient data and cache
13
+
14
+# Save trace setting
15
+DP_AGENT_FAKE_XTRACE=$(set +o | grep xtrace)
16
+set +o xtrace
17
+
18
+# Defaults
19
+# --------
20
+
21
+# Entry Points
22
+# ------------
23
+
24
+# install_designate_agent_backend - install any external requirements
25
+function install_designate_agent_backend {
26
+    :
27
+}
28
+
29
+# configure_designate_agent_backend - make configuration changes, including those to other services
30
+function configure_designate_agent_backend {
31
+    :
32
+}
33
+
34
+# init_designate_agent_backend - initialize databases, etc.
35
+function init_designate_agent_backend {
36
+    :
37
+}
38
+
39
+# start_designate_agent_backend - start any external services
40
+function start_designate_agent_backend {
41
+    :
42
+}
43
+
44
+# stop_designate_agent_backend - stop any external services
45
+function stop_designate_agent_backend {
46
+    :
47
+}
48
+
49
+# cleanup_designate_agent_backend - remove transient data and cache
50
+function cleanup_designate_agent_backend {
51
+    :
52
+}
53
+
54
+# Restore xtrace
55
+$DP_AGENT_FAKE_XTRACE

+ 7
- 1
devstack/plugin.sh View File

@@ -5,7 +5,7 @@ XTRACE=$(set +o | grep xtrace)
5 5
 set +o xtrace
6 6
 
7 7
 # Get backend configuration
8
-# ----------------------------
8
+# -------------------------
9 9
 if is_service_enabled designate && [[ -r $DESIGNATE_PLUGINS/backend-$DESIGNATE_BACKEND_DRIVER ]]; then
10 10
     # Load plugin
11 11
     source $DESIGNATE_PLUGINS/backend-$DESIGNATE_BACKEND_DRIVER
@@ -150,6 +150,7 @@ function configure_designatedashboard {
150 150
 function configure_designate_tempest() {
151 151
     if is_service_enabled tempest; then
152 152
         nameservers=$DESIGNATE_SERVICE_HOST:$DESIGNATE_SERVICE_PORT_DNS
153
+        # TODO(kiall): Remove hardcoded list of plugins
153 154
         case $DESIGNATE_BACKEND_DRIVER in
154 155
             bind9|powerdns)
155 156
                 nameservers="$DESIGNATE_SERVICE_HOST:$DESIGNATE_SERVICE_PORT_DNS"
@@ -306,6 +307,11 @@ function stop_designate {
306 307
 
307 308
 # This is the main for plugin.sh
308 309
 if is_service_enabled designate; then
310
+    # Sanify check for agent backend
311
+    # ------------------------------
312
+    if ! is_service_enabled designate-agent && [ "$DESIGNATE_BACKEND_DRIVER" == "agent" ]; then
313
+        die $LINENO "To use the agent backend, you must enable the designate-agent service"
314
+    fi
309 315
 
310 316
     if [[ "$1" == "stack" && "$2" == "install" ]]; then
311 317
         echo_summary "Installing Designate client"

+ 2
- 1
devstack/settings View File

@@ -1,5 +1,6 @@
1 1
 # Default options
2 2
 DESIGNATE_BACKEND_DRIVER=${DESIGNATE_BACKEND_DRIVER:=powerdns}
3
+DESIGNATE_AGENT_BACKEND_DRIVER=${DESIGNATE_AGENT_BACKEND_DRIVER:-"fake"}
3 4
 DESIGNATE_POOL_MANAGER_CACHE_DRIVER=${DESIGNATE_POOL_MANAGER_CACHE_DRIVER:-memcache}
4 5
 DESIGNATE_POOL_ID=${DESIGNATE_POOL_ID:-794ccc2c-d751-44fe-b57f-8894c9f5c842}
5 6
 DESIGNATE_DEFAULT_NS_RECORD=${DESIGNATE_DEFAULT_NS_RECORD:-ns1.devstack.org.}
@@ -21,6 +22,7 @@ DESIGNATE_SERVICE_PORT=${DESIGNATE_SERVICE_PORT:-9001}
21 22
 DESIGNATE_SERVICE_PORT_INT=${DESIGNATE_SERVICE_PORT_INT:-19001}
22 23
 DESIGNATE_SERVICE_PORT_DNS=${DESIGNATE_SERVICE_PORT_DNS:-53}
23 24
 DESIGNATE_SERVICE_PORT_MDNS=${DESIGNATE_SERVICE_PORT_MDNS:-5354}
25
+DESIGNATE_SERVICE_PORT_AGENT=${DESIGNATE_SERVICE_PORT_AGENT:-5358}
24 26
 
25 27
 # Default directories
26 28
 DESIGNATE_BIN_DIR=$(get_python_exec_prefix)
@@ -50,7 +52,6 @@ GITDIR["designate-tempest-plugin"]=$DEST/designate-tempest-plugin
50 52
 TEMPEST_SERVICES+=,designate
51 53
 
52 54
 # Turn on all Designate services by default
53
-
54 55
 enable_service designate
55 56
 enable_service designate-central
56 57
 enable_service designate-api

+ 1
- 3
doc/source/backends.rst View File

@@ -22,6 +22,4 @@ Contents:
22 22
    :maxdepth: 2
23 23
    :glob:
24 24
 
25
-   backends/bind9
26
-   backends/powerdns
27
-   backends/infoblox
25
+   backends/*

+ 46
- 0
doc/source/backends/agent.rst View File

@@ -0,0 +1,46 @@
1
+..
2
+    Copyright 2016 Hewlett Packard Enterprise Development Company LP
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
+Agent Backend
17
+=============
18
+
19
+This page documents using the Pool Manager Agent backend, and it's accompanying
20
+service, `designate-agent`. This backend uses an extension of the DNS protocol
21
+itself to send management requests to the remote agent processes, where the
22
+requests will be actioned.
23
+
24
+The traffic between `designate-pool-manager`, and `designate-agent` is both
25
+unauthenticated and unencrypted. Do not run this traffic over unsecured
26
+networks.
27
+
28
+Designate Configuration
29
+-----------------------
30
+
31
+For each designate-agent running, add a target to the pools.yaml configuration
32
+file, using the following template:
33
+
34
+   .. literalinclude:: sample_yaml_snippets/agent.yaml
35
+       :language: yaml
36
+
37
+Then update the designate pools database using the ``designate-manage pool``
38
+command - see :ref:`designate_manage_pool` for further details on the
39
+``designate-manage pool`` command:
40
+
41
+.. code-block:: console
42
+
43
+    $ designate-manage pool update
44
+
45
+.. TODO: Document how to configure the agent service itself, and the available
46
+   agent backends.

+ 15
- 0
doc/source/backends/sample_yaml_snippets/agent.yaml View File

@@ -0,0 +1,15 @@
1
+  targets:
2
+    - type: agent
3
+      description: Agent Server 1
4
+
5
+      # List out the designate-mdns servers from which Agent servers should
6
+      # request zone transfers (AXFRs) from.
7
+      masters:
8
+        - host: 192.0.2.1
9
+          port: 5354
10
+
11
+      # Agent Configuration options, this should be this targets
12
+      # designate-agent service's host and port.
13
+      options:
14
+        host: 192.0.2.2
15
+        port: 5358

+ 5
- 0
releasenotes/notes/agent-port-number-c28462562a74cbf9.yaml View File

@@ -0,0 +1,5 @@
1
+---
2
+upgrade:
3
+  - The default port which the designate-agent service listens on has changed
4
+    from 53 to 5358. This matches the port we have always used in the sample
5
+    configuration, and the port used in the agent backend class.

Loading…
Cancel
Save