Pool Manager - Pool Manager Proxy Backend and Devstack
- Implemented a pool manager proxy traditional backend - Incorporated pool manager into Devstack - Changed pool_name to pool_id in [service:pool_manager] To use pool manager in Devstack add to the localrc: ENABLED_SERVICES+=,designate-pool-manager DESIGNATE_BACKEND_DRIVER=bind9_pool Change-Id: I66b81e30067c7c5ff4f1d7c8fd2eecc3b0a3012c Partially-implements: blueprint server-pools-service
This commit is contained in:
parent
3fee11ddd2
commit
75986db67f
@ -2,7 +2,7 @@
|
||||
# Install and start **Designate** service
|
||||
|
||||
# To enable Designate services, add the following to localrc
|
||||
# enable_service designate,designate-api,designate-central,designate-mdns,designate-agent,designate-sink
|
||||
# enable_service designate,designate-api,designate-central,designate-mdns,designate-agent,designate-sink,designate-pool-manager
|
||||
|
||||
# stack.sh
|
||||
# ---------
|
||||
@ -42,6 +42,8 @@ DESIGNATE_APIPASTE_CONF=$DESIGNATE_CONF_DIR/api-paste.ini
|
||||
|
||||
# Set up default options
|
||||
DESIGNATE_BACKEND_DRIVER=${DESIGNATE_BACKEND_DRIVER:=powerdns}
|
||||
DESIGNATE_POOL_ID=${DESIGNATE_POOL_ID:-794ccc2c-d751-44fe-b57f-8894c9f5c842}
|
||||
DESIGNATE_SERVER_ID=${DESIGNATE_SERVER_ID:-f26e0b32-736f-4f0a-831b-039a415c481e}
|
||||
|
||||
# Public IP/Port Settings
|
||||
DESIGNATE_SERVICE_HOST=${DESIGNATE_SERVICE_HOST:-$SERVICE_HOST}
|
||||
@ -206,6 +208,10 @@ function configure_designate {
|
||||
if is_service_enabled designate-agent; then
|
||||
iniset $DESIGNATE_CONF service:central backend_driver rpc
|
||||
iniset $DESIGNATE_CONF service:agent backend_driver $DESIGNATE_BACKEND_DRIVER
|
||||
elif is_service_enabled designate-pool-manager; then
|
||||
iniset $DESIGNATE_CONF service:central backend_driver pool_manager_proxy
|
||||
iniset $DESIGNATE_CONF service:pool_manager pool_id $DESIGNATE_POOL_ID
|
||||
iniset $DESIGNATE_CONF pool_manager_cache:sqlalchemy connection `database_connection_url designate_pool_manager`
|
||||
else
|
||||
iniset $DESIGNATE_CONF service:central backend_driver $DESIGNATE_BACKEND_DRIVER
|
||||
fi
|
||||
@ -272,6 +278,15 @@ function init_designate {
|
||||
# Init and migrate designate database
|
||||
designate-manage database sync
|
||||
|
||||
if is_service_enabled designate-pool-manager; then
|
||||
|
||||
# (Re)create designate_pool_manager cache
|
||||
recreate_database designate_pool_manager utf8
|
||||
|
||||
# Init and migrate designate pool-manager-cache
|
||||
designate-manage pool-manager-cache sync
|
||||
fi
|
||||
|
||||
init_designate_backend
|
||||
}
|
||||
|
||||
@ -313,6 +328,7 @@ function start_designate {
|
||||
run_process designate-mdns "$DESIGNATE_BIN_DIR/designate-mdns --config-file $DESIGNATE_CONF"
|
||||
run_process designate-agent "$DESIGNATE_BIN_DIR/designate-agent --config-file $DESIGNATE_CONF"
|
||||
run_process designate-sink "$DESIGNATE_BIN_DIR/designate-sink --config-file $DESIGNATE_CONF"
|
||||
run_process designate-pool-manager "$DESIGNATE_BIN_DIR/designate-pool-manager --config-file $DESIGNATE_CONF"
|
||||
|
||||
# Start proxies if enabled
|
||||
if is_service_enabled designate-api && is_service_enabled tls-proxy; then
|
||||
@ -332,6 +348,7 @@ function stop_designate {
|
||||
stop_process designate-mdns
|
||||
stop_process designate-agent
|
||||
stop_process designate-sink
|
||||
stop_process designate-pool-manager
|
||||
|
||||
stop_designate_backend
|
||||
}
|
||||
|
184
contrib/devstack/lib/designate_plugins/backend-bind9_pool
Normal file
184
contrib/devstack/lib/designate_plugins/backend-bind9_pool
Normal file
@ -0,0 +1,184 @@
|
||||
# lib/designate_plugins/backend-bind9-pool
|
||||
# Configure the bind9 pool backend
|
||||
|
||||
# Enable with:
|
||||
# DESIGNATE_BACKEND_DRIVER=bind9-pool
|
||||
|
||||
# Dependencies:
|
||||
# ``functions`` file
|
||||
# ``designate`` configuration
|
||||
|
||||
# install_designate_backend - install any external requirements
|
||||
# configure_designate_backend - make configuration changes, including those to other services
|
||||
# init_designate_backend - initialize databases, etc.
|
||||
# start_designate_backend - start any external services
|
||||
# stop_designate_backend - stop any external services
|
||||
# cleanup_designate_backend - remove transient data and cache
|
||||
|
||||
# Save trace setting
|
||||
DP_BIND9_XTRACE=$(set +o | grep xtrace)
|
||||
set +o xtrace
|
||||
|
||||
# Defaults
|
||||
# --------
|
||||
BIND_SERVICE_NAME=bind9
|
||||
BIND_CFG_DIR=/etc/bind
|
||||
BIND_VAR_DIR=/var/cache/bind
|
||||
BIND_CFG_FILE=$BIND_CFG_DIR/named.conf.options
|
||||
BIND_USER=bind
|
||||
BIND_GROUP=bind
|
||||
|
||||
if is_fedora; then
|
||||
BIND_SERVICE_NAME=named
|
||||
BIND_CFG_DIR=/etc/named
|
||||
BIND_CFG_FILE=/etc/named.conf
|
||||
BIND_VAR_DIR=/var/named
|
||||
BIND_USER=named
|
||||
BIND_GROUP=named
|
||||
fi
|
||||
|
||||
# Local functions
|
||||
#----------------
|
||||
# Set an option in an INI file
|
||||
# wildcard_iniset config-file section option value
|
||||
#
|
||||
# This function is needed to handle sections that have a wildcard in them.
|
||||
function wildcard_iniset {
|
||||
local xtrace=$(set +o | grep xtrace)
|
||||
set +o xtrace
|
||||
local file=$1
|
||||
local section=$2
|
||||
local option=$3
|
||||
local value=$4
|
||||
|
||||
[[ -z $section || -z $option ]] && return
|
||||
|
||||
if ! grep -q "^\[$section\]" "$file" 2>/dev/null; then
|
||||
eval wildcardless_section=$section
|
||||
# Add section at the end
|
||||
echo -e "\n[$wildcardless_section]" >>"$file"
|
||||
fi
|
||||
if ! ini_has_option "$file" "$section" "$option"; then
|
||||
# Add it
|
||||
sed -i -e "/^\[$section\]/ a\\
|
||||
$option = $value
|
||||
" "$file"
|
||||
else
|
||||
local sep=$(echo -ne "\x01")
|
||||
# Replace it
|
||||
sed -i -e '/^\['${section}'\]/,/^\[.*\]/ s'${sep}'^\('${option}'[ \t]*=[ \t]*\).*$'${sep}'\1'"${value}"${sep} "$file"
|
||||
fi
|
||||
$xtrace
|
||||
}
|
||||
|
||||
# Entry Points
|
||||
# ------------
|
||||
|
||||
# install_designate_backend - install any external requirements
|
||||
function install_designate_backend {
|
||||
if is_ubuntu; then
|
||||
install_package bind9
|
||||
elif is_fedora; then
|
||||
install_package named
|
||||
fi
|
||||
|
||||
# The user that designate runs as needs to be member of **$BIND_GROUP** group.
|
||||
# The designate bind9 backend needs read/write access to $BIND_VAR_DIR
|
||||
if ! getent group $BIND_GROUP >/dev/null; then
|
||||
sudo groupadd $BIND_GROUP
|
||||
fi
|
||||
add_user_to_group $STACK_USER $BIND_GROUP
|
||||
if [[ ! -d $BIND_CFG_DIR ]]; then
|
||||
sudo mkdir -p $BIND_CFG_DIR
|
||||
sudo chown $BIND_USER:$BIND_GROUP $BIND_CFG_DIR
|
||||
fi
|
||||
|
||||
sudo chown -R $BIND_USER:$BIND_GROUP $BIND_CFG_DIR $BIND_VAR_DIR
|
||||
sudo chmod -R g+r $BIND_CFG_DIR
|
||||
sudo chmod -R g+rw $BIND_VAR_DIR
|
||||
|
||||
# Customize Bind9 apparmor profile if installed
|
||||
if [[ -d /etc/apparmor.d ]]; then
|
||||
sudo tee /etc/apparmor.d/local/usr.sbin.named > /dev/null << EOF
|
||||
$DESIGNATE_STATE_PATH/bind9/** rw,
|
||||
EOF
|
||||
restart_service apparmor
|
||||
fi
|
||||
}
|
||||
|
||||
# configure_designate_backend - make configuration changes, including those to other services
|
||||
function configure_designate_backend {
|
||||
wildcard_iniset $DESIGNATE_CONF backend:bind9_pool:\\\* masters $DESIGNATE_SERVICE_HOST:$DESIGNATE_MDNS_PORT
|
||||
wildcard_iniset $DESIGNATE_CONF backend:bind9_pool:\\\* rndc_port 953
|
||||
wildcard_iniset $DESIGNATE_CONF backend:bind9_pool:\\\* rndc_host $DESIGNATE_SERVICE_HOST
|
||||
wildcard_iniset $DESIGNATE_CONF backend:bind9_pool:\\\* rndc_config_file "$BIND_CFG_DIR/rndc.conf"
|
||||
wildcard_iniset $DESIGNATE_CONF backend:bind9_pool:\\\* rndc_key_file "$BIND_CFG_DIR/rndc.key"
|
||||
|
||||
iniset $DESIGNATE_CONF backend:bind9_pool:$DESIGNATE_SERVER_ID host $DESIGNATE_SERVICE_HOST
|
||||
iniset $DESIGNATE_CONF backend:bind9_pool:$DESIGNATE_SERVER_ID port 53
|
||||
|
||||
sudo chown $STACK_USER $BIND_CFG_DIR
|
||||
|
||||
# create rndc key and config
|
||||
sudo rndc-confgen -a -c $BIND_CFG_DIR/rndc.key
|
||||
sudo chown $BIND_USER:$BIND_GROUP $BIND_CFG_DIR/rndc.key
|
||||
sudo chmod g+r $BIND_CFG_DIR/rndc.key
|
||||
|
||||
# Configure Bind
|
||||
sudo tee $BIND_CFG_FILE > /dev/null <<EOF
|
||||
include "$BIND_CFG_DIR/rndc.key";
|
||||
|
||||
options {
|
||||
directory "$BIND_VAR_DIR";
|
||||
allow-new-zones yes;
|
||||
dnssec-validation auto;
|
||||
auth-nxdomain no; # conform to RFC1035
|
||||
listen-on port $DESIGNATE_SERVICE_PORT_DNS { $DESIGNATE_SERVICE_HOST; };
|
||||
};
|
||||
|
||||
controls {
|
||||
inet $DESIGNATE_SERVICE_HOST allow { $DESIGNATE_SERVICE_HOST; } keys { "rndc-key"; };
|
||||
};
|
||||
EOF
|
||||
|
||||
# Configure RNDC
|
||||
sudo tee $BIND_CFG_DIR/rndc.conf > /dev/null << EOF
|
||||
include "$BIND_CFG_DIR/rndc.key";
|
||||
|
||||
options {
|
||||
default-key "rndc-key";
|
||||
default-server $DESIGNATE_SERVICE_HOST;
|
||||
default-port 953;
|
||||
};
|
||||
EOF
|
||||
|
||||
sudo chown $BIND_USER:$BIND_GROUP $BIND_CFG_FILE $BIND_CFG_DIR/rndc.conf
|
||||
sudo chmod g+r $BIND_CFG_FILE $BIND_CFG_DIR/rndc.conf
|
||||
|
||||
restart_service $BIND_SERVICE_NAME
|
||||
}
|
||||
|
||||
# init_designate_backend - initialize databases, etc.
|
||||
function init_designate_backend {
|
||||
:
|
||||
}
|
||||
|
||||
# start_designate_backend - start any external services
|
||||
function start_designate_backend {
|
||||
start_service bind9
|
||||
}
|
||||
|
||||
# stop_designate_backend - stop any external services
|
||||
function stop_designate_backend {
|
||||
stop_service bind9
|
||||
}
|
||||
|
||||
# cleanup_designate_backend - remove transient data and cache
|
||||
function cleanup_designate_backend {
|
||||
sudo sh -c "rm -rf $BIND_VAR_DIR/*.nzf"
|
||||
sudo sh -c "rm -rf $BIND_VAR_DIR/slave.*"
|
||||
sudo rm -f $BIND_CFG_DIR/rndc.key
|
||||
}
|
||||
|
||||
# Restore xtrace
|
||||
$DP_BIND9_XTRACE
|
99
designate/backend/impl_pool_manager_proxy.py
Normal file
99
designate/backend/impl_pool_manager_proxy.py
Normal file
@ -0,0 +1,99 @@
|
||||
# Copyright 2014 eBay Inc.
|
||||
#
|
||||
# Author: Ron Rickard <rrickard@ebaysf.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from designate.openstack.common import log as logging
|
||||
from designate.backend import base
|
||||
from designate.pool_manager import rpcapi as pool_manager_rpcapi
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
POOL_MANAGER_API = None
|
||||
|
||||
|
||||
def get_pool_manager_api():
|
||||
"""
|
||||
The rpc.get_client() which is called upon the API object initialization
|
||||
will cause a assertion error if the designate.rpc.TRANSPORT isn't setup by
|
||||
rpc.init() before.
|
||||
|
||||
This fixes that by creating the rpcapi when demanded.
|
||||
"""
|
||||
global POOL_MANAGER_API
|
||||
if not POOL_MANAGER_API:
|
||||
POOL_MANAGER_API = pool_manager_rpcapi.PoolManagerAPI()
|
||||
return POOL_MANAGER_API
|
||||
|
||||
|
||||
class PoolManagerProxyBackend(base.Backend):
|
||||
__plugin_name__ = 'pool_manager_proxy'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(PoolManagerProxyBackend, self).__init__(*args, **kwargs)
|
||||
self.pool_manager = get_pool_manager_api()
|
||||
|
||||
def create_server(self, context, server):
|
||||
LOG.debug('Create Server')
|
||||
domains = self.central_service.find_domains(self.admin_context)
|
||||
for domain in domains:
|
||||
self.pool_manager.update_domain(context, domain)
|
||||
|
||||
def update_server(self, context, server):
|
||||
LOG.debug('Update Server')
|
||||
domains = self.central_service.find_domains(self.admin_context)
|
||||
for domain in domains:
|
||||
self.pool_manager.update_domain(context, domain)
|
||||
|
||||
def delete_server(self, context, server):
|
||||
LOG.debug('Delete Server')
|
||||
domains = self.central_service.find_domains(self.admin_context)
|
||||
for domain in domains:
|
||||
self.pool_manager.update_domain(context, domain)
|
||||
|
||||
def create_domain(self, context, domain):
|
||||
LOG.debug('Create Domain')
|
||||
self.pool_manager.create_domain(context, domain)
|
||||
|
||||
def update_domain(self, context, domain):
|
||||
LOG.debug('Update Domain')
|
||||
self.pool_manager.update_domain(context, domain)
|
||||
|
||||
def delete_domain(self, context, domain):
|
||||
LOG.debug('Delete Domain')
|
||||
self.pool_manager.delete_domain(context, domain)
|
||||
|
||||
def create_recordset(self, context, domain, recordset):
|
||||
LOG.debug('Create RecordSet')
|
||||
self.pool_manager.update_domain(context, domain)
|
||||
|
||||
def update_recordset(self, context, domain, recordset):
|
||||
LOG.debug('Update RecordSet')
|
||||
self.pool_manager.update_domain(context, domain)
|
||||
|
||||
def delete_recordset(self, context, domain, recordset):
|
||||
LOG.debug('Delete RecordSet')
|
||||
self.pool_manager.update_domain(context, domain)
|
||||
|
||||
def create_record(self, context, domain, recordset, record):
|
||||
LOG.debug('Create Record')
|
||||
self.pool_manager.update_domain(context, domain)
|
||||
|
||||
def update_record(self, context, domain, recordset, record):
|
||||
LOG.debug('Update Record')
|
||||
self.pool_manager.update_domain(context, domain)
|
||||
|
||||
def delete_record(self, context, domain, recordset, record):
|
||||
LOG.debug('Delete Record')
|
||||
self.pool_manager.update_domain(context, domain)
|
@ -22,8 +22,8 @@ cfg.CONF.register_group(cfg.OptGroup(
|
||||
OPTS = [
|
||||
cfg.IntOpt('workers', default=None,
|
||||
help='Number of Pool Manager worker processes to spawn'),
|
||||
cfg.StrOpt('pool-name', default='default',
|
||||
help='The name of the pool managed by this instance of the '
|
||||
cfg.StrOpt('pool-id', default='default',
|
||||
help='The ID of the pool managed by this instance of the '
|
||||
'Pool Manager'),
|
||||
cfg.IntOpt('threshold-percentage', default=100,
|
||||
help='The percentage of servers requiring a successful update '
|
||||
|
@ -78,6 +78,7 @@ designate.backend =
|
||||
multi = designate.backend.impl_multi:MultiBackend
|
||||
dynect = designate.backend.impl_dynect:DynECTBackend
|
||||
ipa = designate.backend.impl_ipa:IPABackend
|
||||
pool_manager_proxy = designate.backend.impl_pool_manager_proxy:PoolManagerProxyBackend
|
||||
|
||||
designate.network_api =
|
||||
fake = designate.network_api.fake:FakeNetworkAPI
|
||||
|
Loading…
Reference in New Issue
Block a user