Skip to content

Commit

Permalink
Fixes as reviewed by @neo954
Browse files Browse the repository at this point in the history
  • Loading branch information
samveen committed Mar 13, 2018
1 parent bf7ef8c commit 49f9a9a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 32 deletions.
26 changes: 9 additions & 17 deletions xCAT-genesis-scripts/usr/bin/dodiscovery
Original file line number Diff line number Diff line change
Expand Up @@ -119,27 +119,23 @@ elif [ -r /proc/device-tree/model ]; then #POWER
fi

# The MEMORY will look like this: 32868920
MEMORY=$(awk '/MemTotal/{printf "%.0fMB\n", $2/1024}' /proc/meminfo)
MEMORY="$(awk '/MemTotal/{printf "%.0fMB\n", $2/1024}' /proc/meminfo)"

# The DISKSIZE will look like this: sda:960GB,sdb:960GB,sdc:480GB,sdd:480GB (sorted by major,minor)
DISKSIZE="$(grep -v name /proc/partitions |sort -g -k 1,2 |awk 'BEGIN{sep=""} /[^0-9]$/{printf("%s%s:%.0fGB", sep, $4, $3/1024^2) ; sep=","}')"

logger -s -t $log_label -p local4.info "Beginning echo information to discovery packet file..."
cat >/tmp/discopacket <<__ENDL
<xcatrequest>
echo "<xcatrequest>
<command>findme</command>
<sequential>1</sequential>
<arch>$ARCH</arch>
__ENDL
<arch>$ARCH</arch>" >/tmp/discopacket
if [ "$IAMAVM" = 1 ]; then
echo "<nodetype>virtual</nodetype>" >> /tmp/discopacket
fi
cat >>/tmp/discopacket <<__ENDL
<cpucount>$CPUCOUNT</cpucount>
echo "<cpucount>$CPUCOUNT</cpucount>
<cputype>$CPUTYPE</cputype>
<memory>$MEMORY</memory>
<disksize>$DISKSIZE</disksize>
__ENDL
<disksize>$DISKSIZE</disksize>" >>/tmp/discopacket
if [ "$UUID" != "unknown" ]; then
echo "<uuid>$UUID</uuid>" >> /tmp/discopacket
fi
Expand Down Expand Up @@ -225,8 +221,7 @@ for dev in `ip link|grep -B1 ether|grep UP|awk '{print $2}'|sed -e s/://|grep -v
fi
fi
fi
cat >>/tmp/discopacket <<__ENDL
<mac>$DRIVER|$dev|$MAC|$ADDRESS</mac>
echo "<mac>$DRIVER|$dev|$MAC|$ADDRESS</mac>
<nic>
<devname>$dev</devname>
<driver>$DRIVER</driver>
Expand All @@ -235,8 +230,7 @@ ${ADDRESS:+ <ip4address>$ADDRESS</ip4address>}
${PCI_SLOT:+ <pcidev>$PCI_SLOT</pcidev>}
${SLOTNAME:+ <location>$SLOTNAME</location>}
${ONBOARDINDEX:+ <onboardeth>$ONBOARDINDEX</onboardeth>}
${FIRMDESC:+ <firmdesc>$FIRMDESC</firmdesc>}
__ENDL
${FIRMDESC:+ <firmdesc>$FIRMDESC</firmdesc>}" >>/tmp/discopacket
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 " <switchname>$myswitch</switchname>" >> /tmp/discopacket
Expand All @@ -261,12 +255,10 @@ if [ "$UUID" == "unknown" ]; then
echo "<uuid>$UUID</uuid>" >> /tmp/discopacket
fi
#this is not secure to use by itself, switch sourced pubkey for security
cat >>/tmp/discopacket <<__ENDL
<xcatpubkey>$PUBKEY</xcatpubkey>
echo "<xcatpubkey>$PUBKEY</xcatpubkey>
<sha512sig>
</sha512sig>
</xcatrequest>
__ENDL
</xcatrequest>" >>/tmp/discopacket
openssl dgst -sha512 -out /tmp/discopacket.sha512 -sign /etc/xcat/privkey.pem /tmp/discopacket
openssl enc -e -a -in /tmp/discopacket.sha512 > /tmp/discopacket.b64sig
sed -i "/^<sha512sig>$/ r /tmp/discopacket.b64sig" /tmp/discopacket
Expand Down
18 changes: 6 additions & 12 deletions xCAT-genesis-scripts/usr/bin/getadapter
Original file line number Diff line number Diff line change
Expand Up @@ -58,36 +58,30 @@ done
for pci in $(lspci |awk '/Ethernet/ {print $1}'); do
if ! grep -q "$pci" "$ADAPTERFILE" 2>/dev/null; then
tmp="$(lspci |grep "$pci")"
cat >> "$ADAPTERFILE" <<__ENDL
<nic>
echo "<nic>
<pcilocation>$pci</pcilocation>
<model>${tmp##*:}</model>
</nic>
__ENDL
</nic>" >> "$ADAPTERFILE"
fi
done

for pci in $(lspci |awk '/Network/ {print $1}'); do
if ! grep -q "$pci" "$ADAPTERFILE" 2>/dev/null; then
tmp="$(lspci |grep "$pci")"
cat >> "$ADAPTERFILE" <<__ENDL
<nic>
echo "<nic>
<pcilocation>$pci</pcilocation>
<model>${tmp##*: }</model>
</nic>
__ENDL
</nic>" >> "$ADAPTERFILE"
fi
done

for pci in $(lspci |awk '/Mellanox/ {print $1}'); do
if ! grep -q "$pci" "$ADAPTERFILE" 2>/dev/null; then
tmp="$(lspci |grep "$pci")"
cat >> "$ADAPTERFILE" <<__ENDL
<nic>
echo "<nic>
<pcilocation>$pci</pcilocation>
<model>${tmp##*: }</model>
</nic>
__ENDL
</nic>" >> "$ADAPTERFILE"
fi
done

Expand Down
2 changes: 1 addition & 1 deletion xCAT-genesis-scripts/usr/bin/getcert
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ openssl s_client -connect "$XCATDEST" -quiet </tmp/certreq.xml 2>/dev/null >/tmp
if grep -q 'BEGIN CERTIFICATE' /tmp/certresp.xml ; then
awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/' < /tmp/certresp.xml > /etc/xcat/cert.pem
#stop transmitting sysDesc, allowing the public key to age out of validity
while read iface ; do
while read -r iface ; do
lldptool -T -i "$iface" -V sysDesc enableTx=no >& /dev/null
done < <(awk '/^ e/{print $1}' /var/lib/lldpad/lldpad.conf)
fi
Expand Down
2 changes: 1 addition & 1 deletion xCAT-genesis-scripts/usr/bin/getipmi
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fi

# This section only works in genesis
if [ -z "$XCATDEST" ]; then
read XCATDEST < <(grep xcatd= /proc/cmdline| sed 's/.*xcatd=\([^ ]*\).*/\1/')
read -r XCATDEST < <(grep xcatd= /proc/cmdline| sed 's/.*xcatd=\([^ ]*\).*/\1/')
fi
# This section works in diskless/diskful
# The environment MASTER_IP and XCATDPORT is exported by mypostscript
Expand Down
2 changes: 1 addition & 1 deletion xCAT-genesis-scripts/usr/bin/remoteimmsetup
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if [ -z "$XCATDEST" ]; then
XCATDEST=$1
fi
if [ -z "$XCATDEST" ]; then
read XCATDEST < <(grep xcatd= /proc/cmdline| sed 's/.*xcatd=\([^ ]*\).*/\1/')
read -r XCATDEST < <(grep xcatd= /proc/cmdline| sed 's/.*xcatd=\([^ ]*\).*/\1/')
fi
for LANCHAN in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do
if ipmitool channel info $LANCHAN 2> /dev/null | grep 802.3 > /dev/null 2>&1 && ipmitool raw 0xc 2 $LANCHAN 5 0 0 > /dev/null 2>&1;
Expand Down

0 comments on commit 49f9a9a

Please sign in to comment.