summaryrefslogtreecommitdiffstats
path: root/lib/container/start
diff options
context:
space:
mode:
authorNik Lutz <nik@netstyle.ch>2016-05-18 16:20:33 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-05-18 18:26:07 +0000
commitcfe08b9c7149a5dc1b70d665ce918cede8e484ba (patch)
tree32a7d9edee28eed1874ce1374235749dcbfc0137 /lib/container/start
parentUsing eth[0-9] instead of host[0-9] in containers /etc/network/interface. (diff)
downloadcompute-tools-cfe08b9c7149a5dc1b70d665ce918cede8e484ba.tar.xz
compute-tools-cfe08b9c7149a5dc1b70d665ce918cede8e484ba.zip
Replacing systemd-nspawn '--network-bridge=' with one config file per interface in /etc/network/interfaces.d.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to '')
-rwxr-xr-xlib/container/start32
1 files changed, 26 insertions, 6 deletions
diff --git a/lib/container/start b/lib/container/start
index fa717dd..112ee9b 100755
--- a/lib/container/start
+++ b/lib/container/start
@@ -185,15 +185,34 @@ then
MACHINE="--machine=${NAME}"
- NETWORK_BRIDGE="$(awk -F= '/^network-bridge=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+ NETWORK_BRIDGES="$(awk -F= '/^cnt.network-bridge=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
- case "${NETWORK_BRIDGE}" in
+ case "${NETWORK_BRIDGES}" in
"")
- NETWORK_BRIDGE=""
;;
*)
- NETWORK_BRIDGE="--network-bridge=${NETWORK_BRIDGE}"
+ for BRIDGE_DEFINITION in ${NETWORK_BRIDGES}
+ do
+ INTERFACE="$(echo ${BRIDGE_DEFINITION} | awk -F: '{ print $1 }')"
+ BRIDGE="$(echo ${BRIDGE_DEFINITION} | awk -F: '{ print $2 }')"
+
+ if [ -n "${BRIDGE}" ] && [ -n "${INTERFACE}" ]
+ then
+
+cat > "/etc/network/interfaces.d/${INTERFACE}" << EOF
+allow-hotplug ${INTERFACE}
+iface ${INTERFACE} inet manual
+ pre-up ifconfig ${INTERFACE} up
+ post-up brctl addif ${BRIDGE} ${INTERFACE}
+ pre-down brctl delif ${BRIDGE} ${INTERFACE}
+ post-down ifconfig ${INTERFACE} down
+EOF
+
+ else
+ echo "'${BRIDGE_DEFINITION}': no such devices, ignoring" >&2
+ fi
+ done
;;
esac
@@ -211,6 +230,7 @@ then
INTERFACE="$(echo ${VETH} | awk -F: '{ print $1 }')"
cat > "/etc/network/interfaces.d/${INTERFACE}" << EOF
+allow-hotplug ${INTERFACE}
iface ${INTERFACE} inet manual
pre-up ifconfig ${INTERFACE} up
post-down ifconfig ${INTERFACE} down
@@ -312,11 +332,11 @@ fi
# Run
case "${SET_PROPERTY}" in
true)
- ${SETARCH} systemd-nspawn ${BIND} ${BOOT} ${CAPABILITY} ${DIRECTORY} ${DROP_CAPABILITY} ${MACHINE} ${NETWORK_BRIDGE} ${NETWORK_VETH_EXTRA} ${LINK_JOURNAL} ${REGISTER} & \
+ ${SETARCH} systemd-nspawn ${BIND} ${BOOT} ${CAPABILITY} ${DIRECTORY} ${DROP_CAPABILITY} ${MACHINE} ${NETWORK_VETH_EXTRA} ${LINK_JOURNAL} ${REGISTER} & \
systemctl --runtime set-property ${NAME} ${BLOCK_IO_DEVICE_WEIGHT} ${BLOCK_IO_READ_BANDWITH} ${BLOCK_IO_WEIGHT} ${BLOCK_IO_WRITE_BANDWITH} ${CPU_QUOTA} ${CPU_SHARES} ${MEMORY_LIMIT} ${TASKS_MAX}
;;
*)
- ${SETARCH} systemd-nspawn ${BIND} ${BOOT} ${CAPABILITY} ${DIRECTORY} ${DROP_CAPABILITY} ${MACHINE} ${NETWORK_BRIDGE} ${NETWORK_VETH_EXTRA} ${LINK_JOURNAL} ${REGISTER}
+ ${SETARCH} systemd-nspawn ${BIND} ${BOOT} ${CAPABILITY} ${DIRECTORY} ${DROP_CAPABILITY} ${MACHINE} ${NETWORK_VETH_EXTRA} ${LINK_JOURNAL} ${REGISTER}
;;
esac