Class: Beaker::VagrantVirtualbox

Inherits:
Vagrant show all
Defined in:
lib/beaker/hypervisor/vagrant_virtualbox.rb

Constant Summary

Constants inherited from Hypervisor

Hypervisor::CHARMAP

Constants included from HostPrebuiltSteps

HostPrebuiltSteps::APT_CFG, HostPrebuiltSteps::CUMULUS_PACKAGES, HostPrebuiltSteps::DEBIAN_PACKAGES, HostPrebuiltSteps::ETC_HOSTS_PATH, HostPrebuiltSteps::ETC_HOSTS_PATH_SOLARIS, HostPrebuiltSteps::FREEBSD_PACKAGES, HostPrebuiltSteps::IPS_PKG_REPO, HostPrebuiltSteps::NTPSERVER, HostPrebuiltSteps::OPENBSD_PACKAGES, HostPrebuiltSteps::PSWINDOWS_PACKAGES, HostPrebuiltSteps::ROOT_KEYS_SCRIPT, HostPrebuiltSteps::ROOT_KEYS_SYNC_CMD, HostPrebuiltSteps::ROOT_KEYS_SYNC_CMD_AIX, HostPrebuiltSteps::SLEEPWAIT, HostPrebuiltSteps::SLES10_PACKAGES, HostPrebuiltSteps::SLES_PACKAGES, HostPrebuiltSteps::SOLARIS10_PACKAGES, HostPrebuiltSteps::TRIES, HostPrebuiltSteps::UNIX_PACKAGES, HostPrebuiltSteps::WINDOWS_PACKAGES

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Vagrant

#cleanup, #get_ip_from_vagrant_file, #initialize, #make_vfile, #rand_chunk, #randip, #randmac, #set_ssh_config, #vagrant_cmd

Methods inherited from Hypervisor

#cleanup, #configure, create, #generate_host_name, #initialize, #proxy_package_manager, #validate

Methods included from HostPrebuiltSteps

#add_el_extras, #additive_hash_merge, #apt_get_update, #check_and_install_packages_if_needed, #construct_env, #copy_file_to_remote, #copy_ssh_to_root, #disable_iptables, #disable_se_linux, #disable_updates, #enable_root_login, #epel_info_for, #get_domain_name, #get_ip, #hack_etc_hosts, #package_proxy, #proxy_config, #set_env, #set_etc_hosts, #sync_root_keys, #timesync, #validate_host

Methods included from DSL::Patterns

#block_on

Constructor Details

This class inherits a constructor from Beaker::Vagrant

Class Method Details

.provider_vfile_section(host, options) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/beaker/hypervisor/vagrant_virtualbox.rb', line 18

def self.provider_vfile_section(host, options)
  # Allow memory and CPUs to be set at a per node level or overall, and take the most specific setting
  host_memory = host['vagrant_memsize'] ? host['vagrant_memsize'] : (options['vagrant_memsize'] ? options['vagrant_memsize'] : 1024)
  host_cpus = host['vagrant_cpus'] ? host['vagrant_cpus'] : (options['vagrant_cpus'] ? options['vagrant_cpus'] : 1)

  provider_section  = ""
  provider_section << "    v.vm.provider :virtualbox do |vb|\n"
  provider_section << "      vb.customize ['modifyvm', :id, '--memory', '#{host_memory}', '--cpus', '#{host_cpus}']\n"
  provider_section << "      vb.vbguest.auto_update = false" if options[:vbguest_plugin] == 'disable'

  # Guest volume support
  # - Creates a new AHCI controller with the requisite number of ports,
  #   the default controller is limited in its number of supported ports (2).
  #   The AHCI emulation is generic enough for acceptance testing, and
  #   presents the devices as SCSI devices in /sys/class/scsi_disk.
  # - Creates the defined volumes in beaker's temporary folder and attaches
  #   them to the controller in order starting at port 0.  This presents disks
  #   as 2:0:0:0, 3:0:0:0 ... much like you'd see on commercial storage boxes
  if host['volumes']
    provider_section << self.vb_customize_vm('storagectl', [
      '--name', 'SATA Controller',
      '--add', 'sata',
      '--controller', 'IntelAHCI',
      '--portcount', host['volumes'].length
    ])
    host['volumes'].keys.each_with_index do |volume, index|
      volume_path = "#{host.name}-#{volume}.vdi"
      provider_section << self.vb_customize('createhd', [
        '--filename', volume_path,
        '--size', host['volumes'][volume]['size'],
      ])
      provider_section << self.vb_customize_vm('storageattach', [
        '--storagectl', 'SATA Controller',
        '--port', index,
        '--device', 0,
        '--type', 'hdd',
        '--medium', volume_path,
      ])
    end
  end

  provider_section << "      vb.customize [\"modifyvm\", :id, \"--natdnshostresolver1\", \"#{host['natdns']}\"]\n" unless host['natdns'].nil?

  provider_section << "      vb.customize [\"modifyvm\", :id, \"--natdnsproxy1\", \"#{host['natdns']}\"]\n" unless host['natdns'].nil?

  provider_section << "      vb.gui = true\n" unless host['vb_gui'].nil?

  provider_section << "      [\"modifyvm\", :id, \"--cpuidset\", \"1\",\"000206a7\",\"02100800\",\"1fbae3bf\",\"bfebfbff\"\]" if /osx/i.match(host['platform'])

  if host['disk_path']
    unless File.exist?(host['disk_path'])
      host['disk_path'] = File.join(host['disk_path'], "#{host.name}.vmdk")
      provider_section << "      vb.customize ['createhd', '--filename', '#{host['disk_path']}', '--size', #{host['disk_size'] ||= 5 * 1024}, '--format', 'vmdk']\n"
    end
    provider_section << "      vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium','#{host['disk_path']}']\n"
  end

  provider_section << "    end\n"

  provider_section
end

.vb_customize(command, args) ⇒ Object

Generate a VM customization string



9
10
11
# File 'lib/beaker/hypervisor/vagrant_virtualbox.rb', line 9

def self.vb_customize(command, args)
  "      vb.customize ['#{command}', #{args.map{|a| "'#{a.to_s}'"}.join(", ")}]\n"
end

.vb_customize_vm(command, args) ⇒ Object

Generate a VM customization string for the current VM



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

def self.vb_customize_vm(command, args)
  "      vb.customize ['#{command}', :id, #{args.map{|a| "'#{a.to_s}'"}.join(", ")}]\n"
end

Instance Method Details

#provision(provider = 'virtualbox') ⇒ Object



4
5
6
# File 'lib/beaker/hypervisor/vagrant_virtualbox.rb', line 4

def provision(provider = 'virtualbox')
  super
end