Get/set machine id

This commit is contained in:
sophia 2021-07-06 16:19:17 -05:00 committed by Paul Hinze
parent fc8fe0a106
commit 5ecb1cdc26
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
3 changed files with 5 additions and 3 deletions

View File

@ -13,10 +13,11 @@ func (m *Machine) Close() (err error) {
}
func (m *Machine) ID() (id string, err error) {
return "machine-id-value", nil
return m.target.Uuid, nil
}
func (m *Machine) SetID(value string) (err error) {
m.target.Uuid = value
return
}

View File

@ -38,6 +38,7 @@ module VagrantPlugins
def get_id
req = Google::Protobuf::Empty.new
result = @client.get_id(req).id
@logger.debug("Got remote machine id: #{result}")
if result.nil?
raise "Failed to get machine ID. REF: #{ref.inspect} - ID WAS NIL"
end
@ -45,7 +46,7 @@ module VagrantPlugins
end
def set_id(new_id)
req = SDK::Target::SetIDRequest.new(
req = SDK::Target::Machine::SetIDRequest.new(
id: new_id
)
@client.set_id(req)

View File

@ -55,7 +55,7 @@ module VagrantPlugins
begin
@logger.debug("Instantiating the driver for machine ID: #{@machine.id.inspect}")
@driver = Driver::Meta.new(id)
@driver = Driver::Meta.new(uuid=id)
rescue Driver::Meta::VMNotFound
# The virtual machine doesn't exist, so we probably have a stale
# ID. Just clear the id out of the machine and reload it.