puppet-tripleo/templates/neutron/keepalived.epp
Brent Eagles 684521fc84 Neutron sidecar wrappers use netns they were invoked with
Neutron uses namespaces with different prefixes depending on
configuration and the nature of the resource. This patch changes the
wrappers to use the "ip netns identify" command to determine the target
namespace for the sidecar instead of trying to guess from the command
line options.

Change-Id: If58bb9dabebf201b592fb450a663ae2f24374e00
Closes-Bug: #1773823
2018-05-29 09:09:23 -02:30

33 lines
1.0 KiB
Plaintext

<%- | String $image_name = '', String $bind_socket = '' | -%>
#!/bin/bash
export DOCKER_HOST="<%=$bind_socket%>"
ARGS="$@"
# Extract the network namespace UUID from the command line args provided by
# neutron. Typically of the form (with dnsmasq as an example):
#
# dnsmasq --no-hosts --no-resolv --except-interface=lo \
# --pid-file=/var/lib/neutron/dhcp/317716b8-919a-4a6f-8db1-78128ec3b100/pid \
# --dhcp-hostsfile=/var/lib/neutron/dhcp/317716b8-919a-4a6f-8db1-78128ec3b100/host ...
NETNS=$(ip netns identify)
NAME=neutron-keepalived-${NETNS}
docker stop $NAME || true
docker rm -f $NAME || true
docker run --detach \
-v /var/lib/config-data/puppet-generated/neutron/etc/neutron:/etc/neutron:ro \
-v /lib/modules:/lib/modules:ro \
-v /sbin/modprobe:/sbin/modprobe:ro \
-v /run/netns:/run/netns:shared \
-v /var/lib/neutron:/var/lib/neutron \
--net host \
--pid host \
--privileged \
--rm=true \
-u root \
--name $NAME \
<%=$image_name%> \
ip netns exec ${NETNS} /usr/sbin/keepalived -n -l -D $ARGS