Add designate-sink service

Container for Designate Sink, automatic domain creation for
enabled notification handlers (nova and/or neutron).

Change-Id: I41118cb149e7f39a17bff49123d82905b51b7939
Blueprint: designate-container
This commit is contained in:
Michal Rostecki 2015-06-08 20:22:53 +02:00
parent 04f3223ec7
commit 1420d63c7f
7 changed files with 117 additions and 0 deletions

View File

@ -52,3 +52,14 @@ designatemdns:
restart: always
env_file:
- openstack.env
# The Sink service gets notifications from the message queue about events like
# instance creation/deletion or floating IP association/disassociation.
# It then creates records for instances included in events.
designatesink:
image: kollaglue/centos-rdo-designate-sink:latest
name: designate-sink
net: "host"
restart: always
env_file:
- openstack.env

View File

@ -4,6 +4,23 @@ set -e
. /opt/kolla/kolla-common.sh
get_or_create_domain() {
local DOMAIN_NAME=$1
DOMAIN_ID=$(designate domain-create --name $DOMAIN_NAME | awk '/id/ { print $4; }')
# Searching domain if not created
if [ -z $DOMAIN_ID ]; then
DOMAIN_ID=$(designate domain-list | awk "/$DOMAIN_NAME/ { print \$2; }")
fi
# Fail if domain still don't exist
if [ -z $DOMAIN_ID ]; then
echo "Creating domain failed" 1>&2
exit 1
fi
echo $DOMAIN_ID
}
check_required_vars DESIGNATE_DB_PASSWORD DESIGNATE_KEYSTONE_PASSWORD \
KEYSTONE_PUBLIC_SERVICE_HOST RABBITMQ_SERVICE_HOST \
DESIGNATE_BIND9_RNDC_KEY DESIGNATE_BACKEND \

View File

