From f145200fa08a64c5acaae3b89698f2e48ccc6c66 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 26 Sep 2012 19:18:11 +0000 Subject: [PATCH] deployment: generate udev rules before messing with network setup The udev rules need the real MAC addresses and we can't mess with them before the rules are in place Thanks Richard for helping with debugging From: Michael Prokop --- deployment.sh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/deployment.sh b/deployment.sh index bb9df98..88fb590 100755 --- a/deployment.sh +++ b/deployment.sh @@ -839,6 +839,20 @@ if "$PRO_EDITION" ; then fi fi +if "$PRO_EDITION" && [[ $(imvirt) != "Physical" ]] ; then + echo "Generating udev persistent net rules." + INT_MAC=$(udevadm info -a -p /sys/class/net/${INTERNAL_DEV} | awk -F== '/ATTR{address}/ {print $2}') + EXT_MAC=$(udevadm info -a -p /sys/class/net/${EXTERNAL_DEV} | awk -F== '/ATTR{address}/ {print $2}') + + cat > $TARGET/etc/udev/rules.d/70-persistent-net.rules << EOF +## Generated by Sipwise deployment script +SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}==$INT_MAC, ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="$INTERNAL_DEV" +SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}==$EXT_MAC, ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="$EXTERNAL_DEV" +EOF +fi + +# needs to be executed *after* udev rules have been set up, +# otherwise we get duplicated MAC address<->device name mappings if "$RETRIEVE_NETWORK_CONFIG" ; then echo "Retrieving network configuration from management server" wget --timeout=30 -O /etc/network/interfaces "${MANAGEMENT_IP}:3000/nwconfig/$(cat ${TARGET}/etc/hostname)" @@ -854,17 +868,6 @@ if "$RETRIEVE_NETWORK_CONFIG" ; then done fi -if "$PRO_EDITION" && [[ $(imvirt) != "Physical" ]] ; then - echo "Generating udev persistent net rules." - INT_MAC=$(udevadm info -a -p /sys/class/net/${INTERNAL_DEV} | awk -F== '/ATTR{address}/ {print $2}') - EXT_MAC=$(udevadm info -a -p /sys/class/net/${EXTERNAL_DEV} | awk -F== '/ATTR{address}/ {print $2}') - - cat > $TARGET/etc/udev/rules.d/70-persistent-net.rules << EOF -## Generated by Sipwise deployment script -SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}==$INT_MAC, ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="$INTERNAL_DEV" -SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}==$EXT_MAC, ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="$EXTERNAL_DEV" -EOF -fi if "$NGCP_INSTALLER" ; then