Revert the work-around for renaming PXE interface on Ubuntu bootstrap
The fix for the renaming interface used on PXE boot of Ubuntu bootstrap is in the live-boot_4.0.2-1~u14.04+mos2 package. We don't need this work-around any more. Related to the LP #1529631 and LP #1528275. Depends-On: I7ddc1ac41813747ae0285900a3540f39b89161cb Change-Id: I4eaca76175e6df308b819c7f06ff057318f3115b Related-Bug: #1529631 Related-Bug: #1528275
This commit is contained in:
parent
6c0801f2eb
commit
469b68b83b
|
@ -1,8 +1,5 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# Apply work-around for net.ifnames
|
||||
let-rename || true
|
||||
|
||||
# Perform fuel bootstrap configuration
|
||||
fix-configs-on-startup || true
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# do not edit this file, it will be overwritten on update
|
||||
|
||||
ACTION!="add", GOTO="net_name_slot_end"
|
||||
ACTION=="remove", GOTO="net_name_slot_end"
|
||||
SUBSYSTEM!="net", GOTO="net_name_slot_end"
|
||||
NAME!="", GOTO="net_name_slot_end"
|
||||
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The script let remane ethernet interfaces
|
||||
#
|
||||
# The kernel parameters biosdevname=0 net.ifnames=1 are passing on boot
|
||||
# enable persistent interface naming schema and disable
|
||||
# 75-persistent-net-generator.rules bounding MAC and interface name
|
||||
#
|
||||
# The interface is used for PXE booting is eth0 interface (because it becomes up
|
||||
# the very first).
|
||||
# Since Ubuntu uses Upstart-udev-bridge to communicate to udev the udev events
|
||||
# (renaming interfaces) are processed quite later, when the eth0 interface is
|
||||
# in the UP state and /etc/network/interfaces (config file) has been created.
|
||||
# When udev attempts to rename the eth0 interface it receives "device busy"
|
||||
# message (because eth0 is in UP state).
|
||||
# To let the eth0 interface be renamed the following steps are used in
|
||||
# the /usr/bin/let-rename script:
|
||||
#
|
||||
# 1. Scan the interfaces to figure out which one is in the active (UP) state and
|
||||
# has not been renamed. Because we have just one PXE interface, we are looking
|
||||
# for that interface (all others in the down state).
|
||||
# 2. The state of the found interface is changed to DOWN (release DHCP leases) by the
|
||||
# command:
|
||||
# ifdown $intf
|
||||
# 3. The current interface name ($oldname) and MAC address ($macaddr) of the
|
||||
# interface are saved and will be handy later.
|
||||
# 4. The udev event (for subsystem net, action add) is issued, which forces
|
||||
# renaming of the eth0 to a new name by the commands:
|
||||
# udevadm trigger --subsystem-match=net --action=add
|
||||
# udevadm settle
|
||||
# 5. At that point interface's name (eth0) has been changed and we are looking
|
||||
# for interface which MAC address is equal to the remembered MAC address of
|
||||
# the former eth0. Found new name (of the renamed eth0 interface) is saved in
|
||||
# the $newname variable.
|
||||
# 6. Update /etc/network/interfaces (config file) by substituting all $oldname
|
||||
# of the interface to the $newname by the command:
|
||||
# sed -i -e "s/$oldname/$newname/g" /etc/network/interfaces
|
||||
# 7. Enabling the renamed interface by the command
|
||||
# ifup $newname
|
||||
|
||||
NET_CONF_FILE='/etc/network/interfaces'
|
||||
|
||||
get_eth_interfaces() {
|
||||
for DEV in /sys/class/net/* ; do
|
||||
# Take only links into account, skip files
|
||||
if [ ! -L $DEV ]; then
|
||||
continue
|
||||
fi
|
||||
DEVPATH=$(readlink -f $DEV)
|
||||
# Drop virtual devices like loopback, tunnels, bonding, vlans ...
|
||||
case $DEVPATH in
|
||||
*/virtual/*)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
IF=${DEVPATH##*/}
|
||||
# Check ethernet only
|
||||
case "$(cat $DEV/type)" in
|
||||
1)
|
||||
# TYPE=1 is ethernet, may also be wireless
|
||||
# Virtual (lo, bound, vlan, tunnel ...) have been skipped before
|
||||
if [ -d $DEV/wireless -o -L $DEV/phy80211 ]; then
|
||||
continue
|
||||
else
|
||||
# Catch ethernet non-virtual device
|
||||
echo $IF
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
get_interface_name_by_mac() {
|
||||
local mac="$1"
|
||||
if [ -z $mac ] ; then
|
||||
exit 1;
|
||||
fi
|
||||
for DEV in /sys/class/net/* ; do
|
||||
DEVPATH=$(readlink -f $DEV)
|
||||
if [ "$mac" == "$(cat $DEV/address)" ] ; then
|
||||
echo "${DEVPATH##*/}"
|
||||
break
|
||||
else
|
||||
continue
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
for intf in $(get_eth_interfaces) ; do
|
||||
# Remember old interface name and MAC address
|
||||
# The name might be changed due to renaming
|
||||
if [ "up" == "$(cat /sys/class/net/$intf/operstate)" ] ; then
|
||||
# Remember the interface name and MAC
|
||||
oldname="$intf"
|
||||
macaddr="$(cat /sys/class/net/$intf/address)"
|
||||
/usr/bin/logger -i -t let-rename "The old interface name is $oldname"
|
||||
/usr/bin/logger -i -t let-rename "The MAC address of the interface is $macaddr"
|
||||
|
||||
# Down interface to let udev rename it
|
||||
ifdown "$intf"
|
||||
udevadm trigger --subsystem-match=net --action=add
|
||||
udevadm settle
|
||||
# Get new name based on MAC address of the interface
|
||||
newname=$(get_interface_name_by_mac "$macaddr")
|
||||
/usr/bin/logger -i -t let-rename "New interface name is $newname"
|
||||
# Work-around for renaming interface in config files
|
||||
sed -i -e "s/$oldname/$newname/g" $NET_CONF_FILE
|
||||
ifup $newname
|
||||
fi
|
||||
done
|
||||
exit 0
|
|
@ -15,7 +15,7 @@ esac
|
|||
|
||||
RULES=80-net-name-slot.rules
|
||||
if [ -e /etc/udev/rules.d/$RULES ]; then
|
||||
cp -p /etc/udev/rules.d/$RUlES $DESTDIR/lib/udev/rules.d/
|
||||
cp -p /etc/udev/rules.d/$RULES $DESTDIR/lib/udev/rules.d/
|
||||
elif [ -e /lib/udev/rules.d/$RULES ]; then
|
||||
cp -p /lib/udev/rules.d/$RULES $DESTDIR/lib/udev/rules.d/
|
||||
fi
|
||||
|
|
|
@ -124,6 +124,4 @@ rm -rf $RPM_BUILD_ROOT
|
|||
%attr(0755,root,root) %{_datadir}/fuel_bootstrap_cli/files/trusty/usr/bin/fix-configs-on-startup
|
||||
%attr(0755,root,root) %{_datadir}/fuel_bootstrap_cli/files/trusty/usr/bin/send2syslog.py
|
||||
%attr(0755,root,root) %{_datadir}/fuel_bootstrap_cli/files/trusty/etc/rc.local
|
||||
%attr(0755,root,root) %{_datadir}/fuel_bootstrap_cli/files/trusty/usr/bin/let-rename
|
||||
%attr(0755,root,root) %{_datadir}/fuel_bootstrap_cli/files/trusty/lib/udev/rules.d/80-net-name-slot.rules
|
||||
%attr(0755,root,root) %{_datadir}/fuel_bootstrap_cli/files/trusty/usr/share/initramfs-tools/hooks/netifnames
|
||||
|
|
Loading…
Reference in New Issue