Method: VirtualBox::Vm#pull_config
- Defined in:
- lib/virtual_box/vm.rb
#pull_config ⇒ VirtualBox::Vm
Updates this VM’s configuration to reflect the VirtualBox configuration.
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/virtual_box/vm.rb', line 254 def pull_config output = VirtualBox.run_command! ['VBoxManage', '--nologo', 'showvminfo', '--machinereadable', uid] config = self.class.parse_machine_readable output self.name = config['name'] self.uid = config['UUID'] board.from_params config nic_count = config.keys.select { |key| /^nic\d+$/ =~ key }.max[3..-1].to_i 1.upto nic_count do |index| if config["nic#{index}"] == 'none' nics[index - 1] = nil else nics[index - 1] ||= VirtualBox::Vm::Nic.new nics[index - 1].from_params config, index end end bus_count = 1 + (config.keys.select { |key| /^storagecontrollername\d+$/ =~ key }.max || "storagecontrollername-1")[21..-1].to_i 0.upto bus_count - 1 do |index| io_buses[index] ||= VirtualBox::Vm::IoBus.new io_buses[index].from_params config, index end self end |