TT#37257 Add all the network interfaces to udev rules

Our goal is to separate installation and configuration parts so
any network related things have to be configured after the installation
and reboot. But during the deployment.sh we need to configure one
interface which will be used after the reboot. So we need consistent
interfaces' name between reboot.

Change-Id: Ib4cd19bf0455c1365a2d33fc5a90209d0a5d62d7
changes/42/22042/7
Mykola Malkov 8 years ago
parent 9a36eda850
commit 9ee8fa8148

@ -1319,20 +1319,36 @@ ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF
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}')
get_network_devices () {
# get list of available network devices (excl. some known-to-be-irrelevant ones, also see MT#8297)
net_devices=$(tail -n +3 /proc/net/dev | awk -F: '{print $1}'| sed "s/\s*//" | grep -ve '^vmnet' -ve '^vboxnet' -ve '^docker' -ve '^usb' | sort -u)
NETWORK_DEVICES=""
for network_device in ${net_devices} ${DEFAULT_INSTALL_DEV} ${INTERNAL_DEV} ${EXTERNAL_DEV} ; do
# avoid duplicates
echo "${NETWORK_DEVICES}" | grep -wq "${network_device}" || NETWORK_DEVICES="${NETWORK_DEVICES} ${network_device}"
done
export NETWORK_DEVICES
unset net_devices
}
if [ "$INT_MAC" = "$EXT_MAC" ] ; then
die "Error: MAC address for $INTERNAL_DEV is same as for $EXTERNAL_DEV"
fi
get_network_devices
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
if "$PRO_EDITION" && [[ $(imvirt) != "Physical" ]] ; then
echo "Generating udev persistent net rules."
echo "## Generated by Sipwise deployment script" > \
"${TARGET}/etc/udev/rules.d/70-persistent-net.rules"
for dev in ${NETWORK_DEVICES}; do
[[ "${dev}" =~ ^(vlan|bond|lo) ]] && continue
mac=$(udevadm info -a -p "/sys/class/net/${dev}" | sed -nr 's/^ *ATTR\{address\}=="(.+)".*$/\1/p')
if [[ "${mac}" =~ ^([0-9A-Fa-f]{2}:){3}[0-9A-Fa-f]{2}$ ]]; then
echo "Adding device '${dev}' with MAC '${mac}'"
cat >> "${TARGET}/etc/udev/rules.d/70-persistent-net.rules" <<EOL
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="${mac}", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="${dev}"
EOL
fi
done
unset mac
fi
if "$RETRIEVE_MGMT_CONFIG" ; then
@ -1464,19 +1480,6 @@ deb ${DBG_MIRROR} ${DEBIAN_RELEASE}-debug main contrib non-free
EOF
}
get_network_devices () {
# get list of available network devices (excl. some known-to-be-irrelevant ones, also see MT#8297)
net_devices=$(tail -n +3 /proc/net/dev | awk -F: '{print $1}'| sed "s/\s*//" | grep -ve '^vmnet' -ve '^vboxnet' -ve '^docker' -ve '^usb' | sort -u)
NETWORK_DEVICES=""
for network_device in $net_devices $DEFAULT_INSTALL_DEV $INTERNAL_DEV $EXTERNAL_DEV ; do
# avoid duplicates
echo "$NETWORK_DEVICES" | grep -wq "$network_device" || NETWORK_DEVICES="$NETWORK_DEVICES $network_device"
done
export NETWORK_DEVICES
unset net_devices
}
gen_installer_config () {
mkdir -p "${TARGET}/etc/ngcp-installer/"
@ -1508,7 +1511,6 @@ EOF
fi
if "$PRO_EDITION" ; then
get_network_devices
cat >> ${TARGET}/etc/ngcp-installer/config_deploy.inc << EOF
HNAME="${ROLE}"
IP1="${IP1}"

Loading…
Cancel
Save