kolla-ansible/docker/neutron/neutron-agents/config-scripts/config-l3-agent.sh
Daneyon Hansen 17fc2d9b47 Removes existing network namespaces for neutron-agents container
Previously, network namespaces would not work correctly when
restarting or stop/rm/start the neutron-agents container. This
is because network namespaces created within the container are
associated to the container's pid: /pid/$CONTAINER_PID/ns/net.
With this patch, when a container starts or restarts, the l3/dhcp
agent start scripts will remove any existing qrouter/qdhcp network
namespaces before starting the agents. The agents will recreate the
necessary network namespaces since they are stored in the db.

Closes-Bug: 1444219

Change-Id: Ia86729766fe8c2fc145b3a02d519746b149a73bb
2015-04-21 07:50:48 +00:00

86 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
set -e
. /opt/kolla/config-neutron.sh
. /opt/kolla/config-sudoers.sh
: ${USE_NAMESPACES:=true}
check_required_vars VERBOSE_LOGGING DEBUG_LOGGING
cfg=/etc/neutron/l3_agent.ini
neutron_conf=/etc/neutron/neutron.conf
# Logging
crudini --set $neutron_conf \
DEFAULT \
log_file \
"${NEUTRON_L3_AGENT_LOG_FILE}"
# Configure l3_agent.ini
crudini --set $cfg \
DEFAULT \
verbose \
"${VERBOSE_LOGGING}"
crudini --set $cfg \
DEFAULT \
debug \
"${DEBUG_LOGGING}"
if [[ "${MECHANISM_DRIVERS}" =~ linuxbridge ]] ; then
crudini --set $cfg \
DEFAULT \
interface_driver \
"neutron.agent.linux.interface.BridgeInterfaceDriver"
crudini --set $cfg \
DEFAULT \
gateway_external_network_id \
""
crudini --set $cfg \
DEFAULT \
external_network_bridge \
""
elif [[ "${MECHANISM_DRIVERS}" =~ .*openvswitch* ]] ; then
crudini --set $cfg \
DEFAULT \
interface_driver \
"neutron.agent.linux.interface.OVSInterfaceDriver"
crudini --set $cfg \
DEFAULT \
gateway_external_network_id \
"${NEUTRON_FLAT_NETWORK_BRIDGE}"
crudini --set $cfg \
DEFAULT \
external_network_bridge \
"${NEUTRON_FLAT_NETWORK_BRIDGE}"
fi
crudini --set $cfg \
DEFAULT \
use_namespaces \
"${USE_NAMESPACES}"
if [ "${USE_NAMESPACES}" == "false" ] ; then
source /openrc
# Create router if it does not exist
/usr/bin/neutron router-list | grep admin-router || /usr/bin/neutron router-create admin-router
# Set router-id
crudini --set $cfg \
DEFAULT \
router_id \
"$(/usr/bin/neutron router-list | awk '/ admin-router / {print $2}')"
elif [ "${USE_NAMESPACES}" == "true" ] ; then
crudini --set $cfg \
DEFAULT \
router_delete_namespaces \
"true"
fi
# Remove any existing qrouter namespaces
ip netns list | grep qrouter | while read -r line ; do
ip netns delete $line
done
# Start L3 Agent
exec /usr/bin/neutron-l3-agent --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/l3_agent.ini --config-file /etc/neutron/fwaas_driver.ini