Darryl L. Pierce
2008-Dec-01 21:40 UTC
[Ovirt-devel] [PATCH appliance] Allows create-ovirt-appliance to overwrite an existing appliance.
Adds the argument "-u" which tells the script to undefine an existing appliance with the same name as the appliance to be created. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- create-ovirt-appliance | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/create-ovirt-appliance b/create-ovirt-appliance index 1a1529f..938c766 100755 --- a/create-ovirt-appliance +++ b/create-ovirt-appliance @@ -27,18 +27,20 @@ Usage: $ME [-d image_dir] [-n name] [-c] [-f raw|qcow2] -n: appliance name (default: $NAME_DEFAULT) -c: open console when appliance is started -f: disk image format for appliance (default: $DISK_FMT_DEFAULT) + -u: undefine any existing appliance with same name -h: display this help and exit EOF } err=0 help=0 console=0 -while getopts :d:n:cf:h c; do +while getopts :d:n:cf:uh c; do case $c in d) imgdir=$OPTARG;; n) name=$OPTARG;; c) console=1;; f) DISK_FMT=$OPTARG;; + u) undefine_vm=1;; h) help=1;; '?') err=1; warn "invalid option: \`-$OPTARG'";; :) err=1; warn "missing argument to \`-$OPTARG' option";; @@ -50,6 +52,13 @@ test $help = 1 && { usage; exit 0; } do_checks +if [ -n "$undefine_vm" ]; then + # destroy the existing virtual machine that has the same name as the + # appliance to be created + echo "Undefine existing application named $name..." + virsh undefine $name > /dev/null 2>&1& +fi + if virsh dumpxml $name > /dev/null 2>&1 ; then # If the appliance is already defined, abort since rewriting the appliance # will change network settings that break the appliance. -- 1.6.0.4
Perry Myers
2008-Dec-01 21:49 UTC
[Ovirt-devel] [PATCH appliance] Allows create-ovirt-appliance to overwrite an existing appliance.
Darryl L. Pierce wrote:> Adds the argument "-u" which tells the script to undefine an existing > appliance with the same name as the appliance to be created.This will create problems... If you run create-ovirt-appliance with -u it will re-create the appliance but if you have not updated the disk image your network on the appliance will be possibly messed up. Hence the reason why I say in the following check:> # If the appliance is already defined, abort since rewriting the appliance > # will change network settings that break the appliance.So the proper way to re-create the appliance image is to first run get-ovirt-appliance which copies a pristine disk image into the images directory, followed by create-ovirt-appliance. get-ovirt-appliance undefines the old appliance, making the -u option unnecessary for create-ovirt-appliance Perry> Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> > --- > create-ovirt-appliance | 11 ++++++++++- > 1 files changed, 10 insertions(+), 1 deletions(-) > > diff --git a/create-ovirt-appliance b/create-ovirt-appliance > index 1a1529f..938c766 100755 > --- a/create-ovirt-appliance > +++ b/create-ovirt-appliance > @@ -27,18 +27,20 @@ Usage: $ME [-d image_dir] [-n name] [-c] [-f raw|qcow2] > -n: appliance name (default: $NAME_DEFAULT) > -c: open console when appliance is started > -f: disk image format for appliance (default: $DISK_FMT_DEFAULT) > + -u: undefine any existing appliance with same name > -h: display this help and exit > EOF > } > > err=0 help=0 > console=0 > -while getopts :d:n:cf:h c; do > +while getopts :d:n:cf:uh c; do > case $c in > d) imgdir=$OPTARG;; > n) name=$OPTARG;; > c) console=1;; > f) DISK_FMT=$OPTARG;; > + u) undefine_vm=1;; > h) help=1;; > '?') err=1; warn "invalid option: \`-$OPTARG'";; > :) err=1; warn "missing argument to \`-$OPTARG' option";; > @@ -50,6 +52,13 @@ test $help = 1 && { usage; exit 0; } > > do_checks > > +if [ -n "$undefine_vm" ]; then > + # destroy the existing virtual machine that has the same name as the > + # appliance to be created > + echo "Undefine existing application named $name..." > + virsh undefine $name > /dev/null 2>&1& > +fi > + > if virsh dumpxml $name > /dev/null 2>&1 ; then > # If the appliance is already defined, abort since rewriting the appliance > # will change network settings that break the appliance.-- |=- Red Hat, Engineering, Emerging Technologies, Boston -=| |=- Email: pmyers at redhat.com -=| |=- Office: +1 412 474 3552 Mobile: +1 703 362 9622 -=| |=- GnuPG: E65E4F3D 88F9 F1C9 C2F3 1303 01FE 817C C5D2 8B91 E65E 4F3D -=|