diff --git a/contrib/fuel_bootstrap/files/trusty/etc/rc.local b/contrib/fuel_bootstrap/files/trusty/etc/rc.local index bb5d7a83..5f4a4052 100755 --- a/contrib/fuel_bootstrap/files/trusty/etc/rc.local +++ b/contrib/fuel_bootstrap/files/trusty/etc/rc.local @@ -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 diff --git a/contrib/fuel_bootstrap/files/trusty/lib/udev/rules.d/80-net-name-slot.rules b/contrib/fuel_bootstrap/files/trusty/lib/udev/rules.d/80-net-name-slot.rules index c5f1b388..15b5bc41 100755 --- a/contrib/fuel_bootstrap/files/trusty/lib/udev/rules.d/80-net-name-slot.rules +++ b/contrib/fuel_bootstrap/files/trusty/lib/udev/rules.d/80-net-name-slot.rules @@ -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" diff --git a/contrib/fuel_bootstrap/files/trusty/usr/bin/let-rename b/contrib/fuel_bootstrap/files/trusty/usr/bin/let-rename deleted file mode 100755 index 54b7b1ed..00000000 --- a/contrib/fuel_bootstrap/files/trusty/usr/bin/let-rename +++ /dev/null @@ -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 diff --git a/contrib/fuel_bootstrap/files/trusty/usr/share/initramfs-tools/hooks/netifnames b/contrib/fuel_bootstrap/files/trusty/usr/share/initramfs-tools/hooks/netifnames index 248a0c5a..d2421583 100755 --- a/contrib/fuel_bootstrap/files/trusty/usr/share/initramfs-tools/hooks/netifnames +++ b/contrib/fuel_bootstrap/files/trusty/usr/share/initramfs-tools/hooks/netifnames @@ -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 diff --git a/specs/fuel-agent.spec b/specs/fuel-agent.spec index 9edc45ae..bb714980 100644 --- a/specs/fuel-agent.spec +++ b/specs/fuel-agent.spec @@ -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