[Ovirt-devel] [PATCH appliance] Allows create-ovirt-appliance to overwrite an existing appliance.

Darryl L. Pierce dpierce at redhat.com
Mon Dec 1 21:40:30 UTC 2008


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




More information about the ovirt-devel mailing list