From 3496d08373eff68ad25110a9e6018d77134bda22 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Fri, 25 Jan 2013 14:37:17 +0000 Subject: [PATCH] Add support for xcatd to recognize and unpack gzip compressed payloads Put back in extended NIC information, but compress it git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14999 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-genesis-scripts/bin/dodiscovery | 81 ++++++++++++++-------------- xCAT-server/sbin/xcatd | 7 +++ 2 files changed, 48 insertions(+), 40 deletions(-) diff --git a/xCAT-genesis-scripts/bin/dodiscovery b/xCAT-genesis-scripts/bin/dodiscovery index 734b70653..d888d13f5 100755 --- a/xCAT-genesis-scripts/bin/dodiscovery +++ b/xCAT-genesis-scripts/bin/dodiscovery @@ -138,43 +138,43 @@ for dev in `ip link|grep -B1 ether|grep UP|awk '{print $2}'|sed -e s/://|grep -v fi fi echo "$DRIVER|$dev|$MAC|$ADDRESS" >> /tmp/discopacket -########echo "" >> /tmp/discopacket -########echo " $dev" >> /tmp/discopacket -########echo " $DRIVER" >> /tmp/discopacket -########if [ ! -z "$ADDRESS" ]; then -######## echo " $ADDRESS" >> /tmp/discopacket -########fi -########echo " $MAC" >> /tmp/discopacket -########if [ ! -z "$PCI_SLOT" ]; then -######## echo " $PCI_SLOT" >> /tmp/discopacket -########fi -########if [ ! -z "$SLOTNAME" ]; then -######## echo " $SLOTNAME" >> /tmp/discopacket -########fi -########if [ ! -z "$ONBOARDINDEX" ]; then -######## echo " $ONBOARDINDEX" >> /tmp/discopacket -########fi -########if [ ! -z "$FIRMDESC" ]; then -######## echo " $FIRMDESC" >> /tmp/discopacket -########fi -########myswitch=`lldptool -n -i $dev -t -V sysName|grep -v 'System Name TLV'|sed -e 's/^ *//'` -########if [ ! -z "$myswitch" -a "$myswitch" != "Agent instance for device not found" ]; then -######## echo " $myswitch" >> /tmp/discopacket -########fi -########for switchaddr in `lldptool -i $dev -n -t -V mngAddr|grep IP|sed -e 's/.*:.//'`; do -######## if [ "$switchaddr" = "Agent instance for device not found" ]; then break; fi -######## echo " $switchaddr" >> /tmp/discopacket -########done -########myswitchdesc=`lldptool -n -i $dev -t -V sysDesc|grep -v 'System Description TLV'|sed -e 's/^ *//'` -########if [ ! -z "$myswitchdesc" -a "$myswitchdesc" != "Agent instance for device not found" ]; then -######## echo " $myswitchdesc" >> /tmp/discopacket -########fi -########myport=`lldptool -n -i $dev -t -V portDesc|grep -v 'Port Description TLV'|sed -e 's/^ *//'` -########if [ ! -z "$myport" -a "$myswitchdesc" != "Agent instance for device not found" ]; then -######## echo " $myport" >> /tmp/discopacket -########fi -######## -########echo "" >> /tmp/discopacket + echo "" >> /tmp/discopacket + echo " $dev" >> /tmp/discopacket + echo " $DRIVER" >> /tmp/discopacket + if [ ! -z "$ADDRESS" ]; then + echo " $ADDRESS" >> /tmp/discopacket + fi + echo " $MAC" >> /tmp/discopacket + if [ ! -z "$PCI_SLOT" ]; then + echo " $PCI_SLOT" >> /tmp/discopacket + fi + if [ ! -z "$SLOTNAME" ]; then + echo " $SLOTNAME" >> /tmp/discopacket + fi + if [ ! -z "$ONBOARDINDEX" ]; then + echo " $ONBOARDINDEX" >> /tmp/discopacket + fi + if [ ! -z "$FIRMDESC" ]; then + echo " $FIRMDESC" >> /tmp/discopacket + fi + myswitch=`lldptool -n -i $dev -t -V sysName|grep -v 'System Name TLV'|sed -e 's/^ *//'` + if [ ! -z "$myswitch" -a "$myswitch" != "Agent instance for device not found" ]; then + echo " $myswitch" >> /tmp/discopacket + fi + for switchaddr in `lldptool -i $dev -n -t -V mngAddr|grep IP|sed -e 's/.*:.//'`; do + if [ "$switchaddr" = "Agent instance for device not found" ]; then break; fi + echo " $switchaddr" >> /tmp/discopacket + done + myswitchdesc=`lldptool -n -i $dev -t -V sysDesc|grep -v 'System Description TLV'|sed -e 's/^ *//'` + if [ ! -z "$myswitchdesc" -a "$myswitchdesc" != "Agent instance for device not found" ]; then + echo " $myswitchdesc" >> /tmp/discopacket + fi + myport=`lldptool -n -i $dev -t -V portDesc|grep -v 'Port Description TLV'|sed -e 's/^ *//'` + if [ ! -z "$myport" -a "$myswitchdesc" != "Agent instance for device not found" ]; then + echo " $myport" >> /tmp/discopacket + fi + + echo "" >> /tmp/discopacket done echo "$PUBKEY" >> /tmp/discopacket #this is not secure to use by itself, switch sourced pubkey for security echo "" >> /tmp/discopacket @@ -190,13 +190,14 @@ cat /tmp/discopacket |while read line; do done mv /tmp/discopacket.new /tmp/discopacket - +rm -f /tmp/discopacket.gz +gzip -9 /tmp/discopacket while [ ! -r /restart ]; do if [ ! -z "$XCATMASTER" ]; then - (cat /tmp/discopacket | udpcat.awk $XCATMASTER $XCATPORT ) & + (cat /tmp/discopacket.gz | udpcat.awk $XCATMASTER $XCATPORT ) & fi for dhcps in `grep dhcp-server /var/lib/dhclient/dhclient.leases|awk '{print $4}'|sed -s 's/;//'`; do - (cat /tmp/discopacket | udpcat.awk $dhcps $XCATPORT ) & + (cat /tmp/discopacket.gz | udpcat.awk $dhcps $XCATPORT ) & done #cat /tmp/discopacket sleep 5 diff --git a/xCAT-server/sbin/xcatd b/xCAT-server/sbin/xcatd index efc1d7838..67eeb68b8 100755 --- a/xCAT-server/sbin/xcatd +++ b/xCAT-server/sbin/xcatd @@ -31,6 +31,7 @@ use xCAT::TableUtils; use xCAT::NetworkUtils; use xCAT::MsgUtils; use xCAT::xcatd; +use IO::Uncompress::Gunzip qw/gunzip/; use File::Path; use Time::HiRes qw(sleep); use Thread qw(yield); @@ -560,6 +561,12 @@ sleep 0.05; $data=$packets{$pkey}->[1]; $peerhost=gethostbyaddr($client,AF_INET); $peerhost .="\n"; + if ($data =~ /^\037\213/) { #per rfc 1952, these two bytes are gzip, and they are invalid for + #xcatrequest xml, so go ahead and decompress it + my $bigdata; + gunzip \$data => \$bigdata; + $data = $bigdata + } my $req = eval { XMLin($data, SuppressEmpty=>undef,ForceArray=>1) }; if ($req and $req->{command} and ($req->{command}->[0] eq "findme")) { $req->{'_xcat_clienthost'}=gethostbyaddr($client,AF_INET);