add Virtualbox vagrantfile, reintroduce convertOptions

This commit is contained in:
Neil Hanlon 2022-11-19 19:08:05 -05:00
parent b9e8f486c1
commit 98797d1b6c
Signed by untrusted user: neil
GPG Key ID: 705BC21EC3C70F34
2 changed files with 34 additions and 3 deletions

View File

@ -146,16 +146,19 @@ class ImageBuild:
]
if self.image_type in ["Vagrant"]:
_map = {
"Vbox": {"format": "vmdk", "provider": "virtualbox"},
"Vbox": {"format": "vmdk", "provider": "virtualbox", "convertOptions": ["-o", "subformat=streamOptimized"]},
"Libvirt": {"format": "qcow2", "provider": "libvirt", "virtual_size": 10},
"VMware": {"format": "vmdk", "provider": "vmware_desktop"}
}
output = f"{_map[self.variant]['format']}" #type: ignore
options = _map[self.variant]['convertOptions'] if 'convertOptions' in _map[self.variant].keys() else '' #type: ignore
provider = f"{_map[self.variant]['provider']}" # type: ignore
# pop from the options map that will be passed to the vagrant metadata.json
convert_options = _map[self.variant].pop('convertOptions') if 'convertOptions' in _map[self.variant].keys() else '' #type: ignore
self.stage_commands = [
["qemu-img", "convert", "-c", "-f", "raw", "-O", output, *options, lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", f"{self.outdir}/{self.outname}.{output}"],
["qemu-img", "convert", "-c", "-f", "raw", "-O", output, *convert_options, lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", f"{self.outdir}/{self.outname}.{output}"],
["tar", "-C", self.outdir, "-czf", f"/tmp/{self.outname}.box", '.'],
["mv", f"/tmp/{self.outname}.box", self.outdir]
]

View File

@ -0,0 +1,28 @@
# frozen_string_literal: true
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# Example configuration of new VM..
#
#config.vm.define :test_vm do |test_vm|
# Box name
#
#test_vm.vm.box = "rockylinux"
# Domain Specific Options
#
# See README for more info.
# Interfaces for VM
#
# Networking features in the form of `config.vm.network`
#
#test_vm.vm.network :private_network, :ip => '10.20.30.40'
#test_vm.vm.network :public_network, :ip => '10.20.30.41'
#end
config.vm.base_mac = "080027FCE996"
end