File: octavia-agent-netns-start

package info (click to toggle)
octavia 17.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,252 kB
  • sloc: python: 99,849; sh: 2,458; pascal: 450; makefile: 116; ruby: 18
file content (41 lines) | stat: -rwxr-xr-x 1,458 bytes parent folder | download | duplicates (2)
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
#!/bin/sh

set -e
set -x

# Re-add the namespace
ip netns add amphora-haproxy || true

# Load the system sysctl into the new namespace
ip netns exec amphora-haproxy sysctl --system

# Enable kernel module ip_vs for lvs function in amphora network namespace
ip netns exec amphora-haproxy modprobe ip_vs

# Enable ip_forward and conntrack kernel configuration
ip netns exec amphora-haproxy sysctl -w net.ipv4.ip_forward=1
ip netns exec amphora-haproxy sysctl -w net.ipv4.vs.conntrack=1
ip netns exec amphora-haproxy sysctl -w net.ipv6.conf.all.forwarding=1

# Wait until /var/lib/octavia/plugged_interfaces appears
TIMESTAMP_TIMEOUT=$(date -d "now + 5 min" +%s)
while [ ! -f /var/lib/octavia/plugged_interfaces ]  && [ $(date +%s) -lt "${TIMESTAMP_TIMEOUT}" ] ; do
	sleep 2
done
if [ ! -f /var/lib/octavia/plugged_interfaces ] ; then
	exit 1
fi

# We need the plugged_interfaces file sorted to join the host interfaces
/usr/bin/sort -k 1 /var/lib/octavia/plugged_interfaces > /var/lib/octavia/plugged_interfaces.sorted

# Assign the interfaces into the namespace with the appropriate name
ip link | awk '{getline n; print $0,n}' \
	| awk '{sub(":","",$2)} { for(i=1;i<=NF;i++) if ($i == "link/ether") {print $(i+1) " " $2} }' \
	| sort -k 1 | join -j 1 - /var/lib/octavia/plugged_interfaces.sorted \
	| awk '{system("ip link set "$2" netns amphora-haproxy name "$3"")}'

# Bring up all of the namespace interfaces
ip netns exec amphora-haproxy ifup -a

exit 0