From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lucas Meneghel Rodrigues Subject: Re: [KVM_AUTOTEST] unattended installs take 2 Date: Mon, 22 Jun 2009 02:10:03 -0300 Message-ID: <1245647403.2778.13.camel@freedom> References: <1245361860-26726-1-git-send-email-dhuff@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-fM5HPRLr/5JB7tLs8VDv" Cc: kvm@vger.kernel.org To: David Huff Return-path: Received: from mx2.redhat.com ([66.187.237.31]:46913 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750787AbZFVFKF (ORCPT ); Mon, 22 Jun 2009 01:10:05 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5M5A7Zr032002 for ; Mon, 22 Jun 2009 01:10:07 -0400 In-Reply-To: <1245361860-26726-1-git-send-email-dhuff@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: --=-fM5HPRLr/5JB7tLs8VDv Content-Type: text/plain Content-Transfer-Encoding: 7bit On Thu, 2009-06-18 at 17:50 -0400, David Huff wrote: > Second pass at the unattended install test. Both Linux and Windows guests are > working however currently it just uses the existing boot test and extends > timeouts. We still need a good way of determining if an unattended install > completed without error. For Linux guest we should be able to run something > similar to a regular boot test, after reboot try to ssh in. For windows guest > we still have to run setup in order to have shh up. > > Requires the processor patch as well as the patch to "strip and split" patches. > > Scripts still uses loop back mounts for now we can upgrade this in the future > however most generic way of creating and manipulating disk images. > > 5 patches in this set > 0005-Modified-boot-test-in-kvm_test.py.patch > 0004-Added-two-sample-unattended-config-files-Fedora-and.patch > 0003-added-unattended.sh-script.patch > 0002-modified-config-file-to-run-unattended-install.patch > 0001-Added-floppy-and-tftp-options-to-qemu-command.patch I've been trough the changes, thank you for your work David: Comments/questions: * Any particular reason why you guys wrote the PXE boot setup as a shell script instead of a python module (that could be also used as a stand alone program)? * The script had some unused variables, and some extra debugging statements would be helpful. I've modified the original script a bit and I am attaching it to this message, please verify if the changes make sense. Your changes are an excellent starting point for getting unattended installs integrated. So things I'd like to explore: * Turn the script into a python module * See whether the development version of cobbler already handles windows appropriately. Maybe for now cobbler is not an option, but we can revisit it in the future. * Create an install test that would take as the parameter the type of installation we want to perform (steps/unattended). Any comments/suggestions please let me know. Lucas --=-fM5HPRLr/5JB7tLs8VDv Content-Disposition: attachment; filename="unattended.sh" Content-Type: application/x-shellscript; name="unattended.sh" Content-Transfer-Encoding: 7bit #!/bin/bash ################################################################################ # unattended.sh - sets up environment for unattended installs (kvm_autotest) # # Copyright (C) 2009 Red Hat, Inc. # Written by: # David Huff # Darryl L. Pierce # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. A copy of the GNU General Public License is # also available at http://www.gnu.org/copyleft/gpl.html. ################################################################################ E_CODE=1 ME=$(basename "$0") log_base() { printf '%s\n' "$*" >&2; } log() { log_base "[INFO] : $*"; } die() { log_base "[ABORT]: $*"; exit $E_CODE; } debug() { if $debugging; then log_base "[DEBUG]: $*"; fi } debugging=true set -e ################################################################################ # Creates a floppy disk image and adds unattended config file there. # This is prefered over vvfat due to known issues with fat16. # Uses loop back mout because -i wasn't available unitil mtools > 4.0. # # $CONFIG file to put on floppy disk image ################################################################################ create_floppy_disk () { local size="144" local filename="images/$KVM_TEST_floppy" debug "Creating floppy disk: filename=${filename} size=${size}" ./qemu-img create -f raw $filename "${size}M" > /dev/null 2>&1 if [ $? != 0 ]; then die "Unable to create disk image: $filename"; fi mkfs.msdos $filename if [ $? != 0 ]; then die "Unable to format disk image: $filename"; fi debug "Mounting floppy disk image." mp=$(mktemp -d floppytmp.XXXXXX) mount -t vfat -v -o loop $filename $mp if [ $? != 0 ]; then die "Unable to mount disk image: $filename to: $mp"; fi debug "Copying config file to disk." if [[ "$CONFIG" =~ \.ks\$ ]] || [[ "$CONFIG" =~ \.cfg\$ ]]; then cp $CONFIG $mp/ks.cfg elif [[ "$CONFIG" =~ \.sif\$ ]]; then cp $CONFIG $mp/winnt.sif else cp $CONFIG $mp fi debug "Unmounting floppy." df | grep $mp > /dev/null 2>&1 && umount -v $mp rmdir $mp debug "Floppy image $filename successfuly created." } ################################################################################ # setup pxeboot environment # # $PXE - iso image # $ARGS - kernel arguments ################################################################################ setup_pxeboot () { log "Using $PXE to set up pxe environment" local workdir="images/$KVM_TEST_tftp" local iso=$PXE local pxedefault=$workdir/pxelinux.cfg/default local pxelinux="/usr/lib/syslinux/pxelinux.0" local cdlocation="images/pxeboot/" debug "Checking that pxelinux.0 exists" if [ ! -f /usr/share/syslinux/pxelinux.0 -a ! -f /usr/lib/syslinux/pxelinux.0 ]; then die "Warning: pxelinux.0 not found, Make sure syslinux or pxelinux is installed on this system." fi debug "Creating clean tftpboot dir" if [ -d $workdir ]; then log "$ME: subdirectory $workdir exists already. Overwriting" rm -rf $workdir fi mkdir -p $workdir/pxelinux.cfg debug "Setting up pxelinux bootloader" if [ -f /usr/share/syslinux/pxelinux.0 ]; then cp /usr/share/syslinux/pxelinux.0 $workdir elif [ -f /usr/lib/syslinux/pxelinux.0 ]; then cp /usr/lib/syslinux/pxelinux.0 $workdir else die "pxelinux.0 not found. Make sure either syslinux or pxelinux is installed on this system." fi debug "Getting vmlinuz and initrd from image" mp=$(mktemp -d cdtmp.XXXXXX) mount -t iso9660 -v -o ro,loop "$iso" $mp if [ $? != 0 ]; then die "Unable to mount cd image: $iso to: $mp"; fi debug "Checking if the cd mount does have pxeboot images in it" if [ ! -d $mp/$cdlocation ]; then die "The ISO image does not have a $cdlocation dir. Cannot find pxeboot image to proceed." fi cp $mp/$cdlocation/initrd.img $mp/$cdlocation/vmlinuz $workdir df | grep $mp > /dev/null 2>&1 && umount -v $mp rmdir $mp # Set default kernel arguments if none were provided if [ -z "$ARGS" ]; then local $ARGS="" fi local definition="DEFAULT pxeboot" definition="${definition}\nTIMEOUT 20" definition="${definition}\nPROMPT 0" definition="${definition}\nLABEL pxeboot" definition="${definition}\n KERNEL vmlinuz" definition="${definition}\n APPEND initrd=initrd.img $ARGS" printf "${definition}\n" > $pxedefault debug "PXE definition file contents:" cat $pxedefault debug "Done with pxeboot setup." } ################################################################################ # Main program debug "KVM environment variables that this script will use:" debug "KVM_TEST_unattended_file: $KVM_TEST_unattended_file" debug "KVM_TEST_cdrom: $KVM_TEST_cdrom" debug "KVM_TEST_kernel_args: $KVM_TEST_kernel_args" debug "KVM_TEST_TFTP: $KVM_TEST_tftp" CONFIG=$KVM_TEST_unattended_file PXE=isos/$KVM_TEST_cdrom ARGS=$KVM_TEST_kernel_args # check to see we are root if [ $(id -u) -ne 0 ]; then die "Must run as root" fi # Require "CONFIG_FILE" if [[ ! -e $CONFIG ]]; then die "No unattended config file found: $CONFIG" fi debug "Using unattended config file: $CONFIG" # create the floppy image create_floppy_disk $CONFIG if [[ ! -z $KVM_TEST_tftp ]]; then setup_pxeboot fi --=-fM5HPRLr/5JB7tLs8VDv--