Merge "Add virtual media boot support in ramdisk element."

This commit is contained in:
Jenkins 2014-07-28 05:50:39 +00:00 committed by Gerrit Code Review
commit 7485f4a080
2 changed files with 90 additions and 25 deletions

View file

@ -13,22 +13,72 @@
# License for the specific language governing permissions and limitations
# under the License.
function configure_vmedia_dir() {
VMEDIA_MOUNT_POINT="/vfloppy_mnt"
VMEDIA_DIR="/vfloppy"
VMEDIA_CONFIG_FILE="parameters.txt"
SYSFS_DEVICE_MODELS="/sys/class/block/*/device/model"
SYSFS_VMEDIA_DEVICE_MODEL="virtual media"
# Wait for some seconds for kernel to finish initializing the
# virtual media devices.
wait_for 5 1 "grep -q -i \"$SYSFS_VMEDIA_DEVICE_MODEL\" $SYSFS_DEVICE_MODELS"
if [[ $? != 0 ]]; then
echo "Error finding the virtual floppy device on the node."
troubleshoot
fi
# Find the virtual media device from the kernel sysfs file system.
VMEDIA_DEVICE=$(grep -l -i "$SYSFS_VMEDIA_DEVICE_MODEL" $SYSFS_DEVICE_MODELS | awk -F'/' '{print $5}')
if [[ -z $VMEDIA_DEVICE ]]; then
echo "Error finding the virtual floppy device on the node."
troubleshoot
fi
# Mount the virtual media device
VMEDIA_DEVICE_FILE="/dev/$VMEDIA_DEVICE"
mkdir -p $VMEDIA_MOUNT_POINT
mount $VMEDIA_DEVICE_FILE $VMEDIA_MOUNT_POINT
if [[ $? != 0 ]]; then
echo "Error mounting virtual media device $VMEDIA_DEVICE_FILE"
troubleshoot
fi
# Copy the contents of the virtual media to a directory in root
# filesystem so that we can unmount virtual media soon.
cp -rf $VMEDIA_MOUNT_POINT $VMEDIA_DIR
umount $VMEDIA_MOUNT_POINT
}
function get_kernel_parameter() {
local name=$1
for i in `cat /proc/cmdline`; do
if [ "$BOOT_METHOD" = "$VMEDIA_BOOT_TAG" ]; then
echo $(find_parameter_from_file $1 "$VMEDIA_DIR/$VMEDIA_CONFIG_FILE")
else
echo $(find_parameter_from_file $1 "/proc/cmdline")
fi
}
function find_parameter_from_file() {
local paramname=$1
local filename=$2
for i in `cat $filename`; do
case "$i" in
${name}=*)
echo "${i#${name}=}"
return 0
${paramname}=*)
echo "${i#${paramname}=}"
return 0
;;
${name})
echo ""
return 0
${paramname})
echo ""
return 0
;;
*)
*)
;;
esac
done
echo ""
return 1
}

View file

@ -31,22 +31,6 @@ mkdir -p /proc /sys /dev /boot /etc /mnt /lib/modules
mount -t proc proc /proc
readonly _BOOTIF_=$(get_kernel_parameter BOOTIF)
readonly _IP_=$(get_kernel_parameter ip)
readonly BOOT_MAC_ADDRESS=$(echo "$_BOOTIF_" | sed -e "s/-/:/g" | sed -e "s/^01://g" | tr 'a-f' 'A-F')
readonly BOOT_SERVER=$(echo "$_IP_" | cut -d':' -f2)
# IP address and other parameters may be set later in the init script
BOOT_IP_ADDRESS=$(echo "$_IP_" | cut -d':' -f1)
BOOT_NETMASK=$(echo "$_IP_" | cut -d':' -f4)
BOOT_GATEWAY=$(echo "$_IP_" | cut -d':' -f3)
readonly DISK=$(get_kernel_parameter disk)
readonly DEPLOYMENT_ID=$(get_kernel_parameter deployment_id)
readonly DEPLOYMENT_KEY=$(get_kernel_parameter deployment_key)
readonly ISCSI_TARGET_IQN=$(get_kernel_parameter iscsi_target_iqn)
TROUBLESHOOT=$(get_kernel_parameter troubleshoot)
FIRST_ERR_MSG=
mount -t sysfs none /sys
@ -102,3 +86,34 @@ $UDEVD --daemon --resolve-names=never
echo "load modules"
load_modules_by_udev
# To identify that the node has booted from virtual media, a kernel
# command-line argument boot_method=vmedia is added in the iso bootloader
# configuration file (like isolinux.cfg for isolinux).
VMEDIA_BOOT_TAG="vmedia"
BOOT_METHOD=$(get_kernel_parameter boot_method)
if [ "$BOOT_METHOD" = "$VMEDIA_BOOT_TAG" ]; then
# If the node booted from virtual media cdrom, the arguments for the
# installation are provided in virtual media floppy. Find out
# the virtual media device, mount it and get the information.
configure_vmedia_dir
fi
readonly _BOOTIF_=$(get_kernel_parameter BOOTIF)
readonly _IP_=$(get_kernel_parameter ip)
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_SERVER=$(echo "$_IP_" | cut -d':' -f2)
readonly BOOT_NETMASK=$(echo "$_IP_" | cut -d':' -f4)
readonly BOOT_GATEWAY=$(echo "$_IP_" | cut -d':' -f3)
readonly DISK=$(get_kernel_parameter disk)
readonly DEPLOYMENT_ID=$(get_kernel_parameter deployment_id)
readonly DEPLOYMENT_KEY=$(get_kernel_parameter deployment_key)
readonly ISCSI_TARGET_IQN=$(get_kernel_parameter iscsi_target_iqn)
TROUBLESHOOT=$(get_kernel_parameter troubleshoot)