modify genesis to support system P hardware discovery

This commit is contained in:
zhaoertao 2014-09-05 02:10:54 -07:00
parent 447b31ee60
commit 0f4a674527
3 changed files with 55 additions and 8 deletions

View File

@ -38,4 +38,23 @@ if grep console=ttyS /proc/cmdline > /dev/null; then
while :; do sleep 1; screen -x console < /dev/tty1 > /dev/tty1 2>&1; clear; done &
fi
while :; do screen -ln < /dev/tty2 > /dev/tty2 2>&1; done &
# The section below is just for System P LE hardware discovery
# Need to wait for NIC initialization
sleep 20
ARCH=`uname -m`
if [ $ARCH == 'ppc64' ]; then
ALL_NICS=`ip link show | grep -v "^ " | awk '{print $2}' | sed -e 's/:$//' | grep -v lo`
for tmp in $ALL_NICS; do
tmp_data=`ip link show $tmp | grep -v "^ " | grep "UP"`
if [ "$tmp_data" == "" ]; then
ip link set $tmp up
fi
tmp_data="UP"
sleep 1
done
fi
while :; do screen -L -ln doxcat; done

View File

@ -71,10 +71,26 @@ if [ -r /sys/devices/virtual/dmi/id/product_name ]; then #x86
MTM=`cat /sys/devices/virtual/dmi/id/product_name|awk -F'[' '{print $2}'|awk -F']' '{print $1}'`
SERIAL=`cat /sys/devices/virtual/dmi/id/product_serial`
fi
CPUCOUNT=`cat /proc/cpuinfo |grep "model name"|wc -l`
grep "model name" /proc/cpuinfo | while read line; do #to avoid pulling in tail, we do a goofy thing
echo $line > /tmp/cpumod
done
CPUTYPE=`cat /tmp/cpumod|awk -F':' '{print $2}'|sed -e 's/^ //'`
UUID=`sed -e 's/\(..\)\(..\)\(..\)\(..\)-\(..\)\(..\)-\(..\)\(..\)/\4\3\2\1-\6\5-\8\7/' /sys/devices/virtual/dmi/id/product_uuid`
elif [ -r /proc/device-tree/model ]; then #POWER
MTM=`cat /proc/device-tree/model |awk -F, '{print $2}'`
#MTM=`cat /proc/device-tree/model |awk -F, '{print $2}'`
MTM=`cat /proc/device-tree/model | sed -e 's/\^.*,//'`
CPUCOUNT=`cat /proc/cpuinfo |grep -e "^cpu\s*:"|wc -l`
grep -e "^cpu\s*:" /proc/cpuinfo | while read line; do #to avoid pulling in tail, we do a goofy thing
echo $line > /tmp/cpumod
done
CPUTYPE=`cat /tmp/cpumod|awk -F':' '{print $2}'|sed -e 's/^ //'`
SERIAL=`cat /proc/device-tree/system-id`
UUID=`sed -e 's/\(..\)\(..\)\(..\)\(..\)-\(..\)\(..\)-\(..\)\(..\)/\4\3\2\1-\6\5-\8\7/' /proc/sys/kernel/random/uuid`
fi
CPUCOUNT=`cat /proc/cpuinfo |grep "model name"|wc -l`
#CPUCOUNT=`cat /proc/cpuinfo |grep "model name"|wc -l`
# The MEMORY will look like this: 32868920
MEMORY=`cat /proc/meminfo |grep MemTotal|awk '{printf "%.0fMB\n", $2/1024}'`
@ -86,11 +102,11 @@ MEMORY=`cat /proc/meminfo |grep MemTotal|awk '{printf "%.0fMB\n", $2/1024}'`
# The DISKSIZE will look like this: sdb:250GB,sda:250GB
DISKSIZE=`cat /proc/partitions |grep -e "sd.\>" |awk -F' ' '{printf "%s:%.0fGB\n", $4, $3*0.000001024}' |sed 'N;s/\n/,/'`
UUID=`sed -e 's/\(..\)\(..\)\(..\)\(..\)-\(..\)\(..\)-\(..\)\(..\)/\4\3\2\1-\6\5-\8\7/' /sys/devices/virtual/dmi/id/product_uuid`
grep "model name" /proc/cpuinfo | while read line; do #to avoid pulling in tail, we do a goofy thing
echo $line > /tmp/cpumod
done
CPUTYPE=`cat /tmp/cpumod|awk -F':' '{print $2}'|sed -e 's/^ //'`
#UUID=`sed -e 's/\(..\)\(..\)\(..\)\(..\)-\(..\)\(..\)-\(..\)\(..\)/\4\3\2\1-\6\5-\8\7/' /sys/devices/virtual/dmi/id/product_uuid`
#grep "model name" /proc/cpuinfo | while read line; do #to avoid pulling in tail, we do a goofy thing
# echo $line > /tmp/cpumod
#done
#CPUTYPE=`cat /tmp/cpumod|awk -F':' '{print $2}'|sed -e 's/^ //'`
echo '<xcatrequest>' > /tmp/discopacket
echo "<command>findme</command>" >> /tmp/discopacket
echo "<arch>$ARCH</arch>" >> /tmp/discopacket
@ -101,7 +117,10 @@ echo "<cpucount>$CPUCOUNT</cpucount>" >> /tmp/discopacket
echo "<cputype>$CPUTYPE</cputype>" >> /tmp/discopacket
echo "<memory>$MEMORY</memory>" >> /tmp/discopacket
echo "<disksize>$DISKSIZE</disksize>" >> /tmp/discopacket
echo "<uuid>$UUID</uuid>" >> /tmp/discopacket
if [ "$UUID" != "unknown" ]; then
echo "<uuid>$UUID</uuid>" >> /tmp/discopacket
fi
if [ "$MTM" != "unknown" ]; then
echo "<mtm>$MTM</mtm>" >> /tmp/discopacket
fi

View File

@ -145,6 +145,15 @@ if [[ -n $hostip && -n $netmask && -n $gateway && -n $bootnic ]]; then
sleep 3
else
echo "Setting IP via DHCP..."
# This section is for System P hardware discovery, which won't have a BOOTIF value set
if [ -z "$bootnic" ]; then
ALLUP_NICS=`ip link show | grep -v "^ " | grep "state UP" | awk '{print $2}' | sed -e 's/:$//'|grep -v lo`
for tmp1 in $ALLUP_NICS; do
bootnic=$tmp1
break
done
fi
dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$bootnic.pid $bootnic &
#we'll kick of IPv6 and IPv4 on all nics, but not wait for them to come up unless doing discovery, to reduce
#chances that we'll perform a partial discovery