CLOUDSTACK-7143: work on vagrant box export

Running --export creates the .ovf and the .vmdk files referenced
from that .ovf in one go. Guessing/predicting the names of the .vmdk
files is not fool-proof.
This commit is contained in:
Leo Simons 2014-07-29 10:12:00 +02:00 committed by Rohit Yadav
parent cab4dd8258
commit d56e950e85

View File

@ -459,20 +459,24 @@ function vmware_export() {
function vagrant_export() { function vagrant_export() {
log INFO "creating vagrant export" log INFO "creating vagrant export"
local machine_uuid="${1}"
# this is based on veewee export logic, but, we don't want to use veewee 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 # since it makes optimistic assumptions about VM shutdown/halt leading to available
# disks and the like # disks and the like
disk="${appliance_build_name}-vmware.ovf" # predicting VBoxManage disk naming seems problematic
image="${appliance_build_name}-vmware-disk1.vmdk" # disk="${appliance_build_name}-vmware.ovf"
# image="${appliance_build_name}-vmware-disk1.vmdk"
mkdir -p "box/${appliance_build_name}" mkdir -p "box/${appliance_build_name}"
cp "${disk}" "box/${appliance_build_name}/box.ovf" # cp "${disk}" "box/${appliance_build_name}/box.ovf"
cp "${image}" "box/${appliance_build_name}/box-disk1.vmdk" # cp "${image}" "box/${appliance_build_name}/box-disk1.vmdk"
cat >box/${appliance_build_name}/Vagrantfile <<END cat >box/${appliance_build_name}/Vagrantfile <<END
Vagrant::Config.run do |config| Vagrant::Config.run do |config|
# This Vagrantfile is auto-generated by vagrant package to contain # This Vagrantfile is auto-generated by vagrant package to contain
# the MAC address of the box. Custom configuration should be placed in # the MAC address of the box. Custom configuration should be placed in
# the actual Vagrantfile in this box. # the actual Vagrantfile in this box.
config.vm.base_mac = "${mac_address}" config.vm.base_mac = "${mac_address}"
# This is not enough config to be able to use the systemvm .box
# See ../vagrant/systemvm/Vagrantfile for the trickery needed
end end
# Load include vagrant file if it exists after the auto-generated # Load include vagrant file if it exists after the auto-generated
@ -480,6 +484,7 @@ end
include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__) include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)
load include_vagrantfile if File.exist?(include_vagrantfile) load include_vagrantfile if File.exist?(include_vagrantfile)
END END
vboxmanage export "${machine_uuid}" --output "box/${appliance_build_name}/box.ovf"
( cd box/${appliance_build_name}; tar cf "../${appliance_build_name}.box" . ) ( cd box/${appliance_build_name}; tar cf "../${appliance_build_name}.box" . )
mv "box/${appliance_build_name}.box" dist/ mv "box/${appliance_build_name}.box" dist/
log INFO "${appliance} exported for vagrant: dist/${appliance_build_name}.box" log INFO "${appliance} exported for vagrant: dist/${appliance_build_name}.box"
@ -530,7 +535,7 @@ function main() {
xen_server_export "${hdd_path}" xen_server_export "${hdd_path}"
kvm_export "${hdd_path}" kvm_export "${hdd_path}"
vmware_export "${machine_uuid}" "${hdd_uuid}" vmware_export "${machine_uuid}" "${hdd_uuid}"
vagrant_export "${machine_uuid}" "${hdd_uuid}" vagrant_export "${machine_uuid}"
hyperv_export "${hdd_uuid}" hyperv_export "${hdd_uuid}"
add_on_exit log INFO "BUILD SUCCESSFUL" add_on_exit log INFO "BUILD SUCCESSFUL"
} }