Class: VagrantPlugins::ProviderVirtualBox::Driver::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-libcloud-helper/providers/virtualbox/driver/base.rb

Instance Method Summary collapse

Instance Method Details

#allocate_sata_ports(portcount) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/vagrant-libcloud-helper/providers/virtualbox/driver/base.rb', line 6

def allocate_sata_ports(portcount)
  controller = get_sata_controller_name
  if controller.nil?
    controller = "SATA Controller"
    @logger.info("Creating SATA controller '#{controller}' with #{portcount} ports")
    execute("storagectl", @uuid, "--name", controller, "--portcount", portcount.to_s,
            "--add", "sata", "--bootable", "off")
  else
    @logger.info("Allocating #{portcount} ports in  SATA controller '#{controller}'")
    execute("storagectl", @uuid, "--name", controller, "--portcount", portcount.to_s)
  end
end

#get_sata_controller_nameObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/vagrant-libcloud-helper/providers/virtualbox/driver/base.rb', line 19

def get_sata_controller_name
  controllers = Hash.new
  info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true)
  info.split("\n").each do |line|
    controllers[$1] = $2 if line =~ /^storagecontrollername(\d+)="(.*)"/
    sata_controller_number = $1 if line =~ /^storagecontrollertype(\d+)="IntelAhci"/
    return controllers[sata_controller_number] unless controllers[sata_controller_number].nil?
  end
  return nil
end