Class: Beaker::VagrantLibvirt

Inherits:
Vagrant
  • Object
show all
Defined in:
lib/beaker/hypervisor/vagrant_libvirt.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Vagrant

#cleanup, #configure, #connection_preference, cpus, #make_vfile, memsize, #private_network_generator, #rand_chunk, #randip, #set_all_ssh_config, #set_ssh_config, #shell_provisioner_generator, #vagrant_cmd

Constructor Details

#initializeVagrantLibvirt

Returns a new instance of VagrantLibvirt.



4
5
6
7
8
9
10
11
12
# File 'lib/beaker/hypervisor/vagrant_libvirt.rb', line 4

def initialize(*)
  super

  # This needs to be unique for every system with the same hostname but does
  # not affect VirtualBox
  vagrant_path_digest = Digest::SHA256.hexdigest(@vagrant_path)
  @vagrant_path += '_' + vagrant_path_digest[0..2] + vagrant_path_digest[-3..-1]
  @vagrant_file = File.expand_path(File.join(@vagrant_path, 'Vagrantfile'))
end

Class Method Details

.build_options(options) ⇒ Object



27
28
29
30
31
# File 'lib/beaker/hypervisor/vagrant_libvirt.rb', line 27

def self.build_options(options)
  return [] unless options['libvirt']

  options['libvirt'].map { |k, v| "      node.#{k} = '#{v}'" }
end

.provider_vfile_section(host, options) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/beaker/hypervisor/vagrant_libvirt.rb', line 18

def self.provider_vfile_section(host, options)
  "    v.vm.provider :libvirt do |node|\n" +
    "      node.cpus = #{cpus(host, options)}\n" +
    "      node.memory = #{memsize(host, options)}\n" +
    "      node.qemu_use_session = false\n" +
    build_options(options).join("\n") + "\n" +
    "    end\n"
end

Instance Method Details

#provision(provider = 'libvirt') ⇒ Object



14
15
16
# File 'lib/beaker/hypervisor/vagrant_libvirt.rb', line 14

def provision(provider = 'libvirt')
  super
end