├── oz ├── stdout-examples │ ├── rhel63_x86_64.tdl │ ├── f19 │ │ ├── nwinfo.out │ │ ├── f19.tdl │ │ ├── f19-jeosJul_04_2013-12:42:32 │ │ ├── oz-create-f19.bash │ │ └── f19-jeos.out │ ├── f19-25G.tdl │ ├── rhel63-tbox1Feb_15_2013-15:29:50 │ └── rhel63-tbox1.out └── oz-jeos.bash ├── fed-minimal.ks ├── libguestfs └── hostname-guest-edit.py ├── README ├── create-guest-qcow2-btrfs.bash ├── jeos-guest-create.bash ├── create-guest-raw.bash └── create-guest-qcow2.bash /oz/stdout-examples/rhel63_x86_64.tdl: -------------------------------------------------------------------------------- 1 | 14 | 15 | -------------------------------------------------------------------------------- /fed-minimal.ks: -------------------------------------------------------------------------------- 1 | install 2 | #cdrom 3 | text 4 | reboot 5 | lang en_US.UTF-8 6 | keyboard us 7 | network --bootproto dhcp 8 | rootpw redhat 9 | firewall --enabled --ssh 10 | selinux --enforcing 11 | timezone --utc America/New_York 12 | #firstboot --disable 13 | bootloader --location=mbr --append="console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH" 14 | zerombr 15 | clearpart --all --initlabel 16 | autopart 17 | 18 | %packages 19 | @core 20 | %end 21 | -------------------------------------------------------------------------------- /oz/stdout-examples/f19/nwinfo.out: -------------------------------------------------------------------------------- 1 | # /usr/bin/virsh net-destroy default 2 | Network default destroyed 3 | 4 | # /usr/bin/virsh net-start default 5 | Network default started 6 | 7 | # /usr/bin/virsh net-list --all 8 | Name State Autostart Persistent 9 | ---------------------------------------------------------- 10 | default active yes yes 11 | 12 | # cat /proc/sys/net/ipv4/ip_forward 13 | 1 14 | -------------------------------------------------------------------------------- /oz/stdout-examples/f19-25G.tdl: -------------------------------------------------------------------------------- 1 | 17 | 18 | -------------------------------------------------------------------------------- /oz/stdout-examples/f19/f19.tdl: -------------------------------------------------------------------------------- 1 | 17 | 18 | -------------------------------------------------------------------------------- /oz/stdout-examples/rhel63-tbox1Feb_15_2013-15:29:50: -------------------------------------------------------------------------------- 1 | 2 | 3 | rhel63-tbox1 4 | 1048576 5 | 1048576 6 | 45510fd5-3c10-47a4-a5a7-98545900688e 7 | 8 | 1 9 | 10 | 11 | 12 | 13 | 14 | 15 | hvm 16 | 17 | 18 | destroy 19 | destroy 20 | destroy 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /oz/stdout-examples/f19/f19-jeosJul_04_2013-12:42:32: -------------------------------------------------------------------------------- 1 | 2 | 3 | devstack 4 | 1048576 5 | 1048576 6 | 9767ba25-429c-49af-9b6a-33b97caf8b0e 7 | 8 | 1 9 | 10 | 11 | 12 | 13 | 14 | 15 | hvm 16 | 17 | 18 | destroy 19 | destroy 20 | destroy 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /libguestfs/hostname-guest-edit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #------------------------------------------------------------- 3 | # Original idea -- Rich Jones -- 4 | # -https://rwmj.wordpress.com/2010/08/30/python-script-to-replace-templates-in-configuration-files-in-vms/ 5 | # Modified by -- Kashyap Chamarthy 6 | # PURPOSE: To replace hostname in a guest using guestfish 7 | # Please read the comments. 8 | 9 | # *****WARNING**** : This should not be executed on a LIVE vm 10 | #------------------------------------------------------------- 11 | 12 | 13 | image = "/var/lib/libvirt/images/rhel6test.qcow2" 14 | 15 | #root_filesystem = "/dev/sda4" 16 | root_filesystem = "/dev/VolGroup/lv_root" 17 | 18 | filename = "/etc/sysconfig/network" 19 | 20 | pattern = "HOSTNAME=(.*)" 21 | replacement = "HOSTNAME=rootconf2012.foo.bar.com" 22 | 23 | 24 | # Import some standard python modules 25 | import tempfile 26 | import os 27 | import fileinput 28 | import shutil 29 | import sys 30 | import re 31 | 32 | # Import the guestfs module 33 | import guestfs 34 | 35 | 36 | # Create a libguestfs handle. 37 | g = guestfs.GuestFS () 38 | 39 | # Add the disk image. 40 | g.add_drive (image) 41 | 42 | # NOTE:the libguestfs handle should be launched *after* adding the 43 | # drive(s), and *before* any other commands are run. This launches the 44 | # qemu subprocess. 45 | g.launch () 46 | 47 | # Set the trace flag so that we can see each libguestfs call 48 | g.set_trace (1) 49 | 50 | # To access the filesystem in the disk image, mount it. (NOTE: both 51 | # block-devices and LVMs are detected) 52 | g.mount_options ("", root_filesystem, "/") 53 | 54 | #Create a temporary directory to edit the file. 55 | tmpdir = tempfile.mkdtemp () 56 | tmpfile = os.path.join (tmpdir, "filename") 57 | 58 | # Copy the file to a temporary location 59 | g.download (filename, tmpfile) 60 | 61 | # Edit the pattern w/ replacement 62 | for line in fileinput.FileInput (tmpfile, inplace=1): 63 | 64 | line = re.sub(pattern, replacement, line) 65 | print line, 66 | 67 | # Upload the file 68 | g.upload (tmpfile, filename) 69 | 70 | # Unmount all the file system(s). 71 | g.umount_all () 72 | 73 | # This will write any data buffered in memory to disk 74 | # NOTE: This is very important to do. 75 | g.sync () 76 | 77 | # Remove the temporary directory created. 78 | shutil.rmtree (tmpdir) 79 | 80 | # Exit 81 | sys.exit(0) 82 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Simple virt scripts for daily use (mostly for a developer/test 2 | engineer): 3 | 4 | - Create unattended Fedora guests using virt-install (RAW/QCOW2) 5 | - Creating JEOS(Just Enough Operating System) with Oz. 6 | - Simple guestfish script to do post install operations. 7 | 8 | Eventually try to add more cleaner scripts. 9 | 10 | NOTE: To speed up you installs, please change the value of 11 | location{1,2} to your nearest Fedora mirrors. 12 | 13 | 14 | Creating unattended guests 15 | ========================== 16 | 17 | Using virt-install 18 | ------------------ 19 | 20 | To create (this uses `virt-install`) a minimal (@core only) 10G qcow2 21 | disk, 2 vMEM, 2 vCPU, unattended Fedora: 22 | 23 | $ git clone \ 24 | https://github.com/kashyapc/virt-scripts.git 25 | 26 | $ cd virt-scripts 27 | 28 | Assuming you want to create a Fedora 23 guest: 29 | 30 | $ ./create-guest-qcow2.bash f23-jeos f23 x86_64 31 | 32 | Once finished, login using root (passwd: testpwd). 33 | 34 | 35 | Using Oz 36 | -------- 37 | 38 | If you want to use Oz (an automated guest install creator w/ minimal 39 | user input): 40 | 41 | 42 | Usage: ./oz-jeos.bash 43 | 'distro': f20, f23 44 | Examples: oz-jeos.bash f23-jeos f23 # Create f23 45 | 46 | 47 | Create a Fedora 23 guest: 48 | 49 | $ ./oz-jeos.bash f23-jeos f23 50 | 51 | Once installation is finished, define the libvirt XML for the guest (in 52 | this case 'f23-jeos'): 53 | 54 | $ virsh define $libvirt-XML-FROM-PREVIOUS-COMMAND 55 | 56 | List all the guests: 57 | 58 | $ virsh list --all 59 | 60 | Start it and connect to the guest's serial console: 61 | 62 | $ virsh start f23-jeos --console 63 | 64 | Or 65 | 66 | Connect to it via virt-viewer: 67 | 68 | $ virt-viewer f23-jeos 69 | 70 | 71 | Oz notes 72 | ~~~~~~~~ 73 | 74 | Oz uses something called TDL (template descriptive language). For 75 | example: 76 | 77 | ./stdout-examples/f23/f23.tdl 78 | 79 | 80 | Contents of the above file: 81 | 82 | ------------- 83 | 99 | -------------- 100 | 101 | To invoke manually, dump the above contents into 102 | 'f23.tdl' in the current directory, and do: 103 | 104 | $ oz-install ./f23.tdl 105 | 106 | Root password is defined in the attribute of the TDL. 107 | 108 | -------------------------------------------------------------------------------- /oz/stdout-examples/f19/oz-create-f19.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # A script to create joes(just enough operating system) 3 | # NOTE: once the oz-install is finished, define the xml file and start 4 | # the guest. 5 | # Author - Kashyap Chamarthy 6 | # Copyright (C) 2013 Red Hat, Inc. 7 | 8 | # usage 9 | if [ $# -ne 2 ]; then 10 | echo "Usage: $0 11 | 'distro': f19, rhel6 12 | Examples: `basename $0` f19-t1 f18 # create f18 13 | `basename $0` rhel6x-t1 rhel6 # create latest rhel6.x" 14 | exit 1 15 | fi 16 | 17 | TDLFILE=$2.tdl 18 | LOGFILE=$1.out 19 | LOGFILE2=nwinfo.out 20 | NAME=$1 21 | distro=$2 22 | 23 | # This must be run as root 24 | 25 | if [ `id -u` -ne 0 ] ; then 26 | echo "Please run as 'root' to execute '$0'!" 27 | exit 1 28 | fi 29 | 30 | # Enable IP forwarding on your host 31 | cat /proc/sys/net/ipv4/ip_forward 32 | 33 | if [ $? -ne 1 ] ; then 34 | echo 1 > /proc/sys/net/ipv4/ip_forward 35 | echo "IP forwarding enabled" 36 | fi 37 | 38 | # A few checks so that oz-install won't go crazy with iptables. (Just 39 | # deals with the default virt-network) 40 | run_command() { echo "# $@" eval "$@" } 41 | 42 | ( 43 | run_command /usr/bin/virsh net-destroy default 44 | run_command /usr/bin/virsh net-start default 45 | run_command /usr/bin/virsh net-list --all 46 | run_command cat /proc/sys/net/ipv4/ip_forward 47 | ) >& $LOGFILE2 48 | 49 | if [ "$distro" = rhel6 ]; then 50 | 51 | # Create the tdl file( 52 | # NOTE: Change the attribute below to your nearest Fedora tree. 53 | function _make_tdl_rhel() { 54 | cat << EOF > $TDLFILE 55 | 68 | 69 | EOF 70 | } 71 | 72 | # Create the TDL file 73 | _make_tdl_rhel 74 | 75 | #exit 255 76 | 77 | elif [ "$distro" = f19 ]; then 78 | 79 | function _make_tdl_fed() { 80 | cat << EOF > $TDLFILE 81 | 94 | 95 | EOF 96 | } 97 | 98 | # Create the TDL file 99 | _make_tdl_fed 100 | 101 | fi 102 | sleep 2 103 | 104 | #run the oz script as root 105 | /usr/bin/oz-install -d 4 $TDLFILE 2>&1 | tee $LOGFILE 106 | 107 | 108 | -------------------------------------------------------------------------------- /oz/oz-jeos.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Purpose: A script to create JEOS (Just Enough Operating System) guest 4 | # 5 | # Copyright (C) 2015-2016 Red Hat Inc. 6 | # NOTE: Once the `oz-install` command is finished, define the xml file 7 | # and start the guest 8 | # 9 | # Author - Kashyap Chamarthy 10 | # 11 | # This program is free software; you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation; either version 2 of the License, or (at 14 | # your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, but 17 | # WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | # General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program; if not, write to the Free Software 23 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 24 | # 02110-1301 USA. 25 | 26 | set -x 27 | 28 | # Usage 29 | if [ $# -ne 2 ]; then 30 | echo "Usage: $0 31 | 'distro': f23, f22 32 | Examples: `basename $0` f23-vm1 f23 # Create a F23 guest" 33 | exit 1 34 | fi 35 | 36 | TDLFILE=$2.tdl 37 | LOGFILE=$1.out 38 | LOGFILE2=nwinfo.out 39 | NAME=$1 40 | distro=$2 41 | 42 | # This must be run as root 43 | 44 | if [ `id -u` -ne 0 ] ; then 45 | echo "Please run as 'root' to execute '$0'!" 46 | exit 1 47 | fi 48 | 49 | # Enable IP forwarding on your host 50 | cat /proc/sys/net/ipv4/ip_forward 51 | 52 | if [ $? -ne 1 ] ; then 53 | echo 1 > /proc/sys/net/ipv4/ip_forward 54 | echo "IP forwarding enabled" 55 | fi 56 | 57 | # A few checks so that `oz-install` won't go crazy with iptables. (Just 58 | # deals with the default libvirt network) 59 | 60 | run_command() { 61 | echo "# $@" 62 | eval "$@" 63 | } 64 | 65 | ( 66 | run_command /usr/bin/virsh net-destroy default 67 | run_command /usr/bin/virsh net-start default 68 | run_command /usr/bin/virsh net-list --all 69 | run_command cat /proc/sys/net/ipv4/ip_forward 70 | ) >& $LOGFILE2 71 | 72 | if [ "$distro" = f23 ]; then 73 | 74 | # Create the TDL (Template Description Language) file 75 | 76 | function _make_tdl_fed() { 77 | cat << EOF > $TDLFILE 78 | 91 | EOF 92 | } 93 | 94 | elif [ "$distro" = f22 ]; then 95 | 96 | function _make_tdl_fed() { 97 | cat << EOF > $TDLFILE 98 | 111 | EOF 112 | } 113 | 114 | fi 115 | 116 | # Create the TDL file 117 | _make_tdl_fed 118 | sleep 2 119 | 120 | # Invoke `oz-install`, as root 121 | /usr/bin/oz-install -d 4 $TDLFILE 2>&1 | tee $LOGFILE 122 | -------------------------------------------------------------------------------- /create-guest-qcow2-btrfs.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #set -x 4 | 5 | # Copyright (C) 2014 Red Hat Inc. 6 | # Author 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | # 22 | 23 | # Script to create/install unattended Virtual Machines (with bridging) 24 | # 25 | # 1 Note: Bridging should be configured on the host to allow guests to be 26 | # in the same subnet as hosts 27 | # 2 Creting a bridge, refer this: http://wiki.libvirt.org/page/Networking 28 | # 3 The kickstart file contains minimal fedora pkgs like core and text internet 29 | # 4 Also adds a serial console 30 | # 31 | 32 | 33 | IMAGE_HOME="/var/lib/libvirt/images" 34 | 35 | burl="http://dl.fedoraproject.org/pub" 36 | location1="$burl/fedora/linux/releases/19/Fedora/ARCH/os" 37 | location2="$burl/fedora/linux/releases/20/Fedora/ARCH/os" 38 | 39 | 40 | # External F20 mirror 41 | # http://dl.fedoraproject.org/pub/fedora/linux/releases/20/Fedora/x86_64/ 42 | 43 | 44 | # Create a minimal kickstart file and return the temporary file name. 45 | # Do remember to delete this temporary file when it is no longer required. 46 | # 47 | create_ks_file() 48 | { 49 | dist=$1 50 | fkstart=$(mktemp -u --tmpdir=$(pwd) .XXXXXXXXXXXXXX) 51 | 52 | cat << EOF > $fkstart 53 | install 54 | text 55 | reboot 56 | lang en_US.UTF-8 57 | keyboard us 58 | network --bootproto dhcp 59 | rootpw testpwd 60 | firewall --enabled --ssh 61 | selinux --enforcing 62 | timezone --utc America/New_York 63 | bootloader --location=mbr --append="console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH" 64 | zerombr 65 | clearpart --all --initlabel 66 | autopart --type=btrfs 67 | 68 | %packages 69 | @core 70 | %end 71 | EOF 72 | echo "$fkstart" 73 | } 74 | 75 | create_guest() 76 | { 77 | name=$1 78 | arch=$2 79 | dist=$3 80 | locn=$4 81 | dimg=$5 82 | fkst=$(create_ks_file $dist) 83 | bnam=$(basename $fkst) 84 | 85 | echo "Creating domain $name..." 86 | echo "Disk image will be created at: $dimg" 87 | 88 | # Create the qcow2 disk image with preallocation and 'fallocate' 89 | # (which pre-allocates all the blocks to a file) it for maximum 90 | # performance. 91 | # 92 | # fallocate -l `ls -al $diskimage | awk '{print $5}'` $diskimage 93 | # 94 | echo "Creating qcow2 disk image..." 95 | qemu-img create -f qcow2 -o preallocation=metadata $dimg 10G 96 | echo `ls -lash $dimg` 97 | 98 | virt-install --connect=qemu:///system \ 99 | --network=bridge:virbr0 \ 100 | --initrd-inject=$bnam \ 101 | --extra-args="ks=file:/$bnam console=tty0 console=ttyS0,115200" \ 102 | --name=$name \ 103 | --disk path=$dimg,format=qcow2,cache=none \ 104 | --ram 2048 \ 105 | --vcpus=2 \ 106 | --check-cpu \ 107 | --accelerate \ 108 | --cpuset auto \ 109 | --os-type linux \ 110 | --os-variant $dist \ 111 | --hvm \ 112 | --location=$locn \ 113 | --nographics \ 114 | --console=pty 115 | 116 | rm $fkst 117 | return 0 118 | } 119 | 120 | # main 121 | { 122 | # check if min no. of arguments are 3 123 | # 124 | if [ "$#" != 3 ]; then 125 | echo -e "Usage: $0 vm-name distro arch\n" 126 | echo -e "\tdistro: f19 f20" 127 | echo -e "\t arch: i386, x86_64 128 | e.g. ./`basename $0` f20vm1 f20 x86_64 # create fedora 20 VM 129 | ./`basename $0` f19vm1 f19 x86_64 # create fedora f19 VM" 130 | 131 | exit 255 132 | fi 133 | 134 | # check if Linux bridging is configured 135 | # 136 | show_bridge=`brctl show | awk 'NR==2 {print $1}'` 137 | if [ $? -ne 0 ] ; then 138 | echo "Bridged Networking is not configured. " \ 139 | "please do so if your guest needs an IP similar to your host." 140 | exit 255 141 | fi 142 | 143 | name=$1 144 | dist=$2 145 | arch=$3 146 | dimg="$IMAGE_HOME/$name.qcow2" 147 | 148 | locn="" 149 | case "$dist" in 150 | f19) 151 | dist="fedora19" 152 | locn=${location1/ARCH/$arch} 153 | ;; 154 | 155 | f20) 156 | dist="fedora20" 157 | locn=${location2/ARCH/$arch} 158 | ;; 159 | 160 | 161 | *) 162 | echo "$0: invalid distribution name" 163 | exit 255 164 | esac 165 | create_guest $name $arch $dist $locn $dimg 166 | 167 | exit 0 168 | } 169 | -------------------------------------------------------------------------------- /jeos-guest-create.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Kickstart borrowed(& slightly tweaked) from -- 4 | # https://raw.github.com/autotest/virt-test/master/shared/unattended/JeOS-17.ks 5 | # Contact: kashyapc@fedoraproject.org 6 | # 7 | #Check if bridging is configured 8 | show_bridge=`brctl show | awk 'NR==2 {print $1}'` 9 | if [ $? -ne 0 ] ; then 10 | echo "Bridged Networking is not configured, please do so to get an IP similar to your host." 11 | exit 255 12 | fi 13 | 14 | #check if no. of arguments are 3 15 | if [ "$#" != 3 ]; then 16 | echo " Please provide the args according to usage" 17 | echo "" 18 | echo " usage: "$0 name distro arch" " 19 | echo "" 20 | echo " where 'name' = f18vm1 " 21 | echo " where 'distro' = f18 " 22 | echo " where 'arch' = x86_64 [OR] i386 " 23 | echo "" 24 | exit 255 25 | fi 26 | 27 | name=$1 28 | distro=$2 29 | arch=$3 30 | 31 | 32 | location1=http://dl.fedoraproject.org/pub/fedora/linux/releases/18/Fedora/$arch/os/ 33 | 34 | echo "Creating domain $name..." 35 | echo "Disk image will be created as /var/lib/libvirt/images/$name.qcow2" 36 | echo "Location of the OS sources $location2..." 37 | 38 | #Disk Image location 39 | diskimage=/var/lib/libvirt/images/$name.qcow2 40 | 41 | #Create the qcow2 disk image with preallocation and 'facllocate'(which pre-allocates all the blocks to a file) it for max. performance 42 | echo "Creating qcow2 disk image.." 43 | qemu-img create -f qcow2 -o preallocation=metadata $diskimage 2G 44 | 45 | #NOTE : Uncomment the below comment, *if* you want to allocate all the blocks (and marks them unintialized). But this will remove the sparseness 46 | #fallocate -l `ls -al $diskimage | awk '{print $5}'` $diskimage 47 | echo `ls -lash $diskimage` 48 | #!/bin/bash 49 | cat << EOF > fed.ks 50 | install 51 | text 52 | reboot 53 | lang en_US.UTF-8 54 | keyboard us 55 | network --bootproto dhcp 56 | rootpw 123456 57 | firewall --disabled 58 | selinux --disabled 59 | timezone --utc America/New_York 60 | firstboot --disable 61 | bootloader --location=mbr --timeout=0 --append="console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH" 62 | zerombr 63 | poweroff 64 | 65 | clearpart --all --initlabel 66 | part / --fstype=ext4 --grow --asprimary --size=1 67 | 68 | %packages 69 | gpgme 70 | hardlink 71 | dmidecode 72 | ethtool 73 | tcpdump 74 | tar 75 | bzip2 76 | -yum-utils 77 | -cryptsetup 78 | -vconfig 79 | -dump 80 | -acpid 81 | -mlocate 82 | -stunnel 83 | -rng-tools 84 | -ntfs-3g 85 | -sos 86 | -jwhois 87 | -fedora-release-notes 88 | -pam_pkcs11 89 | -wireless-tools 90 | -rdist 91 | -mdadm 92 | -dmraid 93 | -ftp 94 | -rsync 95 | -system-config-network-tui 96 | -pam_krb5 97 | -nano 98 | -nc 99 | -PackageKit-yum-plugin 100 | -btrfs-progs 101 | -ypbind 102 | -yum-presto 103 | -microcode_ctl 104 | -finger 105 | -krb5-workstation 106 | -ntfsprogs 107 | -iptstate 108 | -fprintd-pam 109 | -irqbalance 110 | -dosfstools 111 | -mcelog 112 | -smartmontools 113 | -lftp 114 | -unzip 115 | -rsh 116 | -telnet 117 | -setuptool 118 | -bash-completion 119 | -pinfo 120 | -rdate 121 | -system-config-firewall-tui 122 | -nfs-utils 123 | -words 124 | -cifs-utils 125 | -prelink 126 | -wget 127 | -dos2unix 128 | -passwdqc 129 | -coolkey 130 | -symlinks 131 | -pm-utils 132 | -bridge-utils 133 | -zip 134 | -eject 135 | -numactl 136 | -mtr 137 | -sssd 138 | -pcmciautils 139 | -tree 140 | -usbutils 141 | -hunspell 142 | -irda-utils 143 | -time 144 | -man-pages 145 | -yum-langpacks 146 | -talk 147 | -wpa_supplicant 148 | -kbd-misc 149 | -kbd 150 | -slang 151 | -authconfig 152 | -newt 153 | -newt-python 154 | -ntsysv 155 | -libnl3 156 | -tcp_wrappers 157 | -quota 158 | -libpipeline 159 | -man-db 160 | -groff 161 | -less 162 | -plymouth-core-libs 163 | -plymouth 164 | -plymouth-scripts 165 | -libgudev1 166 | -ModemManager 167 | -NetworkManager-glib 168 | -selinux-policy 169 | -selinux-policy-targeted 170 | -crontabs 171 | -cronie 172 | -cronie-anacron 173 | -cyrus-sasl 174 | -sendmail 175 | -netxen-firmware 176 | -linux-firmware 177 | -libdaemon 178 | -avahi-autoipd 179 | -libpcap 180 | -ppp 181 | -libsss_sudo 182 | -sudo 183 | -at 184 | -psacct 185 | -parted 186 | -passwd 187 | -bind-utils 188 | -tmpwatch 189 | -bc 190 | -acl 191 | -attr 192 | -traceroute 193 | -mailcap 194 | -quota-nls 195 | -mobile-broadband-provider-info 196 | -audit 197 | -e2fsprogs-libs 198 | -e2fsprogs 199 | -pciutils-libs 200 | -biosdevname 201 | -pciutils 202 | -dbus-glib 203 | -libdrm 204 | -setserial 205 | -lsof 206 | -ed 207 | -cyrus-sasl-plain 208 | -dnsmasq 209 | -system-config-firewall-base 210 | -hesiod 211 | -libpciaccess 212 | -diffutils 213 | -policycoreutils 214 | -m4 215 | -checkpolicy 216 | -procmail 217 | -libuser 218 | -polkit 219 | %end 220 | 221 | %post --interpreter /usr/bin/python 222 | import os 223 | os.system('grubby --remove-args="rhgb quiet" --update-kernel=$(grubby --default-kernel)') 224 | os.system('dhclient') 225 | os.system('chkconfig sshd on') 226 | os.system('iptables -F') 227 | os.system('echo 0 > /selinux/enforce') 228 | os.system('echo Post set up finished > /dev/ttyS0') 229 | os.system('echo Post set up finished > /dev/hvc0') 230 | %end 231 | EOF 232 | 233 | 234 | #Create the guest 235 | if [ "$distro" = f18 ]; then 236 | virt-install --connect=qemu:///system \ 237 | --network=bridge:br0 \ 238 | --initrd-inject=./fed.ks \ 239 | --extra-args="ks=file:/fed.ks console=tty0 console=ttyS0,115200 serial rd_NO_PLYMOUTH" \ 240 | --name=$name \ 241 | --disk path=$diskimage,format=qcow2,cache=none \ 242 | --ram 2048 \ 243 | --vcpus=2 \ 244 | --check-cpu \ 245 | --accelerate \ 246 | --os-type linux \ 247 | --os-variant fedora17 \ 248 | --cpuset auto \ 249 | --hvm \ 250 | --location=$location1 \ 251 | --nographics 252 | fi 253 | 254 | -------------------------------------------------------------------------------- /create-guest-raw.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2015 Red Hat Inc. 4 | # Author: 5 | # Further contributions: 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | # 21 | # 22 | # Purpose: Script to create/install a virtual machine (raw disk) 23 | # 24 | # - If you need linux bridging, it should be configured on the host to 25 | # allow guests to be in the same subnet as hosts 26 | # - References: 27 | # - http://wiki.libvirt.org/page/Networking 28 | # - https://kashyapc.fedorapeople.org/virt/configuring-bridging-f19+.txt 29 | # - The kickstart file contains minimal Fedora packages (@core) 30 | # - This script also provides a serial console 31 | 32 | 33 | #set -x 34 | 35 | VERSION="0.1" 36 | prog=`basename $0` 37 | 38 | fstype="ext4" 39 | IMAGE_HOME="/var/lib/libvirt/images" 40 | 41 | burl="http://dl.fedoraproject.org/pub" 42 | location1="$burl/fedora/linux/releases/20/Fedora/ARCH/os" 43 | location2="$burl/fedora/linux/releases/21/Server/ARCH/os" 44 | 45 | 46 | # Create a minimal kickstart file and return the temporary file name. 47 | # Do remember to delete this temporary file when it is no longer required. 48 | # 49 | create_ks_file() 50 | { 51 | dist=$1 52 | fkstart=$(mktemp -u --tmpdir=$(pwd) .XXXXXXXXXXXXXX) 53 | 54 | cat << EOF > $fkstart 55 | install 56 | text 57 | reboot 58 | lang en_US.UTF-8 59 | keyboard us 60 | network --bootproto dhcp 61 | rootpw testpwd 62 | firewall --enabled --ssh 63 | selinux --enforcing 64 | timezone --utc America/New_York 65 | bootloader --location=mbr --append="console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH" 66 | zerombr 67 | clearpart --all --initlabel 68 | autopart --type=$fstype 69 | 70 | %packages 71 | @core 72 | %end 73 | EOF 74 | echo "$fkstart" 75 | } 76 | 77 | create_guest() 78 | { 79 | name=$1 80 | arch=$2 81 | dist=$3 82 | locn=$4 83 | dimg=$5 84 | fkst=$(create_ks_file $dist) 85 | bnam=$(basename $fkst) 86 | 87 | echo "Creating domain $name..." 88 | echo "Disk image will be created at: $dimg" 89 | 90 | echo "Creating RAW disk image..." 91 | qemu-img create -f raw $dimg 10G 92 | echo `ls -lash $dimg` 93 | 94 | virt-install --connect=qemu:///system \ 95 | --network=network:default \ 96 | --initrd-inject=$bnam \ 97 | --extra-args="ks=file:/$bnam console=tty0 console=ttyS0,115200" \ 98 | --name=$name \ 99 | --disk path=$dimg,format=raw,cache=writeback \ 100 | --ram 2048 \ 101 | --vcpus=2 \ 102 | --check-cpu \ 103 | --accelerate \ 104 | --os-type linux \ 105 | --os-variant $dist \ 106 | --hvm \ 107 | --location=$locn \ 108 | --nographics \ 109 | --serial=pty 110 | 111 | rm $fkst 112 | return 0 113 | } 114 | 115 | usage () 116 | { 117 | echo -e "Usage: $prog [OPTIONS] \n" 118 | echo " distro: f20 f21" 119 | echo " arch: i386, x86_64" 120 | } 121 | 122 | printh () 123 | { 124 | format="%-15s %s\n" 125 | 126 | usage; 127 | printf "\n%s\n\n" "OPTIONS:" 128 | printf "$format" " -f " "specify file system type, default: ext4" 129 | printf "$format" " -h" "display this help" 130 | printf "$format" " -v" "display version information" 131 | printf "\nReport bugs to Kashyap \n" 132 | } 133 | 134 | check_options () 135 | { 136 | while getopts ":+f:hv" arg "$@"; 137 | do 138 | case $arg in 139 | :) 140 | printf "$prog: missing argument\n" 141 | exit 0 142 | ;; 143 | 144 | f) 145 | fstype=$OPTARG 146 | ;; 147 | 148 | h) 149 | printh 150 | exit 0 151 | ;; 152 | 153 | v) 154 | printf "%s version %s\n" $prog $VERSION 155 | exit 0 156 | ;; 157 | 158 | *) 159 | printf "%s: invalid option\n" $prog 160 | exit 255 161 | esac 162 | done 163 | 164 | return $(($OPTIND - 1)); 165 | } 166 | 167 | # main 168 | { 169 | check_options $@; 170 | shift $?; 171 | 172 | # check if min no. of arguments are 3 173 | # 174 | if [ "$#" != 3 ]; then 175 | printh; 176 | exit 255 177 | fi 178 | 179 | # check if Linux bridging is configured 180 | # 181 | show_bridge=`brctl show | awk 'NR==2 {print $1}'` 182 | if [ $? -ne 0 ] ; then 183 | echo "Bridged Networking is not configured. " \ 184 | "please do so if your guest needs an IP similar to your host." 185 | exit 255 186 | fi 187 | 188 | name=$1 189 | dist=$2 190 | arch=$3 191 | dimg="$IMAGE_HOME/$name.img" 192 | 193 | locn="" 194 | case "$dist" in 195 | f20) 196 | dist="fedora20" 197 | locn=${location1/ARCH/$arch} 198 | ;; 199 | 200 | f21) 201 | dist="fedora21" 202 | locn=${location2/ARCH/$arch} 203 | ;; 204 | 205 | 206 | *) 207 | echo "$0: invalid distribution name" 208 | exit 255 209 | esac 210 | create_guest $name $arch $dist $locn $dimg 211 | 212 | exit 0 213 | } 214 | -------------------------------------------------------------------------------- /oz/stdout-examples/f19/f19-jeos.out: -------------------------------------------------------------------------------- 1 | DEBUG:oz.Guest.FedoraGuest:libvirt bridge name is virbr0 2 | DEBUG:oz.Guest.FedoraGuest:Libvirt type is kvm 3 | DEBUG:oz.Guest.FedoraGuest:Name: devstack, UUID: 9767ba25-429c-49af-9b6a-33b97caf8b0e 4 | DEBUG:oz.Guest.FedoraGuest:MAC: 52:54:00:ee:bd:07, distro: Fedora 5 | DEBUG:oz.Guest.FedoraGuest:update: 19, arch: x86_64, diskimage: /var/lib/libvirt/images/devstack.dsk 6 | DEBUG:oz.Guest.FedoraGuest:nicmodel: virtio, clockoffset: utc 7 | DEBUG:oz.Guest.FedoraGuest:mousetype: ps2, disk_bus: virtio, disk_dev: vda 8 | DEBUG:oz.Guest.FedoraGuest:icicletmp: /var/lib/oz/icicletmp/devstack, listen_port: 57585 9 | DEBUG:oz.Guest.FedoraGuest:Original ISO path: /var/lib/oz/isos/Fedora19x86_64-url.iso 10 | DEBUG:oz.Guest.FedoraGuest:Modified ISO cache: /var/lib/oz/isos/Fedora19x86_64-url-oz.iso 11 | DEBUG:oz.Guest.FedoraGuest:Output ISO path: /var/lib/libvirt/images/devstack-url-oz.iso 12 | DEBUG:oz.Guest.FedoraGuest:ISO content path: /var/lib/oz/isocontent/devstack-url 13 | INFO:oz.Guest.FedoraGuest:Checking for guest conflicts with devstack 14 | DEBUG:oz.Guest.FedoraGuest:Installtype is URL, trying to do direct kernel boot 15 | DEBUG:oz.Guest.FedoraGuest:Going to write treeinfo to /var/lib/oz/icicletmp/devstack/treeinfo 16 | DEBUG:oz.Guest.FedoraGuest:Trying to get treeinfo from http://dl.fedoraproject.org/pub/fedora/linux/releases/19/Fedora/x86_64/os//.treeinfo 17 | DEBUG:oz.Guest.FedoraGuest:Got treeinfo, parsing 18 | DEBUG:oz.Guest.FedoraGuest:Returning kernel images/pxeboot/vmlinuz and initrd images/pxeboot/initrd.img 19 | INFO:oz.Guest.FedoraGuest:Fetching the original media 20 | DEBUG:oz.Guest.FedoraGuest:Attempting to get the lock for /var/lib/oz/kernels/Fedora19x86_64-kernel 21 | DEBUG:oz.Guest.FedoraGuest:Got the lock, doing the download 22 | INFO:oz.Guest.FedoraGuest:Original install media available, using cached version 23 | INFO:oz.Guest.FedoraGuest:Fetching the original media 24 | DEBUG:oz.Guest.FedoraGuest:Attempting to get the lock for /var/lib/oz/kernels/Fedora19x86_64-ramdisk 25 | DEBUG:oz.Guest.FedoraGuest:Got the lock, doing the download 26 | INFO:oz.Guest.FedoraGuest:Original install media available, using cached version 27 | DEBUG:oz.Guest.FedoraGuest:Putting the kickstart in place 28 | DEBUG:oz.Guest.FedoraGuest:Writing cpio to /var/lib/oz/icicletmp/devstack/extra.cpio 29 | INFO:oz.Guest.FedoraGuest:Generating 25GB diskimage for devstack 30 | INFO:oz.Guest.FedoraGuest:Running install for devstack 31 | INFO:oz.Guest.FedoraGuest:Generate XML for guest devstack with bootdev None 32 | DEBUG:oz.Guest.FedoraGuest:Generated XML: 33 | 34 | 35 | devstack 36 | 1048576 37 | 1048576 38 | 9767ba25-429c-49af-9b6a-33b97caf8b0e 39 | 40 | 1 41 | 42 | 43 | 44 | 45 | 46 | 47 | hvm 48 | /var/lib/libvirt/images/devstack-kernel 49 | /var/lib/libvirt/images/devstack-ramdisk 50 | method=http://dl.fedoraproject.org/pub/fedora/linux/releases/19/Fedora/x86_64/os/ ks=file:/ks.cfg 51 | 52 | destroy 53 | destroy 54 | destroy 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1200/1200 80 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1190/1200 81 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1180/1200 82 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1170/1200 83 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1160/1200 84 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1150/1200 85 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1140/1200 86 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1130/1200 87 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1120/1200 88 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1110/1200 89 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1100/1200 90 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1090/1200 91 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1080/1200 92 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1070/1200 93 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1060/1200 94 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1050/1200 95 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to finish installing, 1040/1200 96 | DEBUG:oz.Guest.FedoraGuest:Waiting for devstack to complete shutdown, 10/10 97 | INFO:oz.Guest.FedoraGuest:Install of devstack succeeded 98 | INFO:oz.Guest.FedoraGuest:Generate XML for guest devstack with bootdev hd 99 | DEBUG:oz.Guest.FedoraGuest:Generated XML: 100 | 101 | 102 | devstack 103 | 1048576 104 | 1048576 105 | 9767ba25-429c-49af-9b6a-33b97caf8b0e 106 | 107 | 1 108 | 109 | 110 | 111 | 112 | 113 | 114 | hvm 115 | 116 | 117 | destroy 118 | destroy 119 | destroy 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | INFO:oz.Guest.FedoraGuest:Cleaning up after install 145 | Libvirt XML was written to devstackJul_04_2013-12:42:32 146 | -------------------------------------------------------------------------------- /create-guest-qcow2.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2016 Red Hat Inc. 4 | # Author: Kashyap Chamarthy 5 | # Further contributions: Prasad J. Pandit 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software 19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | # 21 | # 22 | # Purpose: Script to create/install a virtual machine (qcow2 disk) 23 | # 24 | # - If you need linux bridging, it should be configured on the host to 25 | # allow guests to be in the same subnet as hosts 26 | # - References: 27 | # - http://wiki.libvirt.org/page/Networking 28 | # - https://kashyapc.fedorapeople.org/virt/configuring-bridging-f19+.txt 29 | # - The kickstart file contains minimal Fedora packages (@core) 30 | # - This script also provides access to serial console to the VM 31 | 32 | 33 | #set -x 34 | 35 | VERSION="0.3" 36 | prog=`basename $0` 37 | 38 | fstype="ext4" 39 | IMAGE_HOME="/var/lib/libvirt/images" 40 | 41 | burl="http://dl.fedoraproject.org/pub" 42 | location1="$burl/fedora/linux/releases/22/Server/ARCH/os" 43 | location2="$burl/fedora/linux/releases/23/Server/ARCH/os" 44 | location3="$burl/fedora/linux/development/rawhide/ARCH/os" 45 | 46 | # Create a minimal kickstart file and return the temporary file name. 47 | # Do remember to delete this temporary file when it is no longer required. 48 | # 49 | create_ks_file() 50 | { 51 | dist=$1 52 | fkstart=$(mktemp -u --tmpdir=$(pwd) .XXXXXXXXXXXXXX) 53 | 54 | cat << EOF > $fkstart 55 | install 56 | text 57 | shutdown 58 | lang en_US.UTF-8 59 | keyboard us 60 | network --bootproto dhcp 61 | rootpw testpwd 62 | firewall --enabled --ssh 63 | selinux --enforcing 64 | timezone --utc America/New_York 65 | bootloader --location=mbr --append="console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH" 66 | zerombr 67 | clearpart --all --initlabel 68 | autopart --type=$fstype 69 | 70 | %packages 71 | @core 72 | %end 73 | EOF 74 | echo "$fkstart" 75 | } 76 | 77 | create_guest() 78 | { 79 | name=$1 80 | arch=$2 81 | dist=$3 82 | locn=$4 83 | dimg=$5 84 | fkst=$(create_ks_file $dist) 85 | bnam=$(basename $fkst) 86 | 87 | echo "Creating domain $name..." 88 | echo "Disk image will be created at: $dimg" 89 | 90 | # Create the qcow2 disk image with preallocation and 'fallocate' 91 | # (which pre-allocates all the blocks to a file) it for maximum 92 | # performance. 93 | # 94 | # fallocate -l `ls -al $diskimage | awk '{print $5}'` $diskimage 95 | # 96 | echo "Creating qcow2 disk image..." 97 | qemu-img create -f qcow2 -o preallocation=metadata $dimg 10G 98 | echo `ls -lash $dimg` 99 | 100 | virt-install --connect=qemu:///system \ 101 | --network=network:default \ 102 | --initrd-inject=$bnam \ 103 | --extra-args="ks=file:/$bnam console=tty0 console=ttyS0,115200" \ 104 | --name=$name \ 105 | --disk path=$dimg,format=qcow2,cache=writeback \ 106 | --ram 2048 \ 107 | --vcpus=2 \ 108 | --check-cpu \ 109 | --accelerate \ 110 | --os-type linux \ 111 | --os-variant $dist \ 112 | --hvm \ 113 | --location=$locn \ 114 | --nographics \ 115 | --serial=pty\ 116 | --noreboot 117 | 118 | rm $fkst 119 | return 0 120 | } 121 | 122 | usage () 123 | { 124 | echo -e "Usage: $prog [OPTIONS] [dest-dir]\n" 125 | 126 | echo "distro : f22, f23, rawhide, 127 | [Or, path to HTTP URL, like]: http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/x86_64/os/" 128 | echo "arch : x86_64, i386" 129 | echo "dest-dir : /path/dest-dir [Optional: Alternate directory to store images, 130 | assuming QEMU has access to it, i.e. 'chmod go+rx /path/dest-dir'] 131 | 132 | EXAMPLES: 133 | 134 | # Create a Fedora-23 VM: 135 | ./`basename $0` vm1 f23 x86_64 136 | 137 | # Create a Fedora-23 VM, and store the VM disk image in the said dir: 138 | ./`basename $0` vm2 f23 x86_64 /export/vmimages 139 | 140 | # Create a Fedora-23 VM, with the specified Fedora tree URL: 141 | ./`basename $0` vm3 http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/x86_64/os/ x86_64" 142 | } 143 | 144 | printh () 145 | { 146 | format="%-15s %s\n" 147 | 148 | usage; 149 | printf "\n%s\n\n" "OPTIONS:" 150 | printf "$format" " -f " "specify file system type, default: ext4" 151 | printf "$format" " -h" "display this help" 152 | printf "$format" " -v" "display version information" 153 | printf "\nReport bugs here: 154 | https://github.com/kashyapc/virt-scripts/issues\n" 155 | } 156 | 157 | check_options () 158 | { 159 | while getopts ":+f:hv" arg "$@"; 160 | do 161 | case $arg in 162 | :) 163 | printf "$prog: missing argument\n" 164 | exit 0 165 | ;; 166 | 167 | f) 168 | fstype=$OPTARG 169 | ;; 170 | 171 | h) 172 | printh 173 | exit 0 174 | ;; 175 | 176 | v) 177 | printf "%s version %s\n" $prog $VERSION 178 | exit 0 179 | ;; 180 | 181 | *) 182 | printf "%s: invalid option\n" $prog 183 | exit 255 184 | esac 185 | done 186 | 187 | return $(($OPTIND - 1)); 188 | } 189 | 190 | # main 191 | { 192 | check_options $@; 193 | shift $?; 194 | 195 | # check if min no. of arguments are 3 196 | # 197 | if [ "$#" -lt 3 ]; then 198 | printh; 199 | exit 255 200 | fi 201 | 202 | # check if Linux bridging is configured 203 | # 204 | show_bridge=`brctl show | awk 'NR==2 {print $1}'` 205 | if [ $? -ne 0 ] ; then 206 | echo "Bridged Networking is not configured. " \ 207 | "please do so if your guest needs an IP similar to your host." 208 | exit 255 209 | fi 210 | 211 | name=$1 212 | dist=$2 213 | arch=$3 214 | destdir=$4 215 | test -n "$destdir" && IMAGE_HOME="$destdir" 216 | dimg="$IMAGE_HOME/$name.qcow2" 217 | 218 | locn="" 219 | case "$dist" in 220 | f22) 221 | dist="fedora22" 222 | locn=${location1/ARCH/$arch} 223 | ;; 224 | 225 | f23) 226 | dist="fedora23" 227 | locn=${location2/ARCH/$arch} 228 | ;; 229 | 230 | rawhide) 231 | dist="fedora23" 232 | locn=${location3/ARCH/$arch} 233 | ;; 234 | 235 | http*) 236 | locn=${dist/ARCH/$arch} 237 | echo "RAW version: $locn" 238 | dist="fedora23" 239 | ;; 240 | 241 | *) 242 | echo "$0: invalid distribution name" 243 | exit 255 244 | esac 245 | create_guest $name $arch $dist $locn $dimg 246 | 247 | exit 0 248 | } 249 | -------------------------------------------------------------------------------- /oz/stdout-examples/rhel63-tbox1.out: -------------------------------------------------------------------------------- 1 | DEBUG:oz.Guest.RHEL6Guest:libvirt bridge name is virbr0 2 | DEBUG:oz.Guest.RHEL6Guest:Libvirt type is kvm 3 | DEBUG:oz.Guest.RHEL6Guest:Original URL http://download.foo.bar.redhat.com/pub/rhel/released/RHEL-6/6.3/Server/x86_64/os resolved to http://download.eng.pnq.redhat.com/pub/rhel/released/RHEL-6/6.3/Server/x86_64/os/ 4 | DEBUG:oz.Guest.RHEL6Guest:Name: rhel63-tbox1, UUID: 45510fd5-3c10-47a4-a5a7-98545900688e 5 | DEBUG:oz.Guest.RHEL6Guest:MAC: 52:54:00:b7:6d:fd, distro: RHEL-6 6 | DEBUG:oz.Guest.RHEL6Guest:update: 3, arch: x86_64, diskimage: /var/lib/libvirt/images/rhel63-tbox1.dsk 7 | DEBUG:oz.Guest.RHEL6Guest:nicmodel: virtio, clockoffset: utc 8 | DEBUG:oz.Guest.RHEL6Guest:mousetype: ps2, disk_bus: virtio, disk_dev: vda 9 | DEBUG:oz.Guest.RHEL6Guest:icicletmp: /var/lib/oz/icicletmp/rhel63-tbox1, listen_port: 19127 10 | DEBUG:oz.Guest.RHEL6Guest:Original ISO path: /var/lib/oz/isos/RHEL-63x86_64-url.iso 11 | DEBUG:oz.Guest.RHEL6Guest:Modified ISO cache: /var/lib/oz/isos/RHEL-63x86_64-url-oz.iso 12 | DEBUG:oz.Guest.RHEL6Guest:Output ISO path: /var/lib/libvirt/images/rhel63-tbox1-url-oz.iso 13 | DEBUG:oz.Guest.RHEL6Guest:ISO content path: /var/lib/oz/isocontent/rhel63-tbox1-url 14 | INFO:oz.Guest.RHEL6Guest:Checking for guest conflicts with rhel63-tbox1 15 | DEBUG:oz.Guest.RHEL6Guest:Installtype is URL, trying to do direct kernel boot 16 | DEBUG:oz.Guest.RHEL6Guest:Going to write treeinfo to /var/lib/oz/icicletmp/rhel63-tbox1/treeinfo 17 | DEBUG:oz.Guest.RHEL6Guest:Trying to get treeinfo from http://download.foo.bar.redhat.com/pub/rhel/released/RHEL-6/6.3/Server/x86_64/os//.treeinfo 18 | DEBUG:oz.Guest.RHEL6Guest:Got treeinfo, parsing 19 | DEBUG:oz.Guest.RHEL6Guest:Returning kernel images/pxeboot/vmlinuz and initrd images/pxeboot/initrd.img 20 | INFO:oz.Guest.RHEL6Guest:Fetching the original media 21 | DEBUG:oz.Guest.RHEL6Guest:Attempting to get the lock for /var/lib/oz/kernels/RHEL-63x86_64-kernel 22 | DEBUG:oz.Guest.RHEL6Guest:Got the lock, doing the download 23 | INFO:oz.Guest.RHEL6Guest:Fetching the original install media from http://download.foo.bar.redhat.com/pub/rhel/released/RHEL-6/6.3/Server/x86_64/os/images/pxeboot/vmlinuz 24 | DEBUG:oz.Guest.RHEL6Guest:2kB of 3893kB 25 | DEBUG:oz.Guest.RHEL6Guest:3893kB of 3893kB 26 | DEBUG:oz.Guest.RHEL6Guest:3893kB of 3893kB 27 | DEBUG:oz.Guest.RHEL6Guest:3893kB of 3893kB 28 | INFO:oz.Guest.RHEL6Guest:Fetching the original media 29 | DEBUG:oz.Guest.RHEL6Guest:Attempting to get the lock for /var/lib/oz/kernels/RHEL-63x86_64-ramdisk 30 | DEBUG:oz.Guest.RHEL6Guest:Got the lock, doing the download 31 | INFO:oz.Guest.RHEL6Guest:Fetching the original install media from http://download.foo.bar.redhat.com/pub/rhel/released/RHEL-6/6.3/Server/x86_64/os/images/pxeboot/initrd.img 32 | DEBUG:oz.Guest.RHEL6Guest:2kB of 29729kB 33 | DEBUG:oz.Guest.RHEL6Guest:10240kB of 29729kB 34 | DEBUG:oz.Guest.RHEL6Guest:20480kB of 29729kB 35 | DEBUG:oz.Guest.RHEL6Guest:29729kB of 29729kB 36 | DEBUG:oz.Guest.RHEL6Guest:29729kB of 29729kB 37 | DEBUG:oz.Guest.RHEL6Guest:29729kB of 29729kB 38 | DEBUG:oz.Guest.RHEL6Guest:Putting the kickstart in place 39 | DEBUG:oz.Guest.RHEL6Guest:Writing cpio to /var/lib/oz/icicletmp/rhel63-tbox1/extra.cpio 40 | INFO:oz.Guest.RHEL6Guest:Generating 10GB diskimage for rhel63-tbox1 41 | INFO:oz.Guest.RHEL6Guest:Running install for rhel63-tbox1 42 | INFO:oz.Guest.RHEL6Guest:Generate XML for guest rhel63-tbox1 with bootdev None 43 | DEBUG:oz.Guest.RHEL6Guest:Generated XML: 44 | 45 | 46 | rhel63-tbox1 47 | 1048576 48 | 1048576 49 | 45510fd5-3c10-47a4-a5a7-98545900688e 50 | 51 | 1 52 | 53 | 54 | 55 | 56 | 57 | 58 | hvm 59 | /var/lib/libvirt/images/rhel63-tbox1-kernel 60 | /var/lib/libvirt/images/rhel63-tbox1-ramdisk 61 | method=http://download.foo.bar.redhat.com/pub/rhel/released/RHEL-6/6.3/Server/x86_64/os/ ks=file:/ks.cfg 62 | 63 | destroy 64 | destroy 65 | destroy 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1200/1200 90 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1190/1200 91 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1180/1200 92 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1170/1200 93 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1160/1200 94 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1150/1200 95 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1140/1200 96 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1130/1200 97 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1120/1200 98 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1110/1200 99 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1100/1200 100 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1090/1200 101 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1080/1200 102 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1070/1200 103 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1060/1200 104 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1050/1200 105 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1040/1200 106 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1030/1200 107 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1020/1200 108 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1010/1200 109 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 1000/1200 110 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 990/1200 111 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 980/1200 112 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 970/1200 113 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 960/1200 114 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 950/1200 115 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 940/1200 116 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 930/1200 117 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 920/1200 118 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 910/1200 119 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 900/1200 120 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 890/1200 121 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 880/1200 122 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to finish installing, 870/1200 123 | DEBUG:oz.Guest.RHEL6Guest:Waiting for rhel63-tbox1 to complete shutdown, 10/10 124 | INFO:oz.Guest.RHEL6Guest:Install of rhel63-tbox1 succeeded 125 | INFO:oz.Guest.RHEL6Guest:Generate XML for guest rhel63-tbox1 with bootdev hd 126 | DEBUG:oz.Guest.RHEL6Guest:Generated XML: 127 | 128 | 129 | rhel63-tbox1 130 | 1048576 131 | 1048576 132 | 45510fd5-3c10-47a4-a5a7-98545900688e 133 | 134 | 1 135 | 136 | 137 | 138 | 139 | 140 | 141 | hvm 142 | 143 | 144 | destroy 145 | destroy 146 | destroy 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | INFO:oz.Guest.RHEL6Guest:Cleaning up after install 171 | Libvirt XML was written to rhel63-tbox1Feb_15_2013-15:29:50 172 | --------------------------------------------------------------------------------