@ -0,0 +1,11 @@
FROM %%KOLLA_NAMESPACE%%/%%KOLLA_PREFIX%%designate-base:%%KOLLA_TAG%%
MAINTAINER Kolla Project (https://launchpad.net/kolla)
RUN yum install -y \
openstack-designate-sink \
python-designateclient \
&& yum clean all
COPY start.sh /start.sh
CMD ["/start.sh"]

View File

@ -0,0 +1 @@
../../../../../tools/build-docker-image

View File

@ -0,0 +1,64 @@
#!/bin/bash
set -e
. /opt/kolla/kolla-common.sh
. /opt/kolla/config-designate.sh
CONF=/etc/designate/designate.conf
configure_nova_handler() {
local DOMAIN_ID=$1
crudini --set $CONF handler:nova_fixed domain_id "$DOMAIN_ID"
crudini --set $CONF handler:nova_fixed notification_topics "notifications"
crudini --set $CONF handler:nova_fixed control_exchange "nova"
# Configuring multiple record formats
for FORMAT in $DESIGNATE_SINK_NOVA_FORMATS; do
crudini --set $CONF handler:nova_fixed format "$FORMAT"
done
}
configure_neutron_handler() {
local DOMAIN_ID=$1
crudini --set $CONF handler:neutron_floatingip domain_id "$DOMAIN_ID"
crudini --set $CONF handler:neutron_floatingip notification_topics "notifications"
crudini --set $CONF handler:neutron_floatingip control_exchange "neutron"
# Configuring multiple record formats
for FORMAT in $DESIGNATE_SINK_NEUTRON_FORMATS; do
crudini --set $CONF handler:neutron_floatingip format "$FORMAT"
done
}
check_required_vars DESIGNATE_API_SERVICE_HOST DESIGNATE_API_SERVICE_PORT \
DESIGNATE_DEFAULT_POOL_NS_RECORD
check_for_os_service_endpoint designate DESIGNATE_API_SERVICE_HOST DESIGNATE_API_SERVICE_PORT || exit $?
if [ -z "$DESIGNATE_SINK_NOVA_DOMAIN_NAME" && -z "$DESIGNATE_SINK_NEUTRON_DOMAIN_NAME" ]; then
echo "Please specify either Nova or Neutron domain name for Designate Sink"
exit 1
fi
designate server-create --name ${DESIGNATE_DEFAULT_POOL_NS_RECORD}
if [ $? != 0 ]; then
echo "Creating server failed" 1>&2
exit 1
fi
if [ -n "$DESIGNATE_SINK_NOVA_DOMAIN_NAME" ]; then
NOVA_DOMAIN_ID=$(get_or_create_domain $DESIGNATE_SINK_NOVA_DOMAIN_NAME)
configure_nova_handler $NOVA_DOMAIN_ID
HANDLERS="nova_fixed"
fi
if [ -n "$DESIGNATE_SINK_NEUTRON_DOMAIN_NAME" ]; then
NEUTRON_DOMAIN_ID=$(get_or_create_domain $DESIGNATE_SINK_NEUTRON_DOMAIN_NAME)
configure_neutron_handler $NEUTRON_DOMAIN_ID
[ -n "$HANDLERS" ] && HANDLERS+=","
HANDLERS+="neutron_floatingip"
fi
crudini --set $CONF service:sink enabled_notification_handlers "$HANDLERS"
exec /usr/bin/designate-sink

View File

@ -137,6 +137,11 @@ all containers. This allows a simple method of ensuring every type of node
DESIGNATE_DNS_PORT=<53> - The port of the Designate-backed DNS slaves that are used by the world
DESIGNATE_INITDB=<true|false> - Configures if the database should be created and initialised
DESIGNATE_ALLOW_RECURSION=<true|false> - Configure a recursive nameserver
DESIGNATE_DEFAULT_POOL_NS_RECORD=<ns1.example.org.> - Name of server used to generate NS records
DESIGNATE_SINK_NOVA_DOMAIN_NAME=<nova.example.org.> - Name of domain used to create records from Nova notifications
DESIGNATE_SINK_NEUTRON_DOMAIN_NAME=<neutron.example.org.> - Name of domain used to create records from Neutron notifications
DESIGNATE_SINK_NOVA_FORMATS=<("%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(domain)s" "%(hostname)s.%(domain)s")> - List of formats for records that will be created by Nova handler
DESIGNATE_SINK_NEUTRON_FORMATS=<("%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(domain)s" "%(hostname)s.%(domain)s")> - List of formats for records that will be created by Neutron handler
[Minimum environment variable setup guide.](https://github.com/stackforge/kolla/blob/master/docs/minimal-environment-vars.md)

View File

@ -151,6 +151,11 @@ DESIGNATE_POOLMAN_TARGETS=$(uuidgen)
DESIGNATE_POOLMAN_NSS=$(uuidgen)
DESIGNATE_INITDB=true
DESIGNATE_ALLOW_RECURSION=true
DESIGNATE_DEFAULT_POOL_NS_RECORD=ns1.example.org.
DESIGNATE_SINK_NOVA_DOMAIN_NAME=nova.example.org.
DESIGNATE_SINK_NEUTRON_DOMAIN_NAME=neutron.example.org.
DESIGNATE_SINK_NOVA_FORMATS=("%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(domain)s" "%(hostname)s.%(domain)s")
DESIGNATE_SINK_NEUTRON_FORMATS=("%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(domain)s" "%(hostname)s.%(domain)s")
cat > ./openrc <<EOF
export OS_AUTH_URL="http://${KEYSTONE_PUBLIC_SERVICE_HOST}:5000/v2.0"
@ -260,6 +265,9 @@ DESIGNATE_POOLMAN_TARGETS=$DESIGNATE_POOLMAN_TARGETS
DESIGNATE_POOLMAN_NSS=$DESIGNATE_POOLMAN_NSS
DESIGNATE_INITDB=$DESIGNATE_INITDB
DESIGNATE_ALLOW_RECURSION=$DESIGNATE_ALLOW_RECURSION
DESIGNATE_DEFAULT_POOL_NS_RECORD=$DESIGNATE_DEFAULT_POOL_NS_RECORD
DESIGNATE_SINK_NOVA_DOMAIN_NAME=$DESIGNATE_SINK_NOVA_DOMAIN_NAME
DESIGNATE_SINK_NEUTRON_DOMAIN_NAME=$DESIGNATE_SINK_NEUTRON_DOMAIN_NAME
DB_CLUSTER_BIND_ADDRESS=$DB_CLUSTER_BIND_ADDRESS
DB_CLUSTER_INIT_DB=$DB_CLUSTER_INIT_DB
DB_CLUSTER_NAME=$DB_CLUSTER_NAME