mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Having experimented with many edge cases of running multiple build.sh commands in parallel / against busy virtualbox setups, the only really reliable way to produce consistent images is to not do these commands in parallel and to not do them while the machine is doing many other things. If virtualbox or the machine that hosts it is very busy, and/or it has a lot of disks it knows/knew about, and/or its tuesday, behavior may be a bit different. Realizing this reality, this commit adds some scripts that try really hard to set virtualbox back to known/healthy state before building.
34 lines
953 B
Ruby
Executable File
34 lines
953 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
|
|
lines = `VBoxManage list hdds`
|
|
disks = lines.split(/\n\s*\n/)
|
|
disks.each do |disk|
|
|
disk_lines = disk.split(/\n/)
|
|
disk_config = {}
|
|
disk_lines.each do |line|
|
|
pair = line.split(/:\s*/)
|
|
disk_config[pair[0]] = pair[1]
|
|
# if pair[0] == 'Location'
|
|
# location = pair[1]
|
|
|
|
# if location.include? '/Snapshots/'
|
|
# disk_config['is_snapshot'] = true
|
|
# end
|
|
# if location.include? '/VirtualBox VMs/'
|
|
# disk_config['vm_name'] = location.split('/VirtualBox VMs/')[1].split('/')[0]
|
|
# disk_config['disk_name'] = location.split('/')[-1]
|
|
# disk_config['is_virtualbox_vm'] = true
|
|
# else
|
|
# disk_config['is_virtualbox_vm'] = false
|
|
# disk_config['disk_name'] = location.split('/')[-1]
|
|
# end
|
|
# end
|
|
end
|
|
|
|
if disk_config.include? 'Location'
|
|
cmd="VBoxManage closemedium disk '#{disk_config['Location']}' --delete"
|
|
puts cmd
|
|
`#{cmd}`
|
|
end
|
|
end
|