add Virtualbox vagrantfile, reintroduce convertOptions
This commit is contained in:
parent
b9e8f486c1
commit
98797d1b6c
@ -146,16 +146,19 @@ class ImageBuild:
|
|||||||
]
|
]
|
||||||
if self.image_type in ["Vagrant"]:
|
if self.image_type in ["Vagrant"]:
|
||||||
_map = {
|
_map = {
|
||||||
"Vbox": {"format": "vmdk", "provider": "virtualbox"},
|
"Vbox": {"format": "vmdk", "provider": "virtualbox", "convertOptions": ["-o", "subformat=streamOptimized"]},
|
||||||
"Libvirt": {"format": "qcow2", "provider": "libvirt", "virtual_size": 10},
|
"Libvirt": {"format": "qcow2", "provider": "libvirt", "virtual_size": 10},
|
||||||
"VMware": {"format": "vmdk", "provider": "vmware_desktop"}
|
"VMware": {"format": "vmdk", "provider": "vmware_desktop"}
|
||||||
}
|
}
|
||||||
output = f"{_map[self.variant]['format']}" #type: ignore
|
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
|
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 = [
|
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", '.'],
|
["tar", "-C", self.outdir, "-czf", f"/tmp/{self.outname}.box", '.'],
|
||||||
["mv", f"/tmp/{self.outname}.box", self.outdir]
|
["mv", f"/tmp/{self.outname}.box", self.outdir]
|
||||||
]
|
]
|
||||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user