summaryrefslogtreecommitdiffstats
path: root/libexec/container
diff options
context:
space:
mode:
authorSimon Spöhel <simon@spoehel.ch>2021-06-29 11:52:59 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2021-06-29 11:55:27 +0000
commit3ff612915d66026030db5a0feabcc0aa19cb8ef2 (patch)
treea2edd58d791c4d7dbe3fe5262266dc534807a140 /libexec/container
parentReleasing version 20210628. (diff)
downloadcompute-tools-3ff612915d66026030db5a0feabcc0aa19cb8ef2.tar.xz
compute-tools-3ff612915d66026030db5a0feabcc0aa19cb8ef2.zip
Using openvswitch instead of linux bridges.
Signed-off-by: Simon Spöhel <simon@spoehel.ch> Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to '')
-rwxr-xr-xlibexec/container/start68
-rwxr-xr-xlibexec/container/stop6
2 files changed, 38 insertions, 36 deletions
diff --git a/libexec/container/start b/libexec/container/start
index 08c3611..6b35ea8 100755
--- a/libexec/container/start
+++ b/libexec/container/start
@@ -367,42 +367,6 @@ then
;;
esac
- NETWORK_BRIDGES="$(awk -Fcnt.network-bridge= '/^cnt.network-bridge=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
-
- case "${NETWORK_BRIDGES}" in
- "")
- ;;
-
- *)
- for BRIDGE_DEFINITION in ${NETWORK_BRIDGES}
- do
- INTERFACE="$(echo ${BRIDGE_DEFINITION} | awk -F: '{ print $1 }')"
- BRIDGE="$(echo ${BRIDGE_DEFINITION} | awk -F: '{ print $2 }')"
-
- if [ "$(echo ${INTERFACE} | wc -c)" -gt 15 ]
- then
- echo "'${INTERFACE}': name exceeds maximum of 15 characters, network might be not working."
- fi
-
- if [ -n "${BRIDGE}" ] && [ -n "${INTERFACE}" ]
- then
-
-cat > "/etc/network/interfaces.d/${INTERFACE}" << EOF
-allow-hotplug ${INTERFACE}
-iface ${INTERFACE} inet manual
- pre-up ip link set ${INTERFACE} up
- post-up ip link set ${INTERFACE} master ${BRIDGE}
- pre-down ip link set ${INTERFACE} nomaster
- post-down ip link set ${INTERFACE} down
-EOF
-
- else
- echo "Warning bridge definition '${BRIDGE_DEFINITION}' not recognized (expected <bridge>:<interface>): Ignoring"
- fi
- done
- ;;
- esac
-
PRIVATE_USERS="$(awk -Fprivate-users= '/^private-users=/ { print $2 }' ${CONFIG}/${NAME}.conf || echo no)"
case "${PRIVATE_USERS}" in
@@ -536,3 +500,35 @@ case "${START}" in
esac
;;
esac
+
+# waiting for systemd-nspawn to create the veth interfaces
+sleep 1
+NETWORK_BRIDGES="$(awk -Fcnt.network-bridge= '/^cnt.network-bridge=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
+
+case "${NETWORK_BRIDGES}" in
+ "")
+ ;;
+
+ *)
+ for BRIDGE_DEFINITION in ${NETWORK_BRIDGES}
+ do
+ INTERFACE="$(echo ${BRIDGE_DEFINITION} | awk -F: '{ print $1 }')"
+ BRIDGE="$(echo ${BRIDGE_DEFINITION} | awk -F: '{ print $2 }')"
+
+ if [ "$(echo ${INTERFACE} | wc -c)" -gt 15 ]
+ then
+ echo "'${INTERFACE}': name exceeds maximum of 15 characters, network might be not working."
+ fi
+
+ if [ -n "${BRIDGE}" ] && [ -n "${INTERFACE}" ]
+ then
+
+ ip link set "${INTERFACE}" up
+ ovs-vsctl --may-exist add-port "${BRIDGE}" "${INTERFACE}"
+
+ else
+ echo "Warning bridge definition '${BRIDGE_DEFINITION}' not recognized (expected <bridge>:<interface>): Ignoring"
+ fi
+ done
+ ;;
+esac
diff --git a/libexec/container/stop b/libexec/container/stop
index 58fc0e9..52b40d1 100755
--- a/libexec/container/stop
+++ b/libexec/container/stop
@@ -261,6 +261,12 @@ case "${VERBOSE}" in
;;
esac
+VETHS="$(awk -Fnetwork-veth-extra= '/^network-veth-extra=/ { print $2 }' ${CONFIG}/${NAME}.conf | awk -F: '{ print $1 }')"
+for VETH in ${VETHS}
+do
+ ovs-vsctl --if-exist del-port "${VETH}"
+done
+
machinectl ${MODE} ${NAME}
case "${FORCE}" in