Alan Pevec
2009-May-21 11:30 UTC
[Ovirt-devel] [PATCH node] display descriptions for all disks
Signed-off-by: Alan Pevec <apevec at redhat.com> --- scripts/ovirt-config-storage | 31 +++++++++++++++++++------------ 1 files changed, 19 insertions(+), 12 deletions(-) diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index be5aec0..671ad7d 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -36,15 +36,17 @@ logging_min_size=5 data_min_size=5 swap_min_size=5 -get_selected_drive_size() +get_drive_size() { - start_log + local drive=$1 + local space_var=$2 + local size- local udi=$(hal-find-by-property --key block.device --string $DRIVE) + local udi=$(hal-find-by-property --key block.device --string $drive) if [ -z "$udi" ]; then # If hal didn't find the device, it could be a virtio block device # In this case, use sfdisk -s to get the size - size=$(sfdisk -s $DRIVE) + size=$(sfdisk -s $drive) size=$(echo "scale=0; $size * 1024" | bc -l) else size=$(hal-get-property --udi "$udi" --key storage.size) @@ -54,9 +56,11 @@ get_selected_drive_size() fi fi - SPACE=$(echo "scale=0; $size / (1024 * 1024)" | bc -l) - log "Selected Device: $DRIVE ($SPACE MB) $(basename "$udi")" - stop_log + size=$(echo "scale=0; $size / (1024 * 1024)" | bc -l) + echo "$drive ($size MB) $(basename "$udi")" + if [ -n "$space_var" ]; then + eval $space_var=$size + fi } check_partition_sizes() @@ -69,7 +73,7 @@ check_partition_sizes() fi printf "\n" - get_selected_drive_size + get_drive_size $DRIVE SPACE disk_size=$SPACE need_size=$(echo "scale=0;" \ "$BOOT_SIZE + $SWAP_SIZE + $ROOT_SIZE * 2" \ @@ -160,6 +164,10 @@ get_dev_name() esac # There are two or more; make the user choose. + # display description for each disk + for d in $devices; do + get_drive_size $d >&2 + done local choices="$devices Abort" select device in $choices do @@ -174,7 +182,7 @@ do_configure() { local name_and_size DRIVE=$(get_dev_name) || return 0 - get_selected_drive_size + get_drive_size $DRIVE SPACE printf "\n\nPlease configure storage partitions.\n\n" printf "* Enter partition sizes in MB.\n" @@ -256,8 +264,7 @@ do_review() The local disk will be repartitioned as follows: ===============================================- Physical Hard Disk: $DRIVE - Total storage available: $SPACE MB + Physical Hard Disk: $(get_drive_size $DRIVE) Boot partition size: $BOOT_SIZE MB Swap partition size: $SWAP_SIZE MB Installation partition size: $ROOT_SIZE * 2 MB @@ -494,7 +501,7 @@ DATA_SIZE=${OVIRT_VOL_DATA_SIZE:-$default_data_size} if [ -n "$OVIRT_INIT" ]; then # if present, use the drive selected with 'ovirt_init' boot parameter DRIVE=$OVIRT_INIT - get_selected_drive_size + get_drive_size $DRIVE SPACE fi # if the node is Fedora then use GPT, otherwise use MBR -- 1.6.0.6
Darryl L. Pierce
2009-May-21 13:28 UTC
[Ovirt-devel] [PATCH node] display descriptions for all disks
On Thu, May 21, 2009 at 01:30:24PM +0200, Alan Pevec wrote:> Signed-off-by: Alan Pevec <apevec at redhat.com> > --- > scripts/ovirt-config-storage | 31 +++++++++++++++++++------------ > 1 files changed, 19 insertions(+), 12 deletions(-) > > diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage > index be5aec0..671ad7d 100755 > --- a/scripts/ovirt-config-storage > +++ b/scripts/ovirt-config-storage > @@ -36,15 +36,17 @@ logging_min_size=5 > data_min_size=5 > swap_min_size=5 > > -get_selected_drive_size() > +get_drive_size() > { > - start_log > + local drive=$1 > + local space_var=$2 > + > local size> - local udi=$(hal-find-by-property --key block.device --string $DRIVE) > + local udi=$(hal-find-by-property --key block.device --string $drive) > if [ -z "$udi" ]; then > # If hal didn't find the device, it could be a virtio block device > # In this case, use sfdisk -s to get the size > - size=$(sfdisk -s $DRIVE) > + size=$(sfdisk -s $drive) > size=$(echo "scale=0; $size * 1024" | bc -l) > else > size=$(hal-get-property --udi "$udi" --key storage.size) > @@ -54,9 +56,11 @@ get_selected_drive_size() > fi > fi > > - SPACE=$(echo "scale=0; $size / (1024 * 1024)" | bc -l) > - log "Selected Device: $DRIVE ($SPACE MB) $(basename "$udi")" > - stop_log > + size=$(echo "scale=0; $size / (1024 * 1024)" | bc -l) > + echo "$drive ($size MB) $(basename "$udi")" > + if [ -n "$space_var" ]; then > + eval $space_var=$size > + fi > } > > check_partition_sizes() > @@ -69,7 +73,7 @@ check_partition_sizes() > fi > > printf "\n" > - get_selected_drive_size > + get_drive_size $DRIVE SPACE > disk_size=$SPACE > need_size=$(echo "scale=0;" \ > "$BOOT_SIZE + $SWAP_SIZE + $ROOT_SIZE * 2" \ > @@ -160,6 +164,10 @@ get_dev_name() > esac > > # There are two or more; make the user choose. > + # display description for each disk > + for d in $devices; do > + get_drive_size $d >&2 > + done > local choices="$devices Abort" > select device in $choices > do > @@ -174,7 +182,7 @@ do_configure() > { > local name_and_size > DRIVE=$(get_dev_name) || return 0 > - get_selected_drive_size > + get_drive_size $DRIVE SPACE > > printf "\n\nPlease configure storage partitions.\n\n" > printf "* Enter partition sizes in MB.\n" > @@ -256,8 +264,7 @@ do_review() > > The local disk will be repartitioned as follows: > ===============================================> - Physical Hard Disk: $DRIVE > - Total storage available: $SPACE MB > + Physical Hard Disk: $(get_drive_size $DRIVE)The $DRIVE detail should go to the next line and be labeled "Hard Disk Identifier". This will avoid the text wrapping if the drive id is particularly long.> Boot partition size: $BOOT_SIZE MB > Swap partition size: $SWAP_SIZE MB > Installation partition size: $ROOT_SIZE * 2 MB > @@ -494,7 +501,7 @@ DATA_SIZE=${OVIRT_VOL_DATA_SIZE:-$default_data_size} > if [ -n "$OVIRT_INIT" ]; then > # if present, use the drive selected with 'ovirt_init' boot parameter > DRIVE=$OVIRT_INIT > - get_selected_drive_size > + get_drive_size $DRIVE SPACE > fi > > # if the node is Fedora then use GPT, otherwise use MBR > -- > 1.6.0.6ACK. -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Virtual Machine Management - http://www.ovirt.org/ Is fearr Gaeilge bhriste n? B?arla cliste. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20090521/d7e16523/attachment.sig>