Merge pull request #58 from Divius/ironic-discoverd-full-interfaces
Post full interfaces information to discovery daemon
This commit is contained in:
commit
5ecb331ae4
|
@ -10,7 +10,6 @@ function request_curl(){
|
|||
fi
|
||||
|
||||
RESULT=$(eval curl -i -X "$HTTP_METHOD" \
|
||||
"$TOKEN_HEADER" \
|
||||
"-H 'Accept: application/json'" \
|
||||
"-H 'Content-Type: application/json'" \
|
||||
"$DATA" \
|
||||
|
@ -24,13 +23,18 @@ function request_curl(){
|
|||
}
|
||||
|
||||
MACS=
|
||||
IFACES=
|
||||
for iface in $(ls /sys/class/net/ | grep -v lo)
|
||||
do
|
||||
MAC="$(ip link show $iface | awk '/ether/ {print $2}')"
|
||||
MAC=$(ip link show $iface | awk '/ether/ {print $2}')
|
||||
IP=$(ip addr show $iface | awk '/inet / { sub(/\/.*/, "", $2); print $2 }')
|
||||
if [ ! -z "$MAC" ]; then
|
||||
MACS="$MACS \"$MAC\""
|
||||
IFACES="$IFACES,\"$iface\":{\"mac\":\"$MAC\",\"ip\":\"$IP\"}"
|
||||
fi
|
||||
done
|
||||
IFACES="{$(echo $IFACES | sed s/,//)}"
|
||||
# NOTE(dtantsur): deprecated, left for compatibility
|
||||
MACS="[$(echo $MACS | sed 's/ /,/g')]"
|
||||
|
||||
modprobe ipmi_devintf || echo "WARNING: modprobe failed, ipmitool call may fail"
|
||||
|
@ -45,7 +49,10 @@ disk_bytes=$(fdisk -l | grep Disk | awk '{print $5}' | head -n 1)
|
|||
# -1 is required to give Ironic some spacing for partitioning and may be removed later
|
||||
DISK_SIZE=$(($disk_bytes/1024/1024/1024 - 1))
|
||||
|
||||
NODE_DATA="'{\"ipmi_address\":\"$BMC_ADDRESS\",\"local_gb\":$DISK_SIZE,\"memory_mb\":$RAM,\"cpus\":$CPUS,\"cpu_arch\":\"$CPU_ARCH\",\"macs\":$MACS}'"
|
||||
NODE_DATA="'{\"ipmi_address\":\"$BMC_ADDRESS\",\"local_gb\":$DISK_SIZE,\"memory_mb\":$RAM,\"cpus\":$CPUS,\"cpu_arch\":\"$CPU_ARCH\""
|
||||
NODE_DATA="$NODE_DATA,\"macs\":$MACS"
|
||||
NODE_DATA="$NODE_DATA,\"interfaces\":$IFACES}'"
|
||||
echo Collected $NODE_DATA
|
||||
NODE_RESP=$(request_curl POST $IRONIC_API_URL $NODE_DATA)
|
||||
|
||||
echo "Node is now discovered! Halting..."
|
||||
|
|
Loading…
Reference in New Issue