[Ovirt-devel] [PATCH node] auto install and firstboot fixes
Alan Pevec
apevec at redhat.com
Mon Dec 15 15:45:45 UTC 2008
* Autoinstall is performed when required boot parameters are specified:
- BOOTIF=link|eth*|01-11-22-33-44-55-66
for choosing management NIC (IPv4 DHCP is assumed)
- ovirt_init=usb|scsi
to select a local disk drive to create oVirt LVM volumes
If ovirt_vol parameter is missing, default volume sizes are used:
BOOT 50MB
SWAP 2 * RAM size
ROOT 256MB
CONFIG 5MB
LOGGING 256MB
DATA rest of the disk
equivalent is ovirt_vol=50::256:5:256
* Show firstboot menu only once. Firstboot state is stored
in the persistent config storage.
* Use the drive selected by ovirt_init boot parameter.
Signed-off-by: Alan Pevec <apevec at redhat.com>
---
scripts/ovirt-config-storage | 45 ++++++++++++++++++++++-------------------
scripts/ovirt-functions | 36 +++++++++++++++++++++------------
2 files changed, 47 insertions(+), 34 deletions(-)
diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage
index e2ddec1..fd877e2 100755
--- a/scripts/ovirt-config-storage
+++ b/scripts/ovirt-config-storage
@@ -28,13 +28,25 @@ check_partition_sizes()
# or just let the mke2fs failure suffice.
}
-# Find a usable/selected storage device along with its size in bytes.
+get_selected_drive_size()
+{
+ local udi=$(hal-find-by-property --key block.device --string $DRIVE)
+ if [ -z "$udi" ]; then
+ warn "ERROR: selected storage device is not available"
+ return 1
+ fi
+ size=$(hal-get-property --udi "$udi" --key storage.size)
+ SPACE=$(echo "scale=0; $size / (1024 * 1024)" | bc -l)
+ echo "selected device: $DRIVE ($SPACE MB)"
+}
+
+# Find a usable/selected storage device.
# If there are none, give a diagnostic and return nonzero.
# If there is just one, e.g., /dev/sda, treat it as selected (see below).
# and return 0. If there are two or more, make the user select one
# or decline. Upon decline, return nonzero. Otherwise, print the
-# selected name, a space, and its size, then return 0.
-# Sample output: "/dev/sda 320072933376"
+# selected name, then return 0.
+# Sample output: /dev/sda
get_dev_name()
{
local udi_list=$(hal-find-by-capability --capability storage)
@@ -58,20 +70,16 @@ get_dev_name()
*) warn "block device name $block_dev doesn't start with '/';" \
" skipping"; continue;;
esac
- size=$(hal-get-property --udi "$d" --key storage.size)
test -z "$devices" \
&& devices=$block_dev \
|| devices="$devices $block_dev"
- test -z "$sizes" \
- && sizes=$size \
- || sizes="$sizes $size"
done
# If there's only one device, use it.
case $devices in
'') warn "ERROR: found no usable block device"; return 1;;
*' '*) ;; # found more than one
- *) echo "$devices $sizes"; return 0;; # just one
+ *) echo "$devices"; return 0;; # just one
esac
# There are two or more; make the user choose.
@@ -80,10 +88,7 @@ get_dev_name()
do
test "$device" = Abort && return 1
test -z "$device" && continue
- # $REPLY is the selected number;
- # use that to map to the corresponding size.
- size=$(echo "$sizes"|cut -d' ' -f "$REPLY")
- echo "$device $size"
+ echo "$device"
return 0
done
}
@@ -91,13 +96,8 @@ get_dev_name()
do_configure()
{
local name_and_size
- name_and_size=$(get_dev_name) || exit 1
- set -- $name_and_size
- DRIVE=$1
- local n_bytes=$2
-
- SPACE=$(echo "scale=0; $n_bytes / (1024 * 1024)" | bc -l)
- echo "selected device: $DRIVE ($SPACE MB)"
+ DRIVE=$(get_dev_name) || exit 1
+ get_selected_drive_size
for i in boot swap root config logging ; do
uc=$(echo $i|tr '[[:lower:]]' '[[:upper:]]')
@@ -270,10 +270,13 @@ ROOT_SIZE=${OVIRT_VOL_ROOT_SIZE:-$default_root_size}
CONFIG_SIZE=${OVIRT_VOL_CONFIG_SIZE:-$default_config_size}
LOGGING_SIZE=${OVIRT_VOL_LOGGING_SIZE:-$default_logging_size}
+if [ -n "$OVIRT_INIT" ]; then
+ # if present, use the drive selected with 'ovirt_init' boot parameter
+ DRIVE=$OVIRT_INIT
+ get_selected_drive_size
+fi
if [ "$1" == "AUTO" ]; then
- # In "AUTO" mode, OVIRT_INIT should be defined in the environment.
- DRIVE=$OVIRT_INIT
check_partition_sizes
printf "Partitioning hard disk..."
perform_partitioning
diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions
index cbce347..766c432 100644
--- a/scripts/ovirt-functions
+++ b/scripts/ovirt-functions
@@ -9,34 +9,44 @@ OVIRT_DEFAULTS=/etc/default/ovirt
if [ -f $OVIRT_DEFAULTS ]; then
. $OVIRT_DEFAULTS
fi
-# fallback defaults when sysconfig is empty
+# fallback when default is empty
OVIRT_STANDALONE=${OVIRT_STANDALONE:-0}
OVIRT_BACKUP_DIR=/var/lib/ovirt-backup
-# is_managed
# return 1 if oVirt Node is running in standalone mode
# return 0 if oVirt Node is managed by the oVirt Server
is_managed() {
return $OVIRT_STANDALONE
}
-# is_standalone = not is_managed
+# oVirt Node in standalone mode does not try to contact the oVirt Server
is_standalone() {
if is_managed; then return 1; else return 0; fi
}
-# is_auto_install
-# return 0 if all required oVirt boot parameters are present
+# perform automatic local disk installation
+# when at least following boot parameters are present:
+# for networking - OVIRT_BOOTIF, management NIC
+# if other ip bootparams are not specified, IPv4 DHCP is assumed
+# for storage - OVIRT_INIT, local disk to use
+# if ovirt_vol is not specified, default volume sizes are set
is_auto_install() {
- test -n "$OVIRT_BOOTIF" \
- -a -n "$OVIRT_OVIRT_STANDALONE" \
- -a -n "$OVIRT_INIT" \
- -a -n "$OVIRT_VOL_BOOT_SIZE" \
- -a -n "$OVIRT_VOL_SWAP_SIZE" \
- -a -n "$OVIRT_VOL_ROOT_SIZE" \
- -a -n "$OVIRT_VOL_CONFIG_SIZE" \
- -a -n "$OVIRT_VOL_LOGGING_SIZE"
+ if [ -n "$OVIRT_BOOTIF" -a -n "$OVIRT_INIT" ] ; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+# was firstboot menu already shown?
+# state is stored in persistent config partition
+is_firstboot() {
+ if [ -z "$OVIRT_FIRSTBOOT" -o "$OVIRT_FIRSTBOOT" = "1" ]; then
+ return 0
+ else
+ return 1
+ fi
}
# find_srv SERVICE PROTO
--
1.6.0.4
More information about the ovirt-devel
mailing list