Add virtualbox driver method for obtaining vm information

This commit is contained in:
Brian Cain 2019-12-10 11:05:22 -08:00
parent 9bf41d34ba
commit 16cccd504a
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
2 changed files with 21 additions and 3 deletions

View File

@ -8,6 +8,7 @@ module VagrantPlugins
# @param [VagrantPlugins::Kernel_V2::VagrantConfigDisk] defined_disks
def self.configure_disks(machine, defined_disks)
return nil if defined_disks.empty?
disks = current_vm_disks(machine)
end
protected
@ -15,13 +16,15 @@ module VagrantPlugins
# Maybe move these into the virtualbox driver??
# Versioning might be an issue :shrug:
def current_vm_disks(driver)
def self.current_vm_disks(machine)
disks = {}
info = machine.provider.driver.show_vm_info(machine.id)
end
def vmdk_to_vdi(driver)
def self.vmdk_to_vdi(driver)
end
def vdi_to_vmdk(driver)
def self.vdi_to_vmdk(driver)
end
end
end

View File

@ -368,6 +368,21 @@ module VagrantPlugins
def vm_exists?(uuid)
end
# Returns a hash of information about a given virtual machine
#
# @param [String] uuid
# @return [Hash] info
def show_vm_info(uuid)
info = {}
execute('showvminfo', uuid, '--machinereadable', retryable: true).split("\n").each do |line|
parts = line.partition('=')
key = parts.first.gsub('"', '')
value = parts.last.gsub('"', '')
info[key] = value
end
info
end
# Execute the given subcommand for VBoxManage and return the output.
def execute(*command, &block)
# Get the options hash if it exists