UQuery machine index by uuid
This commit is contained in:
parent
154a4e56f0
commit
c71eb9ea0e
@ -36,7 +36,6 @@ module Vagrant
|
||||
machine_index_client = @client.machine_index
|
||||
@machine_index ||= Vagrant::MachineIndex.new()
|
||||
@machine_index.client = machine_index_client
|
||||
@machine_index.project_ref = @client.ref
|
||||
end
|
||||
@machine_index
|
||||
end
|
||||
|
||||
@ -5,8 +5,6 @@ module Vagrant
|
||||
|
||||
attr_accessor :client
|
||||
|
||||
attr_accessor :project_ref
|
||||
|
||||
# Add an attribute reader for the client
|
||||
# when applied to the MachineIndex class
|
||||
def self.prepended(klass)
|
||||
@ -23,22 +21,23 @@ module Vagrant
|
||||
|
||||
# Deletes a machine by UUID.
|
||||
#
|
||||
# @param [Entry] entry The entry to delete.
|
||||
# @param [Stinrg] The uuid for the entry to delete.
|
||||
# @return [Boolean] true if delete is successful
|
||||
def delete(entry)
|
||||
@machines.delete(entry.id)
|
||||
machine = entry.machine_client.ref
|
||||
@client.delete(machine)
|
||||
def delete(uuid)
|
||||
@machines.delete(uuid)
|
||||
ref = Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier.new(
|
||||
id: uuid
|
||||
)
|
||||
@client.delete(ref)
|
||||
end
|
||||
|
||||
# Accesses a machine by UUID
|
||||
#
|
||||
# @param [String] name for the machine to access.
|
||||
# @param [String] uuid for the machine to access.
|
||||
# @return [MachineIndex::Entry]
|
||||
def get(name)
|
||||
ref = Hashicorp::Vagrant::Sdk::Ref::Target.new(
|
||||
name: name,
|
||||
project: @project_ref
|
||||
def get(uuid)
|
||||
ref = Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier.new(
|
||||
id: uuid
|
||||
)
|
||||
get_response = @client.get(ref)
|
||||
entry = machine_to_entry(get_response)
|
||||
@ -47,12 +46,11 @@ module Vagrant
|
||||
|
||||
# Tests if the index has the given UUID.
|
||||
#
|
||||
# @param [String] name
|
||||
# @param [String] uuid
|
||||
# @return [Boolean]
|
||||
def include?(name)
|
||||
ref = Hashicorp::Vagrant::Sdk::Ref::Target.new(
|
||||
name: name,
|
||||
project: @project_ref
|
||||
def include?(uuid)
|
||||
ref = Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier.new(
|
||||
id: uuid
|
||||
)
|
||||
@client.include?(ref)
|
||||
end
|
||||
|
||||
@ -698,6 +698,9 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.TargetIndex" do
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.TargetIndex.TargetIdentifier" do
|
||||
optional :id, :string, 1
|
||||
end
|
||||
add_message "hashicorp.vagrant.sdk.TargetIndex.AllResponse" do
|
||||
repeated :targets, :message, 1, "hashicorp.vagrant.sdk.Args.Target"
|
||||
end
|
||||
@ -872,6 +875,7 @@ module Hashicorp
|
||||
Vagrantfile::SyncedFolder = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Vagrantfile.SyncedFolder").msgclass
|
||||
Vagrantfile::Vagrantfile = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Vagrantfile.Vagrantfile").msgclass
|
||||
TargetIndex = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.TargetIndex").msgclass
|
||||
TargetIndex::TargetIdentifier = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.TargetIndex.TargetIdentifier").msgclass
|
||||
TargetIndex::AllResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.TargetIndex.AllResponse").msgclass
|
||||
TargetIndex::IncludesResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.TargetIndex.IncludesResponse").msgclass
|
||||
end
|
||||
|
||||
@ -453,9 +453,9 @@ module Hashicorp
|
||||
self.unmarshal_class_method = :decode
|
||||
self.service_name = 'hashicorp.vagrant.sdk.TargetIndexService'
|
||||
|
||||
rpc :Delete, ::Hashicorp::Vagrant::Sdk::Ref::Target, ::Google::Protobuf::Empty
|
||||
rpc :Get, ::Hashicorp::Vagrant::Sdk::Ref::Target, ::Hashicorp::Vagrant::Sdk::Args::Target
|
||||
rpc :Includes, ::Hashicorp::Vagrant::Sdk::Ref::Target, ::Hashicorp::Vagrant::Sdk::TargetIndex::IncludesResponse
|
||||
rpc :Delete, ::Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier, ::Google::Protobuf::Empty
|
||||
rpc :Get, ::Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier, ::Hashicorp::Vagrant::Sdk::Args::Target
|
||||
rpc :Includes, ::Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier, ::Hashicorp::Vagrant::Sdk::TargetIndex::IncludesResponse
|
||||
rpc :Set, ::Hashicorp::Vagrant::Sdk::Args::Target, ::Hashicorp::Vagrant::Sdk::Args::Target
|
||||
rpc :All, ::Google::Protobuf::Empty, ::Hashicorp::Vagrant::Sdk::TargetIndex::AllResponse
|
||||
end
|
||||
|
||||
@ -20,7 +20,7 @@ module VagrantPlugins
|
||||
@broker = broker
|
||||
end
|
||||
|
||||
# @param [Hashicorp::Vagrant::Sdk::Args::Target]
|
||||
# @param [Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier]
|
||||
# @return [Boolean] true if delete is successful
|
||||
def delete(target)
|
||||
@logger.debug("deleting machine #{target} from index")
|
||||
@ -28,7 +28,7 @@ module VagrantPlugins
|
||||
true
|
||||
end
|
||||
|
||||
# @param [Hashicorp::Vagrant::Sdk::Ref::Target] a ref for the machine to access.
|
||||
# @param [Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier]
|
||||
# @return [Hashicorp::Vagrant::Sdk::Ref::Target]
|
||||
def get(ref)
|
||||
@logger.debug("getting machine with ref #{ref} from index")
|
||||
@ -36,7 +36,7 @@ module VagrantPlugins
|
||||
return resp
|
||||
end
|
||||
|
||||
# @param [Hashicorp::Vagrant::Sdk::Ref::Target]
|
||||
# @param [Hashicorp::Vagrant::Sdk::TargetIndex::TargetIdentifier]
|
||||
# @return [Boolean]
|
||||
def include?(ref)
|
||||
@logger.debug("checking for machine with ref #{ref} in index")
|
||||
|
||||
@ -17,11 +17,6 @@ module VagrantPlugins
|
||||
self.new(conn.to_s, broker)
|
||||
end
|
||||
|
||||
def ref
|
||||
req = Google::Protobuf::Empty.new
|
||||
@client.ref(req)
|
||||
end
|
||||
|
||||
# Returns a machine client for the given name
|
||||
# return [VagrantPlugins::CommandServe::Client::Machine]
|
||||
def target(name)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user