summaryrefslogtreecommitdiff
path: root/devstack/designate_plugins/backend-agent-msdns
blob: c2d047fb674ae15f727dc0437bf6cb0ea3d4a13f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Configure the agent backend

# Enable this pluging by adding these line to local.conf:
#
# DESIGNATE_BACKEND_DRIVER=agent
# DESIGNATE_AGENT_BACKEND_DRIVER=msdns

# Dependencies:
# ``functions`` file
# ``designate`` configuration

# install_designate_agent_backend - install any external requirements
# configure_designate_agent_backend - make configuration changes, including those to other services
# init_designate_agent_backend - initialize databases, etc.
# start_designate_agent_backend - start any external services
# stop_designate_agent_backend - stop any external services
# cleanup_designate_agent_backend - remove transient data and cache

# Save trace setting
DP_AGENT_MSDNS_XTRACE=$(set +o | grep xtrace)
set +o xtrace

# Defaults
# --------

DESIGNATE_MSDNS_MASTERS=${DESIGNATE_MSDNS_MASTERS:-"$DESIGNATE_SERVICE_HOST:$DESIGNATE_SERVICE_PORT_MDNS"}
DESIGNATE_MSDNS_HOST_IP=${DESIGNATE_MSDNS_HOST_IP:-}
DESIGNATE_MSDNS_HOST_PORT=${DESIGNATE_MSDNS_HOST_PORT:-}

# Sanity Checks
# -------------
if [ -z "$DESIGNATE_MSDNS_MASTERS" ]; then
    die $LINENO "You must configure DESIGNATE_MSDNS_MASTERS"
fi

if [ -z "$DESIGNATE_MSDNS_HOST_IP" ]; then
    die $LINENO "You must configure DESIGNATE_MSDNS_HOST_IP with the IP of the MS DNS host"
fi

if [ -z "$DESIGNATE_MSDNS_HOST_PORT" ]; then
    die $LINENO "You must configure DESIGNATE_MSDNS_HOST_PORT with the PORT of the MS DNS host"
fi

if [ "$DESIGNATE_SERVICE_PORT_MDNS" != "53" ]; then
    die $LINENO "Microsoft DNS requires DESIGNATE_SERVICE_PORT_MDNS to be set to '53'"
fi

# Entry Points
# ------------

# install_designate_agent_backend - install any external requirements
function install_designate_agent_backend {
    :
}

# configure_designate_agent_backend - make configuration changes, including those to other services
function configure_designate_agent_backend {
    # Generate Designate pool.yaml file
    sudo tee $DESIGNATE_CONF_DIR/pools.yaml > /dev/null <<EOF
---
- name: default
  description: DevStack MSDNS Pool
  attributes: {}

  ns_records:
    - hostname: $DESIGNATE_DEFAULT_NS_RECORD
      priority: 1

  nameservers:
    - host: $DESIGNATE_MSDNS_HOST_IP
      port: $DESIGNATE_MSDNS_HOST_PORT

  targets:
    - type: agent
      description: MSDNS Agent Instance

      masters:
        - host: $(ipv6_unquote $DESIGNATE_SERVICE_HOST)
          port: $DESIGNATE_SERVICE_PORT_MDNS

      options:
        host: $DESIGNATE_MSDNS_HOST_IP
        port: $DESIGNATE_MSDNS_HOST_PORT
EOF

    echo "# Sample Config for Windows Agent service" | sudo tee ${DESIGNATE_CONF}.win
    echo "# This file should be copied to the Windows DNS server and used as the Designate config file" | sudo tee -a ${DESIGNATE_CONF}.win
    # Configure Agent Settings
    iniset ${DESIGNATE_CONF}.win service:agent backend_driver $DESIGNATE_AGENT_BACKEND_DRIVER
    iniset ${DESIGNATE_CONF}.win service:agent host $DESIGNATE_MSDNS_HOST_IP
    iniset ${DESIGNATE_CONF}.win service:agent port $DESIGNATE_MSDNS_HOST_PORT
    iniset ${DESIGNATE_CONF}.win service:agent masters "$DESIGNATE_MSDNS_MASTERS"
}

# init_designate_agent_backend - initialize databases, etc.
function init_designate_agent_backend {
    :
}

# start_designate_agent_backend - start any external services
function start_designate_agent_backend {
    :
}

# stop_designate_agent_backend - stop any external services
function stop_designate_agent_backend {
    :
}

# cleanup_designate_agent_backend - remove transient data and cache
function cleanup_designate_agent_backend {
    :
}

# Restore xtrace
$DP_AGENT_MSDNS_XTRACE