Merge "Ethernet interfaces may not be named as ethX"
This commit is contained in:
commit
56d5184eff
@ -58,7 +58,38 @@ get_bootdev() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_alldevs() {
|
get_alldevs() {
|
||||||
ip link|grep -oE 'eth[0-9]+'|sort|uniq
|
# Take all not virtual network devices given by links (to omit files)
|
||||||
|
# Choose ethernet, but exclude wireless, bond, vlan, loopback, tunnels ...
|
||||||
|
for DEV in /sys/class/net/* ; do
|
||||||
|
# Take only links into account, skip files
|
||||||
|
if test ! -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 test -d $DEV/wireless -o -L $DEV/phy80211 ;
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
# Catch ethernet non-virtual device
|
||||||
|
echo $IF
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*) continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
set_interfaces_up_when_booted() {
|
set_interfaces_up_when_booted() {
|
||||||
|
@ -14,9 +14,49 @@ function fail() {
|
|||||||
echo "ERROR: Fuel node deployment FAILED! Check /var/log/puppet/bootstrap_admin_node.log for details" 1>&2
|
echo "ERROR: Fuel node deployment FAILED! Check /var/log/puppet/bootstrap_admin_node.log for details" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_ethernet_interfaces() {
|
||||||
|
# Get list of all ethernet interfaces, non-virtual, not a wireless
|
||||||
|
for DEV in /sys/class/net/* ; do
|
||||||
|
# Take only links into account, skip files
|
||||||
|
if test ! -L $DEV ; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
DEVPATH=$(readlink -f $DEV)
|
||||||
|
# Avoid 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, bond, tunnel ...
|
||||||
|
# Virtual lo, bound, vlan, tunneling has been skipped before
|
||||||
|
if test -d $DEV/wireless -o -L $DEV/phy80211 ;
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
# Catch ethernet non-virtual device
|
||||||
|
echo $IF
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*) continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# LANG variable is a workaround for puppet-3.4.2 bug. See LP#1312758 for details
|
# LANG variable is a workaround for puppet-3.4.2 bug. See LP#1312758 for details
|
||||||
export LANG=en_US.UTF8
|
export LANG=en_US.UTF8
|
||||||
export ADMIN_INTERFACE=eth0
|
# Be sure, that network devices have been initialized
|
||||||
|
udevadm trigger --subsystem-match=net
|
||||||
|
udevadm settle
|
||||||
|
# Take the very first ethernet interface as an admin interface
|
||||||
|
ADMIN_INTERFACE=$(get_ethernet_interfaces | sort -V | head -1)
|
||||||
|
export ADMIN_INTERFACE
|
||||||
|
|
||||||
showmenu="no"
|
showmenu="no"
|
||||||
if [ -f /etc/fuel/bootstrap_admin_node.conf ]; then
|
if [ -f /etc/fuel/bootstrap_admin_node.conf ]; then
|
||||||
|
@ -366,6 +366,40 @@ function save_cfg {
|
|||||||
[ -n "$build_images" -a "$build_images" != "0" ] && echo -e "$build_images" > /root/.build_images
|
[ -n "$build_images" -a "$build_images" != "0" ] && echo -e "$build_images" > /root/.build_images
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_ethernet_interfaces() {
|
||||||
|
# Get list of all ethernet interfaces, non-virtual, not a wireless
|
||||||
|
for DEV in /sys/class/net/* ; do
|
||||||
|
# Take only links into account, skip files
|
||||||
|
if test ! -L $DEV ; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
DEVPATH=$(readlink -f $DEV)
|
||||||
|
# Avoid 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, bond, tunnel ...
|
||||||
|
# Virtual lo, bound, vlan, tunneling has been skipped before
|
||||||
|
if test -d $DEV/wireless -o -L $DEV/phy80211 ;
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
# Catch ethernet non-virtual device
|
||||||
|
echo $IF
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*) continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Default FQDN
|
# Default FQDN
|
||||||
hostname="nailgun.mirantis.com"
|
hostname="nailgun.mirantis.com"
|
||||||
|
|
||||||
@ -375,7 +409,8 @@ domain=${hostname#*.}
|
|||||||
ip=$ip
|
ip=$ip
|
||||||
netmask=$netmask
|
netmask=$netmask
|
||||||
gw=$gw
|
gw=$gw
|
||||||
admin_interface=${admin_interface:-"eth0"}
|
first_eth_intf=$(get_ethernet_interfaces | sort -V | head -1)
|
||||||
|
admin_interface=${admin_interface:-$first_eth_intf}
|
||||||
hwaddr=`ifconfig $admin_interface | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'`
|
hwaddr=`ifconfig $admin_interface | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'`
|
||||||
dhcp_interface=$dhcp_interface
|
dhcp_interface=$dhcp_interface
|
||||||
build_images=$build_images
|
build_images=$build_images
|
||||||
@ -544,8 +579,45 @@ EOF
|
|||||||
|
|
||||||
|
|
||||||
cat >> '/etc/rc.local' << EOF
|
cat >> '/etc/rc.local' << EOF
|
||||||
|
#Collect info about network addresses
|
||||||
|
function get_ethernet_interfaces() {
|
||||||
|
# Return IP addresses for ethernet interfaces
|
||||||
|
# exclude wireless, bond, vlan, loopback, tunnels ...
|
||||||
|
for DEV in /sys/class/net/* ; do
|
||||||
|
# Take only links into account, skip files
|
||||||
|
if test ! -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 test -d \$DEV/wireless -o -L \$DEV/phy80211 ;
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
# Catch ethernet non-virtual device
|
||||||
|
# Get IP address if assigned
|
||||||
|
echo $IF
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*) continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
first=yes
|
first=yes
|
||||||
for ip in \$(ip -o -4 addr | grep "eth." | awk '{print \$4 }' | cut -d/ -f1); do
|
for intf in \$(get_ethernet_interfaces()) ; do
|
||||||
|
ip = "\$ip_list |\$(ip -4 -o addr show dev \$intf | awk '{ print \$4 }' | cut -d/ -f1)"
|
||||||
if [ "\$first" = "yes" ]; then
|
if [ "\$first" = "yes" ]; then
|
||||||
ipstr="Fuel UI is available on: https://\$ip:8443"
|
ipstr="Fuel UI is available on: https://\$ip:8443"
|
||||||
first=no
|
first=no
|
||||||
|
Loading…
Reference in New Issue
Block a user