From 00b39de0f88b8369243e745b73e7513edfb8844a Mon Sep 17 00:00:00 2001 From: Leo Simons Date: Fri, 25 Jul 2014 14:49:45 +0200 Subject: [PATCH] CLOUDSTACK-7143: more reliable support for vagrant box export Veewee supports exporting vagrant boxes out of virtualbox, out of the box. However, it assumes that it can export a disk if the shutdown of the vm that is using that disk has succeeded. This assumption is not strictly always true (see previous commit). So, we replicate the bit of logic in veewee for making vagrant boxes. This has the added side benefit of creating an .ovf export only once, rather than once for vmware and then again for vagrant. --- tools/appliance/build.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tools/appliance/build.sh b/tools/appliance/build.sh index 736768af392..2cefd793c78 100755 --- a/tools/appliance/build.sh +++ b/tools/appliance/build.sh @@ -146,6 +146,9 @@ fi appliance_build_name=${appliance}${branch_tag}${version_tag} +# mac address of the vm we create +mac_address= + ### ### Generic helper functions ### @@ -308,6 +311,14 @@ function veewee_halt() { bundle exec veewee vbox halt "${appliance_build_name}" ${VEEWEE_ARGS} } +function save_mac_address() { + log INFO "saving new vm mac address" + mac_address=`vboxmanage showvminfo --details --machinereadable ${appliance_build_name} | grep macaddress1= | sed 's/macaddress1=//' | sed 's/"//g'` + if [ "${mac_address}" == "" ]; then + error "Could not find mac address for appliance ${appliance_build_name}" + fi +} + function check_appliance_shutdown() { log INFO "waiting for veewee appliance to shut down..." ! (vboxmanage list runningvms | grep "${appliance_build_name}") @@ -446,6 +457,32 @@ function vmware_export() { log INFO "${appliance} exported for VMWare: dist/${appliance_build_name}-vmware.ova" } +function vagrant_export() { + log INFO "creating vagrant export" + # this is based on veewee export logic, but, we don't want to use veewee export, + # since it makes optimistic assumptions about VM shutdown/halt leading to available + # disks and the like + disk="${appliance_build_name}-vmware.ovf" + mkdir -p "box/${appliance_build_name}" + cp "${disk}" "box/${appliance_build_name}/box.ovf" + cat >box/${appliance_build_name}/Vagrantfile <