Land an extension of baremetal-mkinitrd.sh which can also build flavours, with a start at making hwdiscovery and hwburning flavours

This commit is contained in:
Chris Jones 2012-11-09 16:13:20 +00:00 committed by Robert Collins
parent 5cc195e391
commit 7da463e617
3 changed files with 79 additions and 18 deletions

View File

@ -22,6 +22,36 @@ EOF
exit 1 exit 1
fi fi
FLAVOUR=${FLAVOUR:-baremetal}
echo "Building flavour(s): ${FLAVOUR}"
if [[ "$FLAVOUR" == *hwdiscovery* ]] ; then
HWDISCOVERY_BINARIES="lshw"
for binary in ${HWDISCOVERY_BINARIES} ; do
LOCATION=$(which $binary)
if [ -z "$LOCATION" ]; then
echo "$binary is not found in PATH" 1>&2
echo "Please install it"
exit 1
fi
done
FLAVOUR_BINARIES="${FLAVOUR_BINARIES} ${HWDISCOVERY_BINARIES}"
fi
if [[ "$FLAVOUR" == *hwburnin* ]] ; then
HWDISCOVERY_BINARIES="spew memtester"
for binary in ${HWDISCOVERY_BINARIES} ; do
LOCATION=$(which $binary)
if [ -z "$LOCATION" ]; then
echo "$binary is not found in PATH" 1>&2
echo "Please install it"
exit 1
fi
done
FLAVOUR_BINARIES="${FLAVOUR_BINARIES} ${HWDISCOVERY_BINARIES}"
fi
BUSYBOX=${BUSYBOX:-$(which busybox)} BUSYBOX=${BUSYBOX:-$(which busybox)}
if [ -z "$BUSYBOX" ]; then if [ -z "$BUSYBOX" ]; then
echo "busybox is not found in PATH" 1>&2 echo "busybox is not found in PATH" 1>&2
@ -85,7 +115,7 @@ udev_log="no"
EOF EOF
libs= libs=
for i in "$BUSYBOX" bash modprobe udevd udevadm wget tgtd tgtadm reboot shutdown; do for i in "$BUSYBOX" bash modprobe udevd udevadm wget tgtd tgtadm reboot shutdown $FLAVOUR_BINARIES; do
if "$BUSYBOX" --list | grep "^$i\$" >/dev/null; then if "$BUSYBOX" --list | grep "^$i\$" >/dev/null; then
continue continue
fi fi

View File

@ -33,6 +33,16 @@ function get_kernel_parameter() {
return 1 return 1
} }
function string_contains() {
local string=$1
local word=$2
if [ "$string" != "${string/$word/}" ]; then
return 0
else
return 1
fi
}
function load_modules_by_udev() { function load_modules_by_udev() {
depmod depmod
udevadm trigger --action=add udevadm trigger --action=add

View File

@ -34,6 +34,8 @@ mount -t proc proc /proc
readonly _BOOTIF_=$(get_kernel_parameter BOOTIF) readonly _BOOTIF_=$(get_kernel_parameter BOOTIF)
readonly _IP_=$(get_kernel_parameter ip) readonly _IP_=$(get_kernel_parameter ip)
readonly _CMDLINE_FLAVOUR=$(get_kernel_parameter FLAVOUR)
readonly FLAVOUR=${_CMDLINE_FLAVOUR:-baremetal}
readonly BOOT_MAC_ADDRESS=$(echo "$_BOOTIF_" | sed -e "s/-/:/g" | sed -e "s/^01://g" | tr 'a-f' 'A-F') readonly BOOT_MAC_ADDRESS=$(echo "$_BOOTIF_" | sed -e "s/-/:/g" | sed -e "s/^01://g" | tr 'a-f' 'A-F')
readonly BOOT_IP_ADDRESS=$(echo "$_IP_" | cut -d':' -f1) readonly BOOT_IP_ADDRESS=$(echo "$_IP_" | cut -d':' -f1)
readonly BOOT_SERVER=$(echo "$_IP_" | cut -d':' -f2) readonly BOOT_SERVER=$(echo "$_IP_" | cut -d':' -f2)
@ -45,7 +47,8 @@ readonly DEPLOYMENT_ID=$(get_kernel_parameter deployment_id)
readonly DEPLOYMENT_KEY=$(get_kernel_parameter deployment_key) readonly DEPLOYMENT_KEY=$(get_kernel_parameter deployment_key)
readonly ISCSI_TARGET_IQN=$(get_kernel_parameter iscsi_target_iqn) readonly ISCSI_TARGET_IQN=$(get_kernel_parameter iscsi_target_iqn)
if [ -z "$ISCSI_TARGET_IQN" ]; then string_contains $FLAVOUR "baremetal"
if [ "$?" == "0" -a -z "$ISCSI_TARGET_IQN" ]; then
echo "iscsi_target_iqn is not defined" echo "iscsi_target_iqn is not defined"
echo "Starting troubleshooting shell." echo "Starting troubleshooting shell."
bash bash
@ -129,6 +132,8 @@ done
echo "network ready" echo "network ready"
string_contains $FLAVOUR "baremetal"
if [ "$?" == "0" ]; then
target_disk=`find_disk "$DISK"` target_disk=`find_disk "$DISK"`
echo "start iSCSI target on $target_disk" echo "start iSCSI target on $target_disk"
start_iscsi_target "$ISCSI_TARGET_IQN" "$target_disk" ALL start_iscsi_target "$ISCSI_TARGET_IQN" "$target_disk" ALL
@ -148,6 +153,22 @@ nc -l -p 10000
echo "stop iSCSI target on $target_disk" echo "stop iSCSI target on $target_disk"
stop_iscsi_target stop_iscsi_target
fi
string_contains $FLAVOUR "hwdiscovery"
if [ "$?" == "0" ]; then
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
fi
string_contains $FLAVOUR "hwburnin"
if [ "$?" == "0" ]; then
echo "Starting HW Burnin"
memtester 1G 10 # XXX: Discover RAM size
# XXX: Discover and test disks with spew
fi
echo "rebooting" echo "rebooting"
reboot -f reboot -f