From e1203eccf277c658798d3bc9a715677a0e04f9b8 Mon Sep 17 00:00:00 2001 From: NoBodyCam Date: Tue, 20 Nov 2012 14:05:20 -0800 Subject: [PATCH] adding BASIC hardware discovery. --- flavours/hwdiscovery/init | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/flavours/hwdiscovery/init b/flavours/hwdiscovery/init index 8c03dbde..987440f6 100644 --- a/flavours/hwdiscovery/init +++ b/flavours/hwdiscovery/init @@ -1,5 +1,32 @@ + echo "Starting HW Discovery" # XXX: Collect iLO specific data, bundle everything up and POST it somewhere -lshw -json # XXX: Do something with this -sleep 30 +#lshw -json # XXX: Do something with this +CpuCount=`hwinfo --cpu|grep "Hardware Class: cpu"|wc -l` +MemorySize=`hwinfo --memory|grep "Memory Size:"|awk -F':' {'print $2'}|tr -d ' '` +DiskSize=`lshw -C disk|grep size|awk -F'(' {'print $2'}|tr -d ')'|tr -d ' '` +NicInfo1=`hwinfo --network|grep -B2 "Link detected: yes"|grep -C1 "HW Address:"` + +NicInfo2=`echo "${NicInfo1}"|awk '/Device File: vlan*/{for(x=NR-2;x<=NR+2;x++)d[x];}{a[NR]=$0}END{for(i=1;i<=NR;i++)if(!(i in d))print a[i]}'` +NicDev=`echo "${NicInfo2}"|grep "Device File:"|awk -F':' {'print $2'}|tr -d ' '` +NicMac=`echo "${NicInfo2}"|grep "HW Address:"|awk -F'ss:' {'print $2'}|tr -d ' '` + +echo "Cpu Count: ${CpuCount}" +echo "Memory: ${MemorySize}" +echo "Disk: ${DiskSize}" +echo "Network device : ${NicDev}" +echo "Network Mac: ${NicMac}" + +# in testing the nic did not get a vaild ip... +dhclient "${NicDev}" + +# for testing assume that dhcp server is == baremetal-deployhelper server +# dns flavour will make this better +ServerInfo1=`grep dhcp-server-identifier /var/lib/dhcp/dhclient.leases` +PingToServer=`echo "${ServerInfo1}"|awk -F'dhcp-server-identifier' {'print $2'}|tr -d ';'|tr -d ' '` + +echo "Reporting findings to ${PingToServer}." +#wget "http://${PingToServer}:10000?HWDiscovery=True&Ram=${MemorySize}&Disk=${DiskSize}&Cpu=${CpuCount}&NetDev=${Nicdev}&NetMac=${NicMac}" + +bash