Skip to content

Commit

Permalink
try the BIOS UUID
Browse files Browse the repository at this point in the history
  • Loading branch information
rade committed Jan 11, 2016
1 parent 2c2d8af commit 434a876
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions weave
Expand Up @@ -18,8 +18,6 @@ IMAGE_VERSION=${WEAVE_VERSION:-$IMAGE_VERSION}
MIN_DOCKER_VERSION=1.6.0

# These are needed for remote execs, hence we introduce them here
MACHINE_ID1=/etc/machine-id
MACHINE_ID2=/var/lib/dbus/machine-id
DOCKERHUB_USER=${DOCKERHUB_USER:-weaveworks}
BASE_EXEC_IMAGE=$DOCKERHUB_USER/weaveexec
EXEC_IMAGE=$BASE_EXEC_IMAGE:$IMAGE_VERSION
Expand Down Expand Up @@ -113,7 +111,7 @@ docker_sock_options() {
exec_remote() {
docker $DOCKER_CLIENT_ARGS run --rm --privileged --net=host \
$(docker_sock_options) \
-v /proc:/hostproc -v $MACHINE_ID1:$MACHINE_ID1 -v $MACHINE_ID2:$MACHINE_ID2 \
-v /proc:/hostproc \
-e PROCFS=/hostproc \
-e DOCKERHUB_USER="$DOCKERHUB_USER" \
-e WEAVE_VERSION \
Expand Down Expand Up @@ -342,8 +340,6 @@ PLUGIN_IMAGE=$BASE_PLUGIN_IMAGE:$IMAGE_VERSION
PLUGIN_CONTAINER_NAME=weaveplugin

PROCFS=${PROCFS:-/proc}
[ -z "$MACHINE_ID" -a -f $MACHINE_ID1 ] && MACHINE_ID=$(cat $MACHINE_ID1 2>/dev/null) || true
[ -z "$MACHINE_ID" -a -f $MACHINE_ID2 ] && MACHINE_ID=$(cat $MACHINE_ID2 2>/dev/null) || true
DOCKER_BRIDGE=${DOCKER_BRIDGE:-docker0}
CONTAINER_NAME=${WEAVE_CONTAINER_NAME:-weave}
BRIDGE=weave
Expand Down Expand Up @@ -1512,14 +1508,12 @@ launch_router() {
enforce_docker_bridge_addr_assign_type
create_bridge
docker_bridge_ip
# Derive the router name from the machine id, if present, since
# that is stable across reboots. Otherwise set it to the bridge
# MAC since at least that is stable across router re-launches.
if [ -n "$MACHINE_ID" ] ; then
# first 6 bytes of $MACHINE_ID (which is 16 bytes, represented
# as a 32-digit hex string), in MAC notation
PEERNAME=$(echo "$MACHINE_ID" | sed 's/\(.\{2\}\)/\1:/g' | cut -c1-17)
else
# Derive the router name from the BIOS UUID, if present, since
# that is stable across reboots, unique across VMs (unlike, say,
# /etc/machine-id, which is often identical on VMs created from
# cloned filesystems). Otherwise set it to the bridge MAC since
# at least that is stable across router re-launches.
if ! PEERNAME=$(cat /sys/class/dmi/id/product_uuid 2>/dev/null | sha256sum | sed 's/\(.\{2\}\)/\1:/g' | cut -c1-17) ; then
PEERNAME=$(cat /sys/class/net/$BRIDGE/address)
fi
# backward compatibility...
Expand Down

0 comments on commit 434a876

Please sign in to comment.