osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/docker-playground/+/27159 )
Change subject: common/pipework: deduplicate
......................................................................
common/pipework: deduplicate
Move the pipework script from several image directories to the common
dir.
Change-Id: I88ff40ca69c9ee76bef9bb8f24f66ca9d5ac751a
---
R common/pipework
M debian-bullseye-titan/Dockerfile
M osmo-gbproxy-latest/Dockerfile
D osmo-gbproxy-latest/pipework
M osmo-gbproxy-master/Dockerfile
D osmo-gbproxy-master/pipework
M osmo-ns-master/Dockerfile
D osmo-ns-master/pipework
8 files changed, 4 insertions(+), 1,471 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/59/27159/1
diff --git a/debian-bullseye-titan/pipework b/common/pipework
similarity index 100%
rename from debian-bullseye-titan/pipework
rename to common/pipework
diff --git a/debian-bullseye-titan/Dockerfile b/debian-bullseye-titan/Dockerfile
index b4b6532..16b25b9 100644
--- a/debian-bullseye-titan/Dockerfile
+++ b/debian-bullseye-titan/Dockerfile
@@ -70,4 +70,4 @@
ADD ttcn3-docker-prepare.sh /usr/local/bin/ttcn3-docker-prepare
ADD ttcn3-docker-run.sh /usr/local/bin/ttcn3-docker-run
-ADD pipework /usr/local/bin/pipework
+ADD .common/pipework /usr/local/bin/pipework
diff --git a/osmo-gbproxy-latest/Dockerfile b/osmo-gbproxy-latest/Dockerfile
index 5e16f99..6f58663 100644
--- a/osmo-gbproxy-latest/Dockerfile
+++ b/osmo-gbproxy-latest/Dockerfile
@@ -31,7 +31,7 @@
# work-around for stupid docker not being able to properly deal with host netdevices or start
# containers in pre-existing netns
-COPY pipework /usr/bin/pipework
+COPY .common/pipework /usr/bin/pipework
COPY docker-entrypoint.sh /docker-entrypoint.sh
CMD ["/docker-entrypoint.sh"]
diff --git a/osmo-gbproxy-latest/pipework b/osmo-gbproxy-latest/pipework
deleted file mode 100755
index 97ce66b..0000000
--- a/osmo-gbproxy-latest/pipework
+++ /dev/null
@@ -1,489 +0,0 @@
-#!/bin/sh
-# This code should (try to) follow Google's Shell Style Guide
-# (https://google.github.io/styleguide/shell.xml)
-set -e
-
-case "$1" in
- --wait)
- WAIT=1
- ;;
- --direct-phys)
- DIRECT_PHYS=1
- shift
- ;;
-esac
-
-IFNAME=$1
-
-# default value set further down if not set here
-CONTAINER_IFNAME=
-if [ "$2" = "-i" ]; then
- CONTAINER_IFNAME=$3
- shift 2
-fi
-
-if [ "$2" = "-l" ]; then
- LOCAL_IFNAME=$3
- shift 2
-fi
-
-#inet or inet6
-FAMILY_FLAG="-4"
-if [ "$2" = "-a" ]; then
- FAMILY_FLAG="-$3"
- shift 2
-fi
-
-GUESTNAME=$2
-IPADDR=$3
-MACADDR=$4
-
-case "$MACADDR" in
- *@*)
- VLAN="${MACADDR#*@}"
- VLAN="${VLAN%%@*}"
- MACADDR="${MACADDR%%@*}"
- ;;
- *)
- VLAN=
- ;;
-esac
-
-# did they ask to generate a custom MACADDR?
-# generate the unique string
-case "$MACADDR" in
- U:*)
- macunique="${MACADDR#*:}"
- # now generate a 48-bit hash string from $macunique
- MACADDR=$(echo $macunique|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')
- ;;
-esac
-
-
-[ "$IPADDR" ] || [ "$WAIT" ] || {
- echo "Syntax:"
- echo "pipework <hostinterface> [-i containerinterface] [-l localinterfacename] [-a addressfamily] <guest> <ipaddr>/<subnet>[@default_gateway] [macaddr][@vlan]"
- echo "pipework <hostinterface> [-i containerinterface] [-l localinterfacename] <guest> dhcp [macaddr][@vlan]"
- echo "pipework mac:<hostinterface_macaddress> [-i containerinterface] [-l localinterfacename] [-a addressfamily] <guest> <ipaddr>/<subnet>[@default_gateway] [macaddr][@vlan]"
- echo "pipework mac:<hostinterface_macaddress> [-i containerinterface] [-l localinterfacename] <guest> dhcp [macaddr][@vlan]"
- echo "pipework route <guest> <route_command>"
- echo "pipework rule <guest> <rule_command>"
- echo "pipework tc <guest> <tc_command>"
- echo "pipework --wait [-i containerinterface]"
- exit 1
-}
-
-# Succeed if the given utility is installed. Fail otherwise.
-# For explanations about `which` vs `type` vs `command`, see:
-# http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-…
-# (Thanks to @chenhanxiao for pointing this out!)
-installed () {
- command -v "$1" >/dev/null 2>&1
-}
-
-# Google Styleguide says error messages should go to standard error.
-warn () {
- echo "$@" >&2
-}
-die () {
- status="$1"
- shift
- warn "$@"
- exit "$status"
-}
-
-if echo $IFNAME | grep -q '^mac:'; then
- mac_address=$(echo $IFNAME | cut -c5-)
- ifmatch=
- for iftest in /sys/class/net/*; do
- if [ -f $iftest/address ] && [ "$mac_address" = "$(cat $iftest/address)" ]; then
- ifmatch="$(basename $iftest)"
- break
- fi
- done
-
- if [ -z "$ifmatch" ]; then
- die 1 "Mac address $mac_address specified for interface but no host interface matched."
- else
- IFNAME=$ifmatch
- fi
-fi
-
-# First step: determine type of first argument (bridge, physical interface...),
-# Unless "--wait" is set (then skip the whole section)
-if [ -z "$WAIT" ]; then
- if [ -d "/sys/class/net/$IFNAME" ]
- then
- if [ -d "/sys/class/net/$IFNAME/bridge" ]; then
- IFTYPE=bridge
- BRTYPE=linux
- elif installed ovs-vsctl && ovs-vsctl list-br|grep -q "^${IFNAME}$"; then
- IFTYPE=bridge
- BRTYPE=openvswitch
- elif [ "$(cat "/sys/class/net/$IFNAME/type")" -eq 32 ]; then # InfiniBand IPoIB interface type 32
- IFTYPE=ipoib
- # The IPoIB kernel module is fussy, set device name to ib0 if not overridden
- CONTAINER_IFNAME=${CONTAINER_IFNAME:-ib0}
- PKEY=$VLAN
- else IFTYPE=phys
- fi
- else
- case "$IFNAME" in
- br*)
- IFTYPE=bridge
- BRTYPE=linux
- ;;
- ovs*)
- if ! installed ovs-vsctl; then
- die 1 "Need OVS installed on the system to create an ovs bridge"
- fi
- IFTYPE=bridge
- BRTYPE=openvswitch
- ;;
- route*)
- IFTYPE=route
- ;;
- rule*)
- IFTYPE=rule
- ;;
- tc*)
- IFTYPE=tc
- ;;
- dummy*)
- IFTYPE=dummy
- ;;
- *) die 1 "I do not know how to setup interface $IFNAME." ;;
- esac
- fi
-fi
-
-# Set the default container interface name to eth1 if not already set
-CONTAINER_IFNAME=${CONTAINER_IFNAME:-eth1}
-
-[ "$WAIT" ] && {
- while true; do
- # This first method works even without `ip` or `ifconfig` installed,
- # but doesn't work on older kernels (e.g. CentOS 6.X). See #128.
- grep -q '^1$' "/sys/class/net/$CONTAINER_IFNAME/carrier" && break
- # This method hopefully works on those older kernels.
- ip link ls dev "$CONTAINER_IFNAME" && break
- sleep 1
- done > /dev/null 2>&1
- exit 0
-}
-
-[ "$IFTYPE" = bridge ] && [ "$BRTYPE" = linux ] && [ "$VLAN" ] && {
- die 1 "VLAN configuration currently unsupported for Linux bridge."
-}
-
-[ "$IFTYPE" = ipoib ] && [ "$MACADDR" ] && {
- die 1 "MACADDR configuration unsupported for IPoIB interfaces."
-}
-
-# Second step: find the guest (for now, we only support LXC containers)
-while read _ mnt fstype options _; do
- [ "$fstype" != "cgroup" ] && continue
- echo "$options" | grep -qw devices || continue
- CGROUPMNT=$mnt
-done < /proc/mounts
-
-[ "$CGROUPMNT" ] || {
- die 1 "Could not locate cgroup mount point."
-}
-
-# Try to find a cgroup matching exactly the provided name.
-M=$(find "$CGROUPMNT" -name "$GUESTNAME")
-N=$(echo "$M" | wc -l)
-if [ -z "$M" ] ; then
- N=0
-fi
-case "$N" in
- 0)
- # If we didn't find anything, try to lookup the container with Docker.
- if installed docker; then
- RETRIES=3
- while [ "$RETRIES" -gt 0 ]; do
- DOCKERPID=$(docker inspect --format='{{ .State.Pid }}' "$GUESTNAME")
- DOCKERCID=$(docker inspect --format='{{ .ID }}' "$GUESTNAME")
- DOCKERCNAME=$(docker inspect --format='{{ .Name }}' "$GUESTNAME")
-
- [ "$DOCKERPID" != 0 ] && break
- sleep 1
- RETRIES=$((RETRIES - 1))
- done
-
- [ "$DOCKERPID" = 0 ] && {
- die 1 "Docker inspect returned invalid PID 0"
- }
-
- [ "$DOCKERPID" = "<no value>" ] && {
- die 1 "Container $GUESTNAME not found, and unknown to Docker."
- }
- else
- die 1 "Container $GUESTNAME not found, and Docker not installed."
- fi
- ;;
- 1) true ;;
- 2) # LXC >=3.1.0 returns two entries from the cgroups mount instead of one.
- echo "$M" | grep -q "lxc\.monitor" || die 1 "Found more than one container matching $GUESTNAME."
- ;;
- *) die 1 "Found more than one container matching $GUESTNAME." ;;
-esac
-
-# only check IPADDR if we are not in a route mode
-[ "$IFTYPE" != route ] && [ "$IFTYPE" != rule ] && [ "$IFTYPE" != tc ] && {
- case "$IPADDR" in
- # Let's check first if the user asked for DHCP allocation.
- dhcp|dhcp:*)
- # Use Docker-specific strategy to run the DHCP client
- # from the busybox image, in the network namespace of
- # the container.
- if ! [ "$DOCKERPID" ]; then
- warn "You asked for a Docker-specific DHCP method."
- warn "However, $GUESTNAME doesn't seem to be a Docker container."
- warn "Try to replace 'dhcp' with another option?"
- die 1 "Aborting."
- fi
- DHCP_CLIENT=${IPADDR%%:*}
- ;;
- udhcpc|udhcpc:*|udhcpc-f|udhcpc-f:*|dhcpcd|dhcpcd:*|dhclient|dhclient:*|dhclient-f|dhclient-f:*)
- DHCP_CLIENT=${IPADDR%%:*}
- # did they ask for the client to remain?
- DHCP_FOREGROUND=
- [ "${DHCP_CLIENT%-f}" != "${DHCP_CLIENT}" ] && {
- DHCP_FOREGROUND=true
- }
- DHCP_CLIENT=${DHCP_CLIENT%-f}
- if ! installed "$DHCP_CLIENT"; then
- die 1 "You asked for DHCP client $DHCP_CLIENT, but I can't find it."
- fi
- ;;
- # Alright, no DHCP? Then let's see if we have a subnet *and* gateway.
- */*@*)
- GATEWAY="${IPADDR#*@}" GATEWAY="${GATEWAY%%@*}"
- IPADDR="${IPADDR%%@*}"
- ;;
- # No gateway? We need at least a subnet, anyway!
- */*) : ;;
- # ... No? Then stop right here.
- *)
- warn "The IP address should include a netmask."
- die 1 "Maybe you meant $IPADDR/24 ?"
- ;;
- esac
-}
-
-# If a DHCP method was specified, extract the DHCP options.
-if [ "$DHCP_CLIENT" ]; then
- case "$IPADDR" in
- *:*) DHCP_OPTIONS="${IPADDR#*:}" ;;
- esac
-fi
-
-if [ "$DOCKERPID" ]; then
- NSPID=$DOCKERPID
-else
- NSPID=$(head -n 1 "$(find "$CGROUPMNT" -name "$GUESTNAME" | head -n 1)/tasks")
- [ "$NSPID" ] || {
- # it is an alternative way to get the pid
- NSPID=$(lxc-info -n "$GUESTNAME" | grep PID | grep -Eo '[0-9]+')
- [ "$NSPID" ] || {
- die 1 "Could not find a process inside container $GUESTNAME."
- }
- }
-fi
-
-# Check if an incompatible VLAN device already exists
-[ "$IFTYPE" = phys ] && [ "$VLAN" ] && [ -d "/sys/class/net/$IFNAME.VLAN" ] && {
- ip -d link show "$IFNAME.$VLAN" | grep -q "vlan.*id $VLAN" || {
- die 1 "$IFNAME.VLAN already exists but is not a VLAN device for tag $VLAN"
- }
-}
-
-[ ! -d /var/run/netns ] && mkdir -p /var/run/netns
-rm -f "/var/run/netns/$NSPID"
-ln -s "/proc/$NSPID/ns/net" "/var/run/netns/$NSPID"
-
-# Check if we need to create a bridge.
-[ "$IFTYPE" = bridge ] && [ ! -d "/sys/class/net/$IFNAME" ] && {
- [ "$BRTYPE" = linux ] && {
- (ip link add dev "$IFNAME" type bridge > /dev/null 2>&1) || (brctl addbr "$IFNAME")
- ip link set "$IFNAME" up
- }
- [ "$BRTYPE" = openvswitch ] && {
- ovs-vsctl add-br "$IFNAME"
- }
-}
-
-[ "$IFTYPE" != "route" ] && [ "$IFTYPE" != "dummy" ] && [ "$IFTYPE" != "rule" ] && [ "$IFTYPE" != "tc" ] && MTU=$(ip link show "$IFNAME" | awk '{print $5}')
-
-# If it's a bridge, we need to create a veth pair
-[ "$IFTYPE" = bridge ] && {
- if [ -z "$LOCAL_IFNAME" ]; then
- LOCAL_IFNAME="v${CONTAINER_IFNAME}pl${NSPID}"
- fi
- GUEST_IFNAME="v${CONTAINER_IFNAME}pg${NSPID}"
- # Does the link already exist?
- if ip link show "$LOCAL_IFNAME" >/dev/null 2>&1; then
- # link exists, is it in use?
- if ip link show "$LOCAL_IFNAME" up | grep -q "UP"; then
- echo "Link $LOCAL_IFNAME exists and is up"
- exit 1
- fi
- # delete the link so we can re-add it afterwards
- ip link del "$LOCAL_IFNAME"
- fi
- ip link add name "$LOCAL_IFNAME" mtu "$MTU" type veth peer name "$GUEST_IFNAME" mtu "$MTU"
- case "$BRTYPE" in
- linux)
- (ip link set "$LOCAL_IFNAME" master "$IFNAME" > /dev/null 2>&1) || (brctl addif "$IFNAME" "$LOCAL_IFNAME")
- ;;
- openvswitch)
- if ! ovs-vsctl list-ports "$IFNAME" | grep -q "^${LOCAL_IFNAME}$"; then
- ovs-vsctl add-port "$IFNAME" "$LOCAL_IFNAME" ${VLAN:+tag="$VLAN"} \
- -- set Interface "$LOCAL_IFNAME" \
- external-ids:pipework.interface="$LOCAL_IFNAME" \
- external-ids:pipework.bridge="$IFNAME" \
- ${DOCKERCID:+external-ids:pipework.containerid="$DOCKERCID"} \
- ${DOCKERCNAME:+external-ids:pipework.containername="$DOCKERCNAME"} \
- ${NSPID:+external-ids:pipework.nspid="$NSPID"} \
- ${VLAN:+external-ids:pipework.vlan="$VLAN"}
- fi
- ;;
- esac
- ip link set "$LOCAL_IFNAME" up
-}
-
-# If it's a physical interface, create a macvlan subinterface
-[ "$IFTYPE" = phys ] && {
- [ "$VLAN" ] && {
- [ ! -d "/sys/class/net/${IFNAME}.${VLAN}" ] && {
- ip link add link "$IFNAME" name "$IFNAME.$VLAN" mtu "$MTU" type vlan id "$VLAN"
- }
- ip link set "$IFNAME" up
- IFNAME=$IFNAME.$VLAN
- }
-
- if [ ! -z "$DIRECT_PHYS" ]; then
- GUEST_IFNAME=$IFNAME
- else
- GUEST_IFNAME=ph$NSPID$CONTAINER_IFNAME
- ip link add link "$IFNAME" dev "$GUEST_IFNAME" mtu "$MTU" type macvlan mode bridge
- fi
-
- ip link set "$IFNAME" up
-}
-
-# If it's an IPoIB interface, create a virtual IPoIB interface (the IPoIB
-# equivalent of a macvlan device)
-#
-# Note: no macvlan subinterface nor Ethernet bridge can be created on top of an
-# IPoIB interface. InfiniBand is not Ethernet. IPoIB is an IP layer on top of
-# InfiniBand, without an intermediate Ethernet layer.
-[ "$IFTYPE" = ipoib ] && {
- GUEST_IFNAME="${IFNAME}.${NSPID}"
-
- # If a partition key is provided, use it
- [ "$PKEY" ] && {
- GUEST_IFNAME="${IFNAME}.${PKEY}.${NSPID}"
- PKEY="pkey 0x$PKEY"
- }
-
- ip link add link "$IFNAME" name "$GUEST_IFNAME" type ipoib $PKEY
- ip link set "$IFNAME" up
-}
-
-# If its a dummy interface, create a dummy interface.
-[ "$IFTYPE" = dummy ] && {
- GUEST_IFNAME=du$NSPID$CONTAINER_IFNAME
- ip link add dev "$GUEST_IFNAME" type dummy
-}
-
-# If the `route` command was specified ...
-if [ "$IFTYPE" = route ]; then
- # ... discard the first two arguments and pass the rest to the route command.
- shift 2
- ip netns exec "$NSPID" ip route "$@"
-elif [ "$IFTYPE" = rule ] ; then
- shift 2
- ip netns exec "$NSPID" ip rule "$@"
-elif [ "$IFTYPE" = tc ] ; then
- shift 2
- ip netns exec "$NSPID" tc "$@"
-else
- # Otherwise, run normally.
- ip link set "$GUEST_IFNAME" netns "$NSPID"
- ip netns exec "$NSPID" ip link set "$GUEST_IFNAME" name "$CONTAINER_IFNAME"
- [ "$MACADDR" ] && ip netns exec "$NSPID" ip link set dev "$CONTAINER_IFNAME" address "$MACADDR"
-
- # When using any of the DHCP methods, we start a DHCP client in the
- # network namespace of the container. With the 'dhcp' method, the
- # client used is taken from the Docker busybox image (therefore
- # requiring no specific client installed on the host). Other methods
- # use a locally installed client.
- case "$DHCP_CLIENT" in
- dhcp)
- docker run -d --net container:$GUESTNAME --cap-add NET_ADMIN \
- busybox udhcpc -i "$CONTAINER_IFNAME" -x "hostname:$GUESTNAME" \
- $DHCP_OPTIONS \
- >/dev/null
- ;;
- udhcpc)
- DHCP_Q="-q"
- [ "$DHCP_FOREGROUND" ] && {
- DHCP_OPTIONS="$DHCP_OPTIONS -f"
- }
- ip netns exec "$NSPID" "$DHCP_CLIENT" -qi "$CONTAINER_IFNAME" \
- -x "hostname:$GUESTNAME" \
- -p "/var/run/udhcpc.$GUESTNAME.pid" \
- $DHCP_OPTIONS
- [ ! "$DHCP_FOREGROUND" ] && {
- rm "/var/run/udhcpc.$GUESTNAME.pid"
- }
- ;;
- dhclient)
- ip netns exec "$NSPID" "$DHCP_CLIENT" "$CONTAINER_IFNAME" \
- -pf "/var/run/dhclient.$GUESTNAME.pid" \
- -lf "/etc/dhclient/dhclient.$GUESTNAME.leases" \
- $DHCP_OPTIONS
- # kill dhclient after get ip address to prevent device be used after container close
- [ ! "$DHCP_FOREGROUND" ] && {
- kill "$(cat "/var/run/dhclient.$GUESTNAME.pid")"
- rm "/var/run/dhclient.$GUESTNAME.pid"
- }
- ;;
- dhcpcd)
- ip netns exec "$NSPID" "$DHCP_CLIENT" -q "$CONTAINER_IFNAME" -h "$GUESTNAME"
- ;;
- "")
- if installed ipcalc; then
- eval $(ipcalc -b $IPADDR)
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" addr add "$IPADDR" brd "$BROADCAST" dev "$CONTAINER_IFNAME"
- else
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" addr add "$IPADDR" dev "$CONTAINER_IFNAME"
- fi
-
- [ "$GATEWAY" ] && {
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" route delete default >/dev/null 2>&1 && true
- }
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" link set "$CONTAINER_IFNAME" up
- [ "$GATEWAY" ] && {
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" route get "$GATEWAY" >/dev/null 2>&1 || \
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" route add "$GATEWAY/32" dev "$CONTAINER_IFNAME"
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" route replace default via "$GATEWAY" dev "$CONTAINER_IFNAME"
- }
- ;;
- esac
-
- # Give our ARP neighbors a nudge about the new interface
- if installed arping; then
- IPADDR=$(echo "$IPADDR" | cut -d/ -f1)
- ip netns exec "$NSPID" arping -c 1 -A -I "$CONTAINER_IFNAME" "$IPADDR" > /dev/null 2>&1 || true
- else
- echo "Warning: arping not found; interface may not be immediately reachable"
- fi
-fi
-# Remove NSPID to avoid `ip netns` catch it.
-rm -f "/var/run/netns/$NSPID"
-
-# vim: set tabstop=2 shiftwidth=2 softtabstop=2 expandtab :
diff --git a/osmo-gbproxy-master/Dockerfile b/osmo-gbproxy-master/Dockerfile
index 61463c5..3e0e40c 100644
--- a/osmo-gbproxy-master/Dockerfile
+++ b/osmo-gbproxy-master/Dockerfile
@@ -48,7 +48,7 @@
# work-around for stupid docker not being able to properly deal with host netdevices or start
# containers in pre-existing netns
-COPY pipework /usr/bin/pipework
+COPY .common/pipework /usr/bin/pipework
COPY docker-entrypoint.sh /docker-entrypoint.sh
WORKDIR /data
diff --git a/osmo-gbproxy-master/pipework b/osmo-gbproxy-master/pipework
deleted file mode 100755
index 97ce66b..0000000
--- a/osmo-gbproxy-master/pipework
+++ /dev/null
@@ -1,489 +0,0 @@
-#!/bin/sh
-# This code should (try to) follow Google's Shell Style Guide
-# (https://google.github.io/styleguide/shell.xml)
-set -e
-
-case "$1" in
- --wait)
- WAIT=1
- ;;
- --direct-phys)
- DIRECT_PHYS=1
- shift
- ;;
-esac
-
-IFNAME=$1
-
-# default value set further down if not set here
-CONTAINER_IFNAME=
-if [ "$2" = "-i" ]; then
- CONTAINER_IFNAME=$3
- shift 2
-fi
-
-if [ "$2" = "-l" ]; then
- LOCAL_IFNAME=$3
- shift 2
-fi
-
-#inet or inet6
-FAMILY_FLAG="-4"
-if [ "$2" = "-a" ]; then
- FAMILY_FLAG="-$3"
- shift 2
-fi
-
-GUESTNAME=$2
-IPADDR=$3
-MACADDR=$4
-
-case "$MACADDR" in
- *@*)
- VLAN="${MACADDR#*@}"
- VLAN="${VLAN%%@*}"
- MACADDR="${MACADDR%%@*}"
- ;;
- *)
- VLAN=
- ;;
-esac
-
-# did they ask to generate a custom MACADDR?
-# generate the unique string
-case "$MACADDR" in
- U:*)
- macunique="${MACADDR#*:}"
- # now generate a 48-bit hash string from $macunique
- MACADDR=$(echo $macunique|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')
- ;;
-esac
-
-
-[ "$IPADDR" ] || [ "$WAIT" ] || {
- echo "Syntax:"
- echo "pipework <hostinterface> [-i containerinterface] [-l localinterfacename] [-a addressfamily] <guest> <ipaddr>/<subnet>[@default_gateway] [macaddr][@vlan]"
- echo "pipework <hostinterface> [-i containerinterface] [-l localinterfacename] <guest> dhcp [macaddr][@vlan]"
- echo "pipework mac:<hostinterface_macaddress> [-i containerinterface] [-l localinterfacename] [-a addressfamily] <guest> <ipaddr>/<subnet>[@default_gateway] [macaddr][@vlan]"
- echo "pipework mac:<hostinterface_macaddress> [-i containerinterface] [-l localinterfacename] <guest> dhcp [macaddr][@vlan]"
- echo "pipework route <guest> <route_command>"
- echo "pipework rule <guest> <rule_command>"
- echo "pipework tc <guest> <tc_command>"
- echo "pipework --wait [-i containerinterface]"
- exit 1
-}
-
-# Succeed if the given utility is installed. Fail otherwise.
-# For explanations about `which` vs `type` vs `command`, see:
-# http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-…
-# (Thanks to @chenhanxiao for pointing this out!)
-installed () {
- command -v "$1" >/dev/null 2>&1
-}
-
-# Google Styleguide says error messages should go to standard error.
-warn () {
- echo "$@" >&2
-}
-die () {
- status="$1"
- shift
- warn "$@"
- exit "$status"
-}
-
-if echo $IFNAME | grep -q '^mac:'; then
- mac_address=$(echo $IFNAME | cut -c5-)
- ifmatch=
- for iftest in /sys/class/net/*; do
- if [ -f $iftest/address ] && [ "$mac_address" = "$(cat $iftest/address)" ]; then
- ifmatch="$(basename $iftest)"
- break
- fi
- done
-
- if [ -z "$ifmatch" ]; then
- die 1 "Mac address $mac_address specified for interface but no host interface matched."
- else
- IFNAME=$ifmatch
- fi
-fi
-
-# First step: determine type of first argument (bridge, physical interface...),
-# Unless "--wait" is set (then skip the whole section)
-if [ -z "$WAIT" ]; then
- if [ -d "/sys/class/net/$IFNAME" ]
- then
- if [ -d "/sys/class/net/$IFNAME/bridge" ]; then
- IFTYPE=bridge
- BRTYPE=linux
- elif installed ovs-vsctl && ovs-vsctl list-br|grep -q "^${IFNAME}$"; then
- IFTYPE=bridge
- BRTYPE=openvswitch
- elif [ "$(cat "/sys/class/net/$IFNAME/type")" -eq 32 ]; then # InfiniBand IPoIB interface type 32
- IFTYPE=ipoib
- # The IPoIB kernel module is fussy, set device name to ib0 if not overridden
- CONTAINER_IFNAME=${CONTAINER_IFNAME:-ib0}
- PKEY=$VLAN
- else IFTYPE=phys
- fi
- else
- case "$IFNAME" in
- br*)
- IFTYPE=bridge
- BRTYPE=linux
- ;;
- ovs*)
- if ! installed ovs-vsctl; then
- die 1 "Need OVS installed on the system to create an ovs bridge"
- fi
- IFTYPE=bridge
- BRTYPE=openvswitch
- ;;
- route*)
- IFTYPE=route
- ;;
- rule*)
- IFTYPE=rule
- ;;
- tc*)
- IFTYPE=tc
- ;;
- dummy*)
- IFTYPE=dummy
- ;;
- *) die 1 "I do not know how to setup interface $IFNAME." ;;
- esac
- fi
-fi
-
-# Set the default container interface name to eth1 if not already set
-CONTAINER_IFNAME=${CONTAINER_IFNAME:-eth1}
-
-[ "$WAIT" ] && {
- while true; do
- # This first method works even without `ip` or `ifconfig` installed,
- # but doesn't work on older kernels (e.g. CentOS 6.X). See #128.
- grep -q '^1$' "/sys/class/net/$CONTAINER_IFNAME/carrier" && break
- # This method hopefully works on those older kernels.
- ip link ls dev "$CONTAINER_IFNAME" && break
- sleep 1
- done > /dev/null 2>&1
- exit 0
-}
-
-[ "$IFTYPE" = bridge ] && [ "$BRTYPE" = linux ] && [ "$VLAN" ] && {
- die 1 "VLAN configuration currently unsupported for Linux bridge."
-}
-
-[ "$IFTYPE" = ipoib ] && [ "$MACADDR" ] && {
- die 1 "MACADDR configuration unsupported for IPoIB interfaces."
-}
-
-# Second step: find the guest (for now, we only support LXC containers)
-while read _ mnt fstype options _; do
- [ "$fstype" != "cgroup" ] && continue
- echo "$options" | grep -qw devices || continue
- CGROUPMNT=$mnt
-done < /proc/mounts
-
-[ "$CGROUPMNT" ] || {
- die 1 "Could not locate cgroup mount point."
-}
-
-# Try to find a cgroup matching exactly the provided name.
-M=$(find "$CGROUPMNT" -name "$GUESTNAME")
-N=$(echo "$M" | wc -l)
-if [ -z "$M" ] ; then
- N=0
-fi
-case "$N" in
- 0)
- # If we didn't find anything, try to lookup the container with Docker.
- if installed docker; then
- RETRIES=3
- while [ "$RETRIES" -gt 0 ]; do
- DOCKERPID=$(docker inspect --format='{{ .State.Pid }}' "$GUESTNAME")
- DOCKERCID=$(docker inspect --format='{{ .ID }}' "$GUESTNAME")
- DOCKERCNAME=$(docker inspect --format='{{ .Name }}' "$GUESTNAME")
-
- [ "$DOCKERPID" != 0 ] && break
- sleep 1
- RETRIES=$((RETRIES - 1))
- done
-
- [ "$DOCKERPID" = 0 ] && {
- die 1 "Docker inspect returned invalid PID 0"
- }
-
- [ "$DOCKERPID" = "<no value>" ] && {
- die 1 "Container $GUESTNAME not found, and unknown to Docker."
- }
- else
- die 1 "Container $GUESTNAME not found, and Docker not installed."
- fi
- ;;
- 1) true ;;
- 2) # LXC >=3.1.0 returns two entries from the cgroups mount instead of one.
- echo "$M" | grep -q "lxc\.monitor" || die 1 "Found more than one container matching $GUESTNAME."
- ;;
- *) die 1 "Found more than one container matching $GUESTNAME." ;;
-esac
-
-# only check IPADDR if we are not in a route mode
-[ "$IFTYPE" != route ] && [ "$IFTYPE" != rule ] && [ "$IFTYPE" != tc ] && {
- case "$IPADDR" in
- # Let's check first if the user asked for DHCP allocation.
- dhcp|dhcp:*)
- # Use Docker-specific strategy to run the DHCP client
- # from the busybox image, in the network namespace of
- # the container.
- if ! [ "$DOCKERPID" ]; then
- warn "You asked for a Docker-specific DHCP method."
- warn "However, $GUESTNAME doesn't seem to be a Docker container."
- warn "Try to replace 'dhcp' with another option?"
- die 1 "Aborting."
- fi
- DHCP_CLIENT=${IPADDR%%:*}
- ;;
- udhcpc|udhcpc:*|udhcpc-f|udhcpc-f:*|dhcpcd|dhcpcd:*|dhclient|dhclient:*|dhclient-f|dhclient-f:*)
- DHCP_CLIENT=${IPADDR%%:*}
- # did they ask for the client to remain?
- DHCP_FOREGROUND=
- [ "${DHCP_CLIENT%-f}" != "${DHCP_CLIENT}" ] && {
- DHCP_FOREGROUND=true
- }
- DHCP_CLIENT=${DHCP_CLIENT%-f}
- if ! installed "$DHCP_CLIENT"; then
- die 1 "You asked for DHCP client $DHCP_CLIENT, but I can't find it."
- fi
- ;;
- # Alright, no DHCP? Then let's see if we have a subnet *and* gateway.
- */*@*)
- GATEWAY="${IPADDR#*@}" GATEWAY="${GATEWAY%%@*}"
- IPADDR="${IPADDR%%@*}"
- ;;
- # No gateway? We need at least a subnet, anyway!
- */*) : ;;
- # ... No? Then stop right here.
- *)
- warn "The IP address should include a netmask."
- die 1 "Maybe you meant $IPADDR/24 ?"
- ;;
- esac
-}
-
-# If a DHCP method was specified, extract the DHCP options.
-if [ "$DHCP_CLIENT" ]; then
- case "$IPADDR" in
- *:*) DHCP_OPTIONS="${IPADDR#*:}" ;;
- esac
-fi
-
-if [ "$DOCKERPID" ]; then
- NSPID=$DOCKERPID
-else
- NSPID=$(head -n 1 "$(find "$CGROUPMNT" -name "$GUESTNAME" | head -n 1)/tasks")
- [ "$NSPID" ] || {
- # it is an alternative way to get the pid
- NSPID=$(lxc-info -n "$GUESTNAME" | grep PID | grep -Eo '[0-9]+')
- [ "$NSPID" ] || {
- die 1 "Could not find a process inside container $GUESTNAME."
- }
- }
-fi
-
-# Check if an incompatible VLAN device already exists
-[ "$IFTYPE" = phys ] && [ "$VLAN" ] && [ -d "/sys/class/net/$IFNAME.VLAN" ] && {
- ip -d link show "$IFNAME.$VLAN" | grep -q "vlan.*id $VLAN" || {
- die 1 "$IFNAME.VLAN already exists but is not a VLAN device for tag $VLAN"
- }
-}
-
-[ ! -d /var/run/netns ] && mkdir -p /var/run/netns
-rm -f "/var/run/netns/$NSPID"
-ln -s "/proc/$NSPID/ns/net" "/var/run/netns/$NSPID"
-
-# Check if we need to create a bridge.
-[ "$IFTYPE" = bridge ] && [ ! -d "/sys/class/net/$IFNAME" ] && {
- [ "$BRTYPE" = linux ] && {
- (ip link add dev "$IFNAME" type bridge > /dev/null 2>&1) || (brctl addbr "$IFNAME")
- ip link set "$IFNAME" up
- }
- [ "$BRTYPE" = openvswitch ] && {
- ovs-vsctl add-br "$IFNAME"
- }
-}
-
-[ "$IFTYPE" != "route" ] && [ "$IFTYPE" != "dummy" ] && [ "$IFTYPE" != "rule" ] && [ "$IFTYPE" != "tc" ] && MTU=$(ip link show "$IFNAME" | awk '{print $5}')
-
-# If it's a bridge, we need to create a veth pair
-[ "$IFTYPE" = bridge ] && {
- if [ -z "$LOCAL_IFNAME" ]; then
- LOCAL_IFNAME="v${CONTAINER_IFNAME}pl${NSPID}"
- fi
- GUEST_IFNAME="v${CONTAINER_IFNAME}pg${NSPID}"
- # Does the link already exist?
- if ip link show "$LOCAL_IFNAME" >/dev/null 2>&1; then
- # link exists, is it in use?
- if ip link show "$LOCAL_IFNAME" up | grep -q "UP"; then
- echo "Link $LOCAL_IFNAME exists and is up"
- exit 1
- fi
- # delete the link so we can re-add it afterwards
- ip link del "$LOCAL_IFNAME"
- fi
- ip link add name "$LOCAL_IFNAME" mtu "$MTU" type veth peer name "$GUEST_IFNAME" mtu "$MTU"
- case "$BRTYPE" in
- linux)
- (ip link set "$LOCAL_IFNAME" master "$IFNAME" > /dev/null 2>&1) || (brctl addif "$IFNAME" "$LOCAL_IFNAME")
- ;;
- openvswitch)
- if ! ovs-vsctl list-ports "$IFNAME" | grep -q "^${LOCAL_IFNAME}$"; then
- ovs-vsctl add-port "$IFNAME" "$LOCAL_IFNAME" ${VLAN:+tag="$VLAN"} \
- -- set Interface "$LOCAL_IFNAME" \
- external-ids:pipework.interface="$LOCAL_IFNAME" \
- external-ids:pipework.bridge="$IFNAME" \
- ${DOCKERCID:+external-ids:pipework.containerid="$DOCKERCID"} \
- ${DOCKERCNAME:+external-ids:pipework.containername="$DOCKERCNAME"} \
- ${NSPID:+external-ids:pipework.nspid="$NSPID"} \
- ${VLAN:+external-ids:pipework.vlan="$VLAN"}
- fi
- ;;
- esac
- ip link set "$LOCAL_IFNAME" up
-}
-
-# If it's a physical interface, create a macvlan subinterface
-[ "$IFTYPE" = phys ] && {
- [ "$VLAN" ] && {
- [ ! -d "/sys/class/net/${IFNAME}.${VLAN}" ] && {
- ip link add link "$IFNAME" name "$IFNAME.$VLAN" mtu "$MTU" type vlan id "$VLAN"
- }
- ip link set "$IFNAME" up
- IFNAME=$IFNAME.$VLAN
- }
-
- if [ ! -z "$DIRECT_PHYS" ]; then
- GUEST_IFNAME=$IFNAME
- else
- GUEST_IFNAME=ph$NSPID$CONTAINER_IFNAME
- ip link add link "$IFNAME" dev "$GUEST_IFNAME" mtu "$MTU" type macvlan mode bridge
- fi
-
- ip link set "$IFNAME" up
-}
-
-# If it's an IPoIB interface, create a virtual IPoIB interface (the IPoIB
-# equivalent of a macvlan device)
-#
-# Note: no macvlan subinterface nor Ethernet bridge can be created on top of an
-# IPoIB interface. InfiniBand is not Ethernet. IPoIB is an IP layer on top of
-# InfiniBand, without an intermediate Ethernet layer.
-[ "$IFTYPE" = ipoib ] && {
- GUEST_IFNAME="${IFNAME}.${NSPID}"
-
- # If a partition key is provided, use it
- [ "$PKEY" ] && {
- GUEST_IFNAME="${IFNAME}.${PKEY}.${NSPID}"
- PKEY="pkey 0x$PKEY"
- }
-
- ip link add link "$IFNAME" name "$GUEST_IFNAME" type ipoib $PKEY
- ip link set "$IFNAME" up
-}
-
-# If its a dummy interface, create a dummy interface.
-[ "$IFTYPE" = dummy ] && {
- GUEST_IFNAME=du$NSPID$CONTAINER_IFNAME
- ip link add dev "$GUEST_IFNAME" type dummy
-}
-
-# If the `route` command was specified ...
-if [ "$IFTYPE" = route ]; then
- # ... discard the first two arguments and pass the rest to the route command.
- shift 2
- ip netns exec "$NSPID" ip route "$@"
-elif [ "$IFTYPE" = rule ] ; then
- shift 2
- ip netns exec "$NSPID" ip rule "$@"
-elif [ "$IFTYPE" = tc ] ; then
- shift 2
- ip netns exec "$NSPID" tc "$@"
-else
- # Otherwise, run normally.
- ip link set "$GUEST_IFNAME" netns "$NSPID"
- ip netns exec "$NSPID" ip link set "$GUEST_IFNAME" name "$CONTAINER_IFNAME"
- [ "$MACADDR" ] && ip netns exec "$NSPID" ip link set dev "$CONTAINER_IFNAME" address "$MACADDR"
-
- # When using any of the DHCP methods, we start a DHCP client in the
- # network namespace of the container. With the 'dhcp' method, the
- # client used is taken from the Docker busybox image (therefore
- # requiring no specific client installed on the host). Other methods
- # use a locally installed client.
- case "$DHCP_CLIENT" in
- dhcp)
- docker run -d --net container:$GUESTNAME --cap-add NET_ADMIN \
- busybox udhcpc -i "$CONTAINER_IFNAME" -x "hostname:$GUESTNAME" \
- $DHCP_OPTIONS \
- >/dev/null
- ;;
- udhcpc)
- DHCP_Q="-q"
- [ "$DHCP_FOREGROUND" ] && {
- DHCP_OPTIONS="$DHCP_OPTIONS -f"
- }
- ip netns exec "$NSPID" "$DHCP_CLIENT" -qi "$CONTAINER_IFNAME" \
- -x "hostname:$GUESTNAME" \
- -p "/var/run/udhcpc.$GUESTNAME.pid" \
- $DHCP_OPTIONS
- [ ! "$DHCP_FOREGROUND" ] && {
- rm "/var/run/udhcpc.$GUESTNAME.pid"
- }
- ;;
- dhclient)
- ip netns exec "$NSPID" "$DHCP_CLIENT" "$CONTAINER_IFNAME" \
- -pf "/var/run/dhclient.$GUESTNAME.pid" \
- -lf "/etc/dhclient/dhclient.$GUESTNAME.leases" \
- $DHCP_OPTIONS
- # kill dhclient after get ip address to prevent device be used after container close
- [ ! "$DHCP_FOREGROUND" ] && {
- kill "$(cat "/var/run/dhclient.$GUESTNAME.pid")"
- rm "/var/run/dhclient.$GUESTNAME.pid"
- }
- ;;
- dhcpcd)
- ip netns exec "$NSPID" "$DHCP_CLIENT" -q "$CONTAINER_IFNAME" -h "$GUESTNAME"
- ;;
- "")
- if installed ipcalc; then
- eval $(ipcalc -b $IPADDR)
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" addr add "$IPADDR" brd "$BROADCAST" dev "$CONTAINER_IFNAME"
- else
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" addr add "$IPADDR" dev "$CONTAINER_IFNAME"
- fi
-
- [ "$GATEWAY" ] && {
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" route delete default >/dev/null 2>&1 && true
- }
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" link set "$CONTAINER_IFNAME" up
- [ "$GATEWAY" ] && {
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" route get "$GATEWAY" >/dev/null 2>&1 || \
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" route add "$GATEWAY/32" dev "$CONTAINER_IFNAME"
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" route replace default via "$GATEWAY" dev "$CONTAINER_IFNAME"
- }
- ;;
- esac
-
- # Give our ARP neighbors a nudge about the new interface
- if installed arping; then
- IPADDR=$(echo "$IPADDR" | cut -d/ -f1)
- ip netns exec "$NSPID" arping -c 1 -A -I "$CONTAINER_IFNAME" "$IPADDR" > /dev/null 2>&1 || true
- else
- echo "Warning: arping not found; interface may not be immediately reachable"
- fi
-fi
-# Remove NSPID to avoid `ip netns` catch it.
-rm -f "/var/run/netns/$NSPID"
-
-# vim: set tabstop=2 shiftwidth=2 softtabstop=2 expandtab :
diff --git a/osmo-ns-master/Dockerfile b/osmo-ns-master/Dockerfile
index 1185253..2f88c83 100644
--- a/osmo-ns-master/Dockerfile
+++ b/osmo-ns-master/Dockerfile
@@ -41,7 +41,7 @@
# work-around for stupid docker not being able to properly deal with host netdevices or start
# containers in pre-existing netns
-COPY pipework /usr/bin/pipework
+COPY .common/pipework /usr/bin/pipework
COPY docker-entrypoint.sh /docker-entrypoint.sh
WORKDIR /data
diff --git a/osmo-ns-master/pipework b/osmo-ns-master/pipework
deleted file mode 100755
index 97ce66b..0000000
--- a/osmo-ns-master/pipework
+++ /dev/null
@@ -1,489 +0,0 @@
-#!/bin/sh
-# This code should (try to) follow Google's Shell Style Guide
-# (https://google.github.io/styleguide/shell.xml)
-set -e
-
-case "$1" in
- --wait)
- WAIT=1
- ;;
- --direct-phys)
- DIRECT_PHYS=1
- shift
- ;;
-esac
-
-IFNAME=$1
-
-# default value set further down if not set here
-CONTAINER_IFNAME=
-if [ "$2" = "-i" ]; then
- CONTAINER_IFNAME=$3
- shift 2
-fi
-
-if [ "$2" = "-l" ]; then
- LOCAL_IFNAME=$3
- shift 2
-fi
-
-#inet or inet6
-FAMILY_FLAG="-4"
-if [ "$2" = "-a" ]; then
- FAMILY_FLAG="-$3"
- shift 2
-fi
-
-GUESTNAME=$2
-IPADDR=$3
-MACADDR=$4
-
-case "$MACADDR" in
- *@*)
- VLAN="${MACADDR#*@}"
- VLAN="${VLAN%%@*}"
- MACADDR="${MACADDR%%@*}"
- ;;
- *)
- VLAN=
- ;;
-esac
-
-# did they ask to generate a custom MACADDR?
-# generate the unique string
-case "$MACADDR" in
- U:*)
- macunique="${MACADDR#*:}"
- # now generate a 48-bit hash string from $macunique
- MACADDR=$(echo $macunique|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')
- ;;
-esac
-
-
-[ "$IPADDR" ] || [ "$WAIT" ] || {
- echo "Syntax:"
- echo "pipework <hostinterface> [-i containerinterface] [-l localinterfacename] [-a addressfamily] <guest> <ipaddr>/<subnet>[@default_gateway] [macaddr][@vlan]"
- echo "pipework <hostinterface> [-i containerinterface] [-l localinterfacename] <guest> dhcp [macaddr][@vlan]"
- echo "pipework mac:<hostinterface_macaddress> [-i containerinterface] [-l localinterfacename] [-a addressfamily] <guest> <ipaddr>/<subnet>[@default_gateway] [macaddr][@vlan]"
- echo "pipework mac:<hostinterface_macaddress> [-i containerinterface] [-l localinterfacename] <guest> dhcp [macaddr][@vlan]"
- echo "pipework route <guest> <route_command>"
- echo "pipework rule <guest> <rule_command>"
- echo "pipework tc <guest> <tc_command>"
- echo "pipework --wait [-i containerinterface]"
- exit 1
-}
-
-# Succeed if the given utility is installed. Fail otherwise.
-# For explanations about `which` vs `type` vs `command`, see:
-# http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-…
-# (Thanks to @chenhanxiao for pointing this out!)
-installed () {
- command -v "$1" >/dev/null 2>&1
-}
-
-# Google Styleguide says error messages should go to standard error.
-warn () {
- echo "$@" >&2
-}
-die () {
- status="$1"
- shift
- warn "$@"
- exit "$status"
-}
-
-if echo $IFNAME | grep -q '^mac:'; then
- mac_address=$(echo $IFNAME | cut -c5-)
- ifmatch=
- for iftest in /sys/class/net/*; do
- if [ -f $iftest/address ] && [ "$mac_address" = "$(cat $iftest/address)" ]; then
- ifmatch="$(basename $iftest)"
- break
- fi
- done
-
- if [ -z "$ifmatch" ]; then
- die 1 "Mac address $mac_address specified for interface but no host interface matched."
- else
- IFNAME=$ifmatch
- fi
-fi
-
-# First step: determine type of first argument (bridge, physical interface...),
-# Unless "--wait" is set (then skip the whole section)
-if [ -z "$WAIT" ]; then
- if [ -d "/sys/class/net/$IFNAME" ]
- then
- if [ -d "/sys/class/net/$IFNAME/bridge" ]; then
- IFTYPE=bridge
- BRTYPE=linux
- elif installed ovs-vsctl && ovs-vsctl list-br|grep -q "^${IFNAME}$"; then
- IFTYPE=bridge
- BRTYPE=openvswitch
- elif [ "$(cat "/sys/class/net/$IFNAME/type")" -eq 32 ]; then # InfiniBand IPoIB interface type 32
- IFTYPE=ipoib
- # The IPoIB kernel module is fussy, set device name to ib0 if not overridden
- CONTAINER_IFNAME=${CONTAINER_IFNAME:-ib0}
- PKEY=$VLAN
- else IFTYPE=phys
- fi
- else
- case "$IFNAME" in
- br*)
- IFTYPE=bridge
- BRTYPE=linux
- ;;
- ovs*)
- if ! installed ovs-vsctl; then
- die 1 "Need OVS installed on the system to create an ovs bridge"
- fi
- IFTYPE=bridge
- BRTYPE=openvswitch
- ;;
- route*)
- IFTYPE=route
- ;;
- rule*)
- IFTYPE=rule
- ;;
- tc*)
- IFTYPE=tc
- ;;
- dummy*)
- IFTYPE=dummy
- ;;
- *) die 1 "I do not know how to setup interface $IFNAME." ;;
- esac
- fi
-fi
-
-# Set the default container interface name to eth1 if not already set
-CONTAINER_IFNAME=${CONTAINER_IFNAME:-eth1}
-
-[ "$WAIT" ] && {
- while true; do
- # This first method works even without `ip` or `ifconfig` installed,
- # but doesn't work on older kernels (e.g. CentOS 6.X). See #128.
- grep -q '^1$' "/sys/class/net/$CONTAINER_IFNAME/carrier" && break
- # This method hopefully works on those older kernels.
- ip link ls dev "$CONTAINER_IFNAME" && break
- sleep 1
- done > /dev/null 2>&1
- exit 0
-}
-
-[ "$IFTYPE" = bridge ] && [ "$BRTYPE" = linux ] && [ "$VLAN" ] && {
- die 1 "VLAN configuration currently unsupported for Linux bridge."
-}
-
-[ "$IFTYPE" = ipoib ] && [ "$MACADDR" ] && {
- die 1 "MACADDR configuration unsupported for IPoIB interfaces."
-}
-
-# Second step: find the guest (for now, we only support LXC containers)
-while read _ mnt fstype options _; do
- [ "$fstype" != "cgroup" ] && continue
- echo "$options" | grep -qw devices || continue
- CGROUPMNT=$mnt
-done < /proc/mounts
-
-[ "$CGROUPMNT" ] || {
- die 1 "Could not locate cgroup mount point."
-}
-
-# Try to find a cgroup matching exactly the provided name.
-M=$(find "$CGROUPMNT" -name "$GUESTNAME")
-N=$(echo "$M" | wc -l)
-if [ -z "$M" ] ; then
- N=0
-fi
-case "$N" in
- 0)
- # If we didn't find anything, try to lookup the container with Docker.
- if installed docker; then
- RETRIES=3
- while [ "$RETRIES" -gt 0 ]; do
- DOCKERPID=$(docker inspect --format='{{ .State.Pid }}' "$GUESTNAME")
- DOCKERCID=$(docker inspect --format='{{ .ID }}' "$GUESTNAME")
- DOCKERCNAME=$(docker inspect --format='{{ .Name }}' "$GUESTNAME")
-
- [ "$DOCKERPID" != 0 ] && break
- sleep 1
- RETRIES=$((RETRIES - 1))
- done
-
- [ "$DOCKERPID" = 0 ] && {
- die 1 "Docker inspect returned invalid PID 0"
- }
-
- [ "$DOCKERPID" = "<no value>" ] && {
- die 1 "Container $GUESTNAME not found, and unknown to Docker."
- }
- else
- die 1 "Container $GUESTNAME not found, and Docker not installed."
- fi
- ;;
- 1) true ;;
- 2) # LXC >=3.1.0 returns two entries from the cgroups mount instead of one.
- echo "$M" | grep -q "lxc\.monitor" || die 1 "Found more than one container matching $GUESTNAME."
- ;;
- *) die 1 "Found more than one container matching $GUESTNAME." ;;
-esac
-
-# only check IPADDR if we are not in a route mode
-[ "$IFTYPE" != route ] && [ "$IFTYPE" != rule ] && [ "$IFTYPE" != tc ] && {
- case "$IPADDR" in
- # Let's check first if the user asked for DHCP allocation.
- dhcp|dhcp:*)
- # Use Docker-specific strategy to run the DHCP client
- # from the busybox image, in the network namespace of
- # the container.
- if ! [ "$DOCKERPID" ]; then
- warn "You asked for a Docker-specific DHCP method."
- warn "However, $GUESTNAME doesn't seem to be a Docker container."
- warn "Try to replace 'dhcp' with another option?"
- die 1 "Aborting."
- fi
- DHCP_CLIENT=${IPADDR%%:*}
- ;;
- udhcpc|udhcpc:*|udhcpc-f|udhcpc-f:*|dhcpcd|dhcpcd:*|dhclient|dhclient:*|dhclient-f|dhclient-f:*)
- DHCP_CLIENT=${IPADDR%%:*}
- # did they ask for the client to remain?
- DHCP_FOREGROUND=
- [ "${DHCP_CLIENT%-f}" != "${DHCP_CLIENT}" ] && {
- DHCP_FOREGROUND=true
- }
- DHCP_CLIENT=${DHCP_CLIENT%-f}
- if ! installed "$DHCP_CLIENT"; then
- die 1 "You asked for DHCP client $DHCP_CLIENT, but I can't find it."
- fi
- ;;
- # Alright, no DHCP? Then let's see if we have a subnet *and* gateway.
- */*@*)
- GATEWAY="${IPADDR#*@}" GATEWAY="${GATEWAY%%@*}"
- IPADDR="${IPADDR%%@*}"
- ;;
- # No gateway? We need at least a subnet, anyway!
- */*) : ;;
- # ... No? Then stop right here.
- *)
- warn "The IP address should include a netmask."
- die 1 "Maybe you meant $IPADDR/24 ?"
- ;;
- esac
-}
-
-# If a DHCP method was specified, extract the DHCP options.
-if [ "$DHCP_CLIENT" ]; then
- case "$IPADDR" in
- *:*) DHCP_OPTIONS="${IPADDR#*:}" ;;
- esac
-fi
-
-if [ "$DOCKERPID" ]; then
- NSPID=$DOCKERPID
-else
- NSPID=$(head -n 1 "$(find "$CGROUPMNT" -name "$GUESTNAME" | head -n 1)/tasks")
- [ "$NSPID" ] || {
- # it is an alternative way to get the pid
- NSPID=$(lxc-info -n "$GUESTNAME" | grep PID | grep -Eo '[0-9]+')
- [ "$NSPID" ] || {
- die 1 "Could not find a process inside container $GUESTNAME."
- }
- }
-fi
-
-# Check if an incompatible VLAN device already exists
-[ "$IFTYPE" = phys ] && [ "$VLAN" ] && [ -d "/sys/class/net/$IFNAME.VLAN" ] && {
- ip -d link show "$IFNAME.$VLAN" | grep -q "vlan.*id $VLAN" || {
- die 1 "$IFNAME.VLAN already exists but is not a VLAN device for tag $VLAN"
- }
-}
-
-[ ! -d /var/run/netns ] && mkdir -p /var/run/netns
-rm -f "/var/run/netns/$NSPID"
-ln -s "/proc/$NSPID/ns/net" "/var/run/netns/$NSPID"
-
-# Check if we need to create a bridge.
-[ "$IFTYPE" = bridge ] && [ ! -d "/sys/class/net/$IFNAME" ] && {
- [ "$BRTYPE" = linux ] && {
- (ip link add dev "$IFNAME" type bridge > /dev/null 2>&1) || (brctl addbr "$IFNAME")
- ip link set "$IFNAME" up
- }
- [ "$BRTYPE" = openvswitch ] && {
- ovs-vsctl add-br "$IFNAME"
- }
-}
-
-[ "$IFTYPE" != "route" ] && [ "$IFTYPE" != "dummy" ] && [ "$IFTYPE" != "rule" ] && [ "$IFTYPE" != "tc" ] && MTU=$(ip link show "$IFNAME" | awk '{print $5}')
-
-# If it's a bridge, we need to create a veth pair
-[ "$IFTYPE" = bridge ] && {
- if [ -z "$LOCAL_IFNAME" ]; then
- LOCAL_IFNAME="v${CONTAINER_IFNAME}pl${NSPID}"
- fi
- GUEST_IFNAME="v${CONTAINER_IFNAME}pg${NSPID}"
- # Does the link already exist?
- if ip link show "$LOCAL_IFNAME" >/dev/null 2>&1; then
- # link exists, is it in use?
- if ip link show "$LOCAL_IFNAME" up | grep -q "UP"; then
- echo "Link $LOCAL_IFNAME exists and is up"
- exit 1
- fi
- # delete the link so we can re-add it afterwards
- ip link del "$LOCAL_IFNAME"
- fi
- ip link add name "$LOCAL_IFNAME" mtu "$MTU" type veth peer name "$GUEST_IFNAME" mtu "$MTU"
- case "$BRTYPE" in
- linux)
- (ip link set "$LOCAL_IFNAME" master "$IFNAME" > /dev/null 2>&1) || (brctl addif "$IFNAME" "$LOCAL_IFNAME")
- ;;
- openvswitch)
- if ! ovs-vsctl list-ports "$IFNAME" | grep -q "^${LOCAL_IFNAME}$"; then
- ovs-vsctl add-port "$IFNAME" "$LOCAL_IFNAME" ${VLAN:+tag="$VLAN"} \
- -- set Interface "$LOCAL_IFNAME" \
- external-ids:pipework.interface="$LOCAL_IFNAME" \
- external-ids:pipework.bridge="$IFNAME" \
- ${DOCKERCID:+external-ids:pipework.containerid="$DOCKERCID"} \
- ${DOCKERCNAME:+external-ids:pipework.containername="$DOCKERCNAME"} \
- ${NSPID:+external-ids:pipework.nspid="$NSPID"} \
- ${VLAN:+external-ids:pipework.vlan="$VLAN"}
- fi
- ;;
- esac
- ip link set "$LOCAL_IFNAME" up
-}
-
-# If it's a physical interface, create a macvlan subinterface
-[ "$IFTYPE" = phys ] && {
- [ "$VLAN" ] && {
- [ ! -d "/sys/class/net/${IFNAME}.${VLAN}" ] && {
- ip link add link "$IFNAME" name "$IFNAME.$VLAN" mtu "$MTU" type vlan id "$VLAN"
- }
- ip link set "$IFNAME" up
- IFNAME=$IFNAME.$VLAN
- }
-
- if [ ! -z "$DIRECT_PHYS" ]; then
- GUEST_IFNAME=$IFNAME
- else
- GUEST_IFNAME=ph$NSPID$CONTAINER_IFNAME
- ip link add link "$IFNAME" dev "$GUEST_IFNAME" mtu "$MTU" type macvlan mode bridge
- fi
-
- ip link set "$IFNAME" up
-}
-
-# If it's an IPoIB interface, create a virtual IPoIB interface (the IPoIB
-# equivalent of a macvlan device)
-#
-# Note: no macvlan subinterface nor Ethernet bridge can be created on top of an
-# IPoIB interface. InfiniBand is not Ethernet. IPoIB is an IP layer on top of
-# InfiniBand, without an intermediate Ethernet layer.
-[ "$IFTYPE" = ipoib ] && {
- GUEST_IFNAME="${IFNAME}.${NSPID}"
-
- # If a partition key is provided, use it
- [ "$PKEY" ] && {
- GUEST_IFNAME="${IFNAME}.${PKEY}.${NSPID}"
- PKEY="pkey 0x$PKEY"
- }
-
- ip link add link "$IFNAME" name "$GUEST_IFNAME" type ipoib $PKEY
- ip link set "$IFNAME" up
-}
-
-# If its a dummy interface, create a dummy interface.
-[ "$IFTYPE" = dummy ] && {
- GUEST_IFNAME=du$NSPID$CONTAINER_IFNAME
- ip link add dev "$GUEST_IFNAME" type dummy
-}
-
-# If the `route` command was specified ...
-if [ "$IFTYPE" = route ]; then
- # ... discard the first two arguments and pass the rest to the route command.
- shift 2
- ip netns exec "$NSPID" ip route "$@"
-elif [ "$IFTYPE" = rule ] ; then
- shift 2
- ip netns exec "$NSPID" ip rule "$@"
-elif [ "$IFTYPE" = tc ] ; then
- shift 2
- ip netns exec "$NSPID" tc "$@"
-else
- # Otherwise, run normally.
- ip link set "$GUEST_IFNAME" netns "$NSPID"
- ip netns exec "$NSPID" ip link set "$GUEST_IFNAME" name "$CONTAINER_IFNAME"
- [ "$MACADDR" ] && ip netns exec "$NSPID" ip link set dev "$CONTAINER_IFNAME" address "$MACADDR"
-
- # When using any of the DHCP methods, we start a DHCP client in the
- # network namespace of the container. With the 'dhcp' method, the
- # client used is taken from the Docker busybox image (therefore
- # requiring no specific client installed on the host). Other methods
- # use a locally installed client.
- case "$DHCP_CLIENT" in
- dhcp)
- docker run -d --net container:$GUESTNAME --cap-add NET_ADMIN \
- busybox udhcpc -i "$CONTAINER_IFNAME" -x "hostname:$GUESTNAME" \
- $DHCP_OPTIONS \
- >/dev/null
- ;;
- udhcpc)
- DHCP_Q="-q"
- [ "$DHCP_FOREGROUND" ] && {
- DHCP_OPTIONS="$DHCP_OPTIONS -f"
- }
- ip netns exec "$NSPID" "$DHCP_CLIENT" -qi "$CONTAINER_IFNAME" \
- -x "hostname:$GUESTNAME" \
- -p "/var/run/udhcpc.$GUESTNAME.pid" \
- $DHCP_OPTIONS
- [ ! "$DHCP_FOREGROUND" ] && {
- rm "/var/run/udhcpc.$GUESTNAME.pid"
- }
- ;;
- dhclient)
- ip netns exec "$NSPID" "$DHCP_CLIENT" "$CONTAINER_IFNAME" \
- -pf "/var/run/dhclient.$GUESTNAME.pid" \
- -lf "/etc/dhclient/dhclient.$GUESTNAME.leases" \
- $DHCP_OPTIONS
- # kill dhclient after get ip address to prevent device be used after container close
- [ ! "$DHCP_FOREGROUND" ] && {
- kill "$(cat "/var/run/dhclient.$GUESTNAME.pid")"
- rm "/var/run/dhclient.$GUESTNAME.pid"
- }
- ;;
- dhcpcd)
- ip netns exec "$NSPID" "$DHCP_CLIENT" -q "$CONTAINER_IFNAME" -h "$GUESTNAME"
- ;;
- "")
- if installed ipcalc; then
- eval $(ipcalc -b $IPADDR)
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" addr add "$IPADDR" brd "$BROADCAST" dev "$CONTAINER_IFNAME"
- else
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" addr add "$IPADDR" dev "$CONTAINER_IFNAME"
- fi
-
- [ "$GATEWAY" ] && {
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" route delete default >/dev/null 2>&1 && true
- }
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" link set "$CONTAINER_IFNAME" up
- [ "$GATEWAY" ] && {
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" route get "$GATEWAY" >/dev/null 2>&1 || \
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" route add "$GATEWAY/32" dev "$CONTAINER_IFNAME"
- ip netns exec "$NSPID" ip "$FAMILY_FLAG" route replace default via "$GATEWAY" dev "$CONTAINER_IFNAME"
- }
- ;;
- esac
-
- # Give our ARP neighbors a nudge about the new interface
- if installed arping; then
- IPADDR=$(echo "$IPADDR" | cut -d/ -f1)
- ip netns exec "$NSPID" arping -c 1 -A -I "$CONTAINER_IFNAME" "$IPADDR" > /dev/null 2>&1 || true
- else
- echo "Warning: arping not found; interface may not be immediately reachable"
- fi
-fi
-# Remove NSPID to avoid `ip netns` catch it.
-rm -f "/var/run/netns/$NSPID"
-
-# vim: set tabstop=2 shiftwidth=2 softtabstop=2 expandtab :
--
To view, visit https://gerrit.osmocom.org/c/docker-playground/+/27159
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: I88ff40ca69c9ee76bef9bb8f24f66ca9d5ac751a
Gerrit-Change-Number: 27159
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: newchange
daniel has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/27108 )
Change subject: RAN_Emulation: Don't decode L3 if g_ran_ops.decode_dtap == false
......................................................................
RAN_Emulation: Don't decode L3 if g_ran_ops.decode_dtap == false
We must respect this flag not only in "normal" PDUs but also
in the code path processing the "expect" handling.
Change-Id: I04a9197ac0b68c2dcb7542d035dc70c9f2b90473
---
M library/RAN_Emulation.ttcnpp
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/library/RAN_Emulation.ttcnpp b/library/RAN_Emulation.ttcnpp
index 3158dc4..9873245 100644
--- a/library/RAN_Emulation.ttcnpp
+++ b/library/RAN_Emulation.ttcnpp
@@ -569,7 +569,7 @@
runs on RAN_Emulation_CT {
/* decode + send decoded RANAP to client */
var template (omit) octetstring l3 := f_ranap_extract_l3(ranap);
- if (istemplatekind(l3, "omit")) {
+ if (istemplatekind(l3, "omit") or not g_ran_ops.decode_dtap) {
CLIENT.send(ranap) to client;
} else {
var template (omit) SAPI sapi := f_ranap_extract_sapi(ranap);
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/27108
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I04a9197ac0b68c2dcb7542d035dc70c9f2b90473
Gerrit-Change-Number: 27108
Gerrit-PatchSet: 2
Gerrit-Owner: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
daniel has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/27107 )
Change subject: Iuh_Emulation: Introduce Iuh_ConnHdlr component type
......................................................................
Iuh_Emulation: Introduce Iuh_ConnHdlr component type
Like RAN_ConnHdlr, this contains the ports required for
a ConnHdlr attaching to Iuh_Emulaiton
Change-Id: Icbffedceb65f791306fde74f3bc5b8fe964148b9
---
M hnodeb/HNBGW_ConnectionHandler.ttcn
M library/Iuh_Emulation.ttcn
2 files changed, 8 insertions(+), 3 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/hnodeb/HNBGW_ConnectionHandler.ttcn b/hnodeb/HNBGW_ConnectionHandler.ttcn
index ac280b0..076cb82 100644
--- a/hnodeb/HNBGW_ConnectionHandler.ttcn
+++ b/hnodeb/HNBGW_ConnectionHandler.ttcn
@@ -40,10 +40,8 @@
import from GTPU_Types all;
/* this component represents a single Iuh connection at the HNBGW. */
-type component HNBGW_ConnHdlr extends StatsD_ConnHdlr, GTP_ConnHdlr {
+type component HNBGW_ConnHdlr extends Iuh_ConnHdlr, GTP_ConnHdlr, StatsD_ConnHdlr {
port TELNETasp_PT HNBVTY;
- port HNBAP_PT HNBAP;
- port RUA_PT RUA;
/* HNBLLIF Interface of HNodeB */
port HNBLLIF_CODEC_PT LLSK;
var integer g_llsk_conn_id;
diff --git a/library/Iuh_Emulation.ttcn b/library/Iuh_Emulation.ttcn
index bc8e7c3..e05afe5 100644
--- a/library/Iuh_Emulation.ttcn
+++ b/library/Iuh_Emulation.ttcn
@@ -38,6 +38,13 @@
import from IPL4asp_Types all;
import from DNS_Helpers all;
+/* General "base class" component definition, of which specific implementations
+ * derive themselves by means of the "extends" feature */
+type component Iuh_ConnHdlr {
+ port HNBAP_PT HNBAP;
+ port RUA_PT RUA;
+};
+
type enumerated IUHEM_EventUpDown {
IUHEM_EVENT_DOWN,
IUHEM_EVENT_UP
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/27107
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Icbffedceb65f791306fde74f3bc5b8fe964148b9
Gerrit-Change-Number: 27107
Gerrit-PatchSet: 2
Gerrit-Owner: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ci/+/27155 )
Change subject: scripts/docker-cleanup.sh: use "docker system prune"
......................................................................
scripts/docker-cleanup.sh: use "docker system prune"
Do not only clean up dangling images, but also containers, volumes and
networks.
Related: SYS#5827
Change-Id: If441b251de50063f0229d36fb1bc260a4cb1dd87
---
M scripts/docker-cleanup.sh
1 file changed, 2 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/55/27155/1
diff --git a/scripts/docker-cleanup.sh b/scripts/docker-cleanup.sh
index 90b32b9..34a98b2 100755
--- a/scripts/docker-cleanup.sh
+++ b/scripts/docker-cleanup.sh
@@ -12,4 +12,5 @@
docker rm $CONTAINERS
fi
-docker image prune -f
+# remove dangling images, containers, volumes, and networks (not tagged or associated with a container)
+docker system prune -f
--
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/27155
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: If441b251de50063f0229d36fb1bc260a4cb1dd87
Gerrit-Change-Number: 27155
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: newchange
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ci/+/27156 )
Change subject: scripts/docker-cleanup.sh: conditional img clean
......................................................................
scripts/docker-cleanup.sh: conditional img clean
Only run the simple image clean code if docuum is not running. It works
well enough in most cases, but has the drawbacks that it never deletes
"latest" images or images not matching "^osmocom-build", and may delete
images that are still being used (OS#5447). With the other tool, all
images are considered for removal, and the ones that have not been used
the longest time are removed first.
Related: OS#5477, OS#5066, SYS#5827
Change-Id: I1cef0833c096de0fa5acf77156bb5dd362e2ef9c
---
M scripts/docker-cleanup.sh
1 file changed, 7 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/56/27156/1
diff --git a/scripts/docker-cleanup.sh b/scripts/docker-cleanup.sh
index 34a98b2..7336ed2 100755
--- a/scripts/docker-cleanup.sh
+++ b/scripts/docker-cleanup.sh
@@ -1,10 +1,13 @@
#!/bin/sh -x
+# simple image cleaning code in case docuum isn't running
# delete all but the latest images
-IMAGES=`docker image ls | grep \^osmocom-build | grep -v latest | awk -F ' ' '{print $1":"$2}'`
-for f in $IMAGES; do
- docker image rm $f
-done
+if [ -z "$(docker ps -q -f name=docuum)" ]; then
+ IMAGES=`docker image ls | grep \^osmocom-build | grep -v latest | awk -F ' ' '{print $1":"$2}'`
+ for f in $IMAGES; do
+ docker image rm $f
+ done
+fi
# delete all containers where we forgot to use --rm with docker run
CONTAINERS="$(docker ps -q -a -f status=exited -f status=created)"
--
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/27156
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I1cef0833c096de0fa5acf77156bb5dd362e2ef9c
Gerrit-Change-Number: 27156
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: newchange
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ci/+/27157 )
Change subject: ansible: docker: clean vfs storage leftovers
......................................................................
ansible: docker: clean vfs storage leftovers
Docker is configured via ansible to use the overlay2 storage driver
since August 2020 (I20728d6017204c3978e23376baa89de6e91fed1e). Clean up
an unused vfs dir if it is present on the system, as it was the case on
build2-deb9build-ansible with a 190 GiB vfs dir.
Related: OS#5827
Change-Id: I58f3f4a26ad6fa4698d87475cefb6ab21e66b15a
---
M ansible/roles/docker/tasks/main.yml
1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/57/27157/1
diff --git a/ansible/roles/docker/tasks/main.yml b/ansible/roles/docker/tasks/main.yml
index 97df86a..7c7fe85 100644
--- a/ansible/roles/docker/tasks/main.yml
+++ b/ansible/roles/docker/tasks/main.yml
@@ -52,6 +52,10 @@
dest: /etc/docker/daemon.json
notify: restart docker
+# daemon.json configures overlay2 storage driver, clean up vfs leftovers
+- name: cleanup vfs storage dir
+ shell: "docker info | grep -q 'Storage Driver: overlay2' && rm -rf /var/lib/docker/vfs"
+
# After docker is set up, add docuum to clean old docker images
# x86_64 only, as the raspberries need to be upgraded before they can use recent docker images (OS#5453)
- include: docuum.yml
--
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/27157
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I58f3f4a26ad6fa4698d87475cefb6ab21e66b15a
Gerrit-Change-Number: 27157
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: newchange
osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ci/+/27150 )
Change subject: ansible/ansible.cfg: make command output readable
......................................................................
ansible/ansible.cfg: make command output readable
Have a readable output, instead of the default that wraps the output
with stripped new lines inside json.
Related: https://github.com/ansible/ansible/issues/27078#issuecomment-364560173
Change-Id: I88d584a1808d82d75906b350e3bffe9bc73a8c67
---
A ansible/ansible.cfg
1 file changed, 2 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/50/27150/1
diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg
new file mode 100644
index 0000000..11169e6
--- /dev/null
+++ b/ansible/ansible.cfg
@@ -0,0 +1,2 @@
+[defaults]
+stdout_callback=debug
--
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/27150
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I88d584a1808d82d75906b350e3bffe9bc73a8c67
Gerrit-Change-Number: 27150
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: newchange