testing
This commit is contained in:
parent
c84c1217ac
commit
fdcbadbd83
73
Vagrantfile
vendored
73
Vagrantfile
vendored
@ -11,59 +11,92 @@ end
|
|||||||
|
|
||||||
# Can't use `||` here because `false || true` evaluates to true
|
# Can't use `||` here because `false || true` evaluates to true
|
||||||
VAGRANT_PROV = settings.key?('VAGRANT_PROV') ? settings['VAGRANT_PROV'] : true
|
VAGRANT_PROV = settings.key?('VAGRANT_PROV') ? settings['VAGRANT_PROV'] : true
|
||||||
|
VAGRANT_NODES = settings['VAGRANT_NODES'] || 1
|
||||||
VAGRANT_NAME = settings['VAGRANT_NAME'] || 'zfstest'
|
VAGRANT_NAME = settings['VAGRANT_NAME'] || 'zfstest'
|
||||||
VAGRANT_BOX = settings['VAGRANT_BOX'] || 'debian/bookworm64'
|
VAGRANT_BOX = settings['VAGRANT_BOX'] || 'debian/bookworm64'
|
||||||
VAGRANT_CPUS = settings['VAGRANT_CPUS'] || 4
|
VAGRANT_CPUS = settings['VAGRANT_CPUS'] || 4
|
||||||
VAGRANT_MEM = settings['VAGRANT_MEM'] || 4096
|
VAGRANT_MEM = settings['VAGRANT_MEM'] || 4096
|
||||||
VAGRANT_SH = settings['VAGRANT_SH'] || ''
|
VAGRANT_SH = settings['VAGRANT_SH'] || ''
|
||||||
NUM_DISKS = settings['NUM_DISKS'] || 16
|
NUM_DISKS = settings['NUM_DISKS'] || 16
|
||||||
# 18 TB decimal/SI to binary/IEC conversion:
|
# 18 TB decimal/SI to binary/IEC conversion
|
||||||
# 18 TB x (1000^4 / 1024^4) = 16.37 TiB
|
# 18 TB x (1000^4 / 1024^4) = 16.37 TiB
|
||||||
# 16.37 TiB x 1024 = ~16763 GiB
|
# 16.37 TiB x 1024 = ~16763 GiB
|
||||||
DISK_SIZE = settings['DISK_SIZE'] || '16763G'
|
DISK_SIZE = settings['DISK_SIZE'] || '16763G'
|
||||||
|
|
||||||
|
NODES = settings['NODES'] || {}
|
||||||
|
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
config.vm.box = VAGRANT_BOX
|
config.vm.box = VAGRANT_BOX
|
||||||
config.vm.hostname = VAGRANT_NAME
|
|
||||||
config.vm.synced_folder ".", "/vagrant", type: "rsync",
|
config.vm.synced_folder ".", "/vagrant", type: "rsync",
|
||||||
rsync__exclude: ".git"
|
rsync__exclude: ".git"
|
||||||
|
|
||||||
config.vm.provider :libvirt do |libvirt|
|
HOSTS = Array(1..VAGRANT_NODES)
|
||||||
libvirt.cpus = VAGRANT_CPUS
|
HOSTS.each do |count|
|
||||||
libvirt.memory = VAGRANT_MEM
|
DEFAULT_NODE_NAME = "#{VAGRANT_NAME}#{count}"
|
||||||
|
NODE_NAME = NODES.dig(DEFAULT_NODE_NAME, 'NAME') || DEFAULT_NODE_NAME
|
||||||
|
|
||||||
|
config.vm.define NODE_NAME do |node_config|
|
||||||
|
node_config.vm.hostname = NODE_NAME
|
||||||
|
node_config.vm.box = NODES.dig(DEFAULT_NODE_NAME, 'BOX') || VAGRANT_BOX
|
||||||
|
|
||||||
|
node_config.vm.provider :libvirt do |libvirt|
|
||||||
|
libvirt.cpus = NODES.dig(DEFAULT_NODE_NAME, 'CPUS') || VAGRANT_CPUS
|
||||||
|
libvirt.memory = NODES.dig(DEFAULT_NODE_NAME, 'MEM') || VAGRANT_MEM
|
||||||
# Doesn't boot without this on rockylinux/9
|
# Doesn't boot without this on rockylinux/9
|
||||||
libvirt.machine_virtual_size = 10
|
libvirt.machine_virtual_size = 10
|
||||||
|
|
||||||
(1..NUM_DISKS).each do |i|
|
NODE_DISKS = NODES.dig(DEFAULT_NODE_NAME, 'DISKS') || {}
|
||||||
|
NODE_NUM_DISKS = NODE_DISKS['NUM'] || NUM_DISKS
|
||||||
|
NODE_DISK_SIZE = NODE_DISKS['SIZE'] || DISK_SIZE
|
||||||
|
|
||||||
|
if !NODE_DISKS.key?('VAGRANT_DISKS') || NODE_DISKS['VAGRANT_DISKS']
|
||||||
|
(1..NODE_NUM_DISKS).each do |i|
|
||||||
if i <= 676
|
if i <= 676
|
||||||
first_char = (97 + ((i - 1) / 26)).chr
|
FIRST_CHAR = (97 + ((i - 1) / 26)).chr
|
||||||
second_char = (97 + ((i - 1) % 26)).chr
|
SECOND_CHAR = (97 + ((i - 1) % 26)).chr
|
||||||
device_suffix = first_char + second_char
|
DEVICE_SUFFIX = FIRST_CHAR + SECOND_CHAR
|
||||||
else
|
else
|
||||||
raise "Error: Exceeded number of supported disks (#{NUM_DISKS}/676))"
|
raise "Error: Exceeded number of supported disks (#{NODE_NUM_DISKS}/676))"
|
||||||
end
|
end
|
||||||
|
|
||||||
libvirt.storage :file, \
|
libvirt.storage :file, \
|
||||||
:size => "#{DISK_SIZE}", \
|
:size => "#{NODE_DISK_SIZE}", \
|
||||||
:type => 'qcow2', \
|
:type => 'qcow2', \
|
||||||
:sparse => true, \
|
:sparse => true, \
|
||||||
:device => "vdz#{device_suffix}", \
|
:device => "vdz#{DEVICE_SUFFIX}", \
|
||||||
:serial => "VDZ#{device_suffix.upcase}"
|
:serial => "VDZ#{DEVICE_SUFFIX.upcase}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if VAGRANT_PROV
|
if NODE_DISKS.key?('CUSTOM')
|
||||||
config.vm.provision "shell", path: "provision.sh"
|
CUSTOM_DISKS = NODE_DISKS['CUSTOM']
|
||||||
|
CUSTOM_DISKS.each do |disk|
|
||||||
|
libvirt.storage :file, \
|
||||||
|
:size => disk['SIZE'] || NODE_DISK_SIZE, \
|
||||||
|
:type => disk['TYPE'] || 'qcow2', \
|
||||||
|
:sparse => disk.key?('SPARSE') ? disk['SPARSE'] : true, \
|
||||||
|
:device => disk['DEVICE'], \
|
||||||
|
:serial => disk['SERIAL'] || disk['DEVICE'].upcase
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if VAGRANT_SH != ''
|
NODE_PROV = NODES.dig(DEFAULT_NODE_NAME, 'PROV')
|
||||||
config.vm.provision "shell", inline: <<-SHELL
|
if NODE_PROV.nil? ? VAGRANT_PROV : NODE_PROV
|
||||||
if [ -f /vagrant/scratch/#{VAGRANT_SH} ]; then
|
node_config.vm.provision "shell", path: "provision.sh"
|
||||||
/bin/bash /vagrant/scratch/#{VAGRANT_SH}
|
end
|
||||||
|
|
||||||
|
NODE_SH = NODES.dig(DEFAULT_NODE_NAME, 'SH') || VAGRANT_SH
|
||||||
|
if NODE_SH != ''
|
||||||
|
node_config.vm.provision "shell", inline: <<-SHELL
|
||||||
|
if [ -f /vagrant/scratch/#{NODE_SH} ]; then
|
||||||
|
/bin/bash /vagrant/scratch/#{NODE_SH}
|
||||||
else
|
else
|
||||||
echo "ERROR: /vagrant/scratch/#{VAGRANT_SH} not found"
|
echo "ERROR: /vagrant/scratch/#{NODE_SH} not found"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
SHELL
|
SHELL
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user