Switch to using upstream ironic-discoverd-ramdisk element

The element was backported from diskimage-builder master.
It mostly contains some clean ups.

We'll carry on the ramdisk development here, while trying to keep
the DIB version more or less up-to-date.
This commit is contained in:
Dmitry Tantsur 2014-12-11 16:50:44 +01:00
parent e094c0e3bd
commit 2636785436
9 changed files with 16 additions and 17 deletions

View File

@ -1,11 +1,10 @@
ironic-discoverd [1] is a StackForge project for conducting hardware properties
discovery via booting a special discovery ramdisk and interrogating hardware
from within it.
This ramdisk collects hardware information from the machine
it's booted on and posts it to the URL provided via
kernel argument 'ironic_callback_url'.
The ramdisk is meant to be used with Ironic, thus it's name,
but it's not really tied to it. We may switch to talking
to an intermediate service later without changing ramdisk
code.
kernel argument 'discoverd_callback_url'.
The hardware information collected by the ramdisk are:
@ -13,6 +12,8 @@ The hardware information collected by the ramdisk are:
* CPU count and architecture
* Memory amount in MiB
* Hard drive size in GiB
* Mac addresses for all NICs except the loopback
* IP and mac addresses for all NICs except the loopback
The machine is halted at the end of the process.
[1] https://pypi.python.org/pypi/ironic-discoverd

View File

@ -1,4 +1,4 @@
readonly IRONIC_API_URL=$(get_kernel_parameter ironic_callback_url)
readonly DISCOVERD_URL=$(get_kernel_parameter discoverd_callback_url)
function request_curl(){
HTTP_METHOD=$1
@ -22,24 +22,22 @@ function request_curl(){
echo $RESULT
}
MACS=
IFACES=
for iface in $(ls /sys/class/net/ | grep -v lo)
do
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')]"
# NOTE(dtantsur): workaround for IPMI device not present on some systems
modprobe ipmi_msghandler || echo "WARNING: modprobe failed, ipmitool call may fail"
modprobe ipmi_devintf || echo "WARNING: modprobe failed, ipmitool call may fail"
modprobe ipmi_si || echo "WARNING: modprobe failed, ipmitool call may fail"
BMC_ADDRESS=$(ipmitool lan print | grep -e "IP Address [^S]" | awk '{ print $4 }')
CPU_ARCH=$(lscpu | grep Architecture | awk '{ print $2 }')
@ -48,15 +46,15 @@ CPU_ARCH=$(lscpu | grep Architecture | awk '{ print $2 }')
RAM=$(dmidecode -t 16 | grep 'Maximum Capacity' | awk '{if ($4 == "GB") s+=$3*1024; else s+=$3;} END {print s}')
CPUS=$(cat /proc/cpuinfo | grep processor | wc -l)
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
# NOTE(dtantsur): -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\""
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)
NODE_RESP=$(request_curl POST $DISCOVERD_URL $NODE_DATA)
echo "Node is now discovered! Halting..."
# Give user a chance of seeing the output
sleep 5
poweroff -f

View File

@ -2,6 +2,6 @@ default discover
label discover
kernel discovery.kernel
append initrd=discovery.ramdisk ironic_callback_url=http://{{local-ipv4}}:5050/v1/continue
append initrd=discovery.ramdisk discoverd_callback_url=http://{{local-ipv4}}:5050/v1/continue
ipappend 3

View File

@ -25,7 +25,7 @@ fi
export NODE_DIST=${NODE_DIST:-$DEFAULT_DIST}
export DEPLOY_IMAGE_ELEMENT=${DEPLOY_IMAGE_ELEMENT:-deploy-ironic}
export DEPLOY_NAME=${DEPLOY_NAME:-deploy-ramdisk-ironic}
export DISCOVERY_IMAGE_ELEMENT=${DISCOVERY_IMAGE_ELEMENT:-discovery-ironic}
export DISCOVERY_IMAGE_ELEMENT=${DISCOVERY_IMAGE_ELEMENT:-ironic-discoverd-ramdisk-instack}
export DISCOVERY_NAME=${DISCOVERY_NAME:-discovery-ramdisk}
export DIB_COMMON_ELEMENTS=${DIB_COMMON_ELEMENTS:-""}