Get machine index remote service setup

This commit is contained in:
sophia 2021-08-02 16:11:24 -05:00 committed by Paul Hinze
parent c123335456
commit 7de0fe1bd8
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
5 changed files with 56 additions and 8 deletions

View File

@ -11,13 +11,13 @@ module Vagrant
end
def initialize(opts={})
@client = opts[:client]
super
@client = opts[:client]
if @client.nil?
raise ArgumentError,
"Remote client is required for `#{self.class.name}'"
end
@logger = Log4r::Logger.new("vagrant::environment")
end
# Gets a target (machine) by name
@ -34,7 +34,8 @@ module Vagrant
def machine_index
if !@client.nil?
machine_index_client = @client.machine_index
@machine_index ||= Vagrant::MachineIndex.new(client: machine_index_client)
@machine_index ||= Vagrant::MachineIndex.new()
@machine_index.set_client(machine_index_client)
end
@machine_index
end

View File

@ -12,10 +12,57 @@ module Vagrant
end
# Initializes a MachineIndex
def initialize(*args, **kwargs)
def initialize(*args)
@logger = Log4r::Logger.new("vagrant::machine_index")
@machines = {}
@machine_locks = {}
@client = kwargs.key("client")
end
def set_client(client)
@logger.debug("setting machine index client")
@client = client
end
# Deletes a machine by UUID.
#
# The machine being deleted with this UUID must either be locked
# by this index or must be unlocked.
#
# @param [Entry] entry The entry to delete.
# @return [Boolean] true if delete is successful
def delete(entry)
end
def get(uuid)
end
def include?(uuid)
end
def release(entry)
#no-op
end
def set(entry)
end
def recover(entry)
#TODO
end
protected
# Converts a machine index entry to a machine
#
# @param [Vagrant::MachineIndex::Entry]
# @return [Hashicorp::Vagrant::Sdk::Args::Target]
def entry_to_machine(entry)
end
# Converts a machine to a machine index entry
#
# @param [Hashicorp::Vagrant::Sdk::Args::Target]
# @return [Vagrant::MachineIndex::Entry]
def machine_to_entry(machine)
end
end
end

View File

@ -243,5 +243,6 @@ module Vagrant
SERVER_MODE_CALLBACKS = [
->{ Vagrant::Machine.prepend(Vagrant::Machine::Remote) },
->{ Vagrant::Environment.prepend(Vagrant::Environment::Remote) },
->{ Vagrant::MachineIndex.prepend(Vagrant::MachineIndex::Remote) },
].freeze
end

View File

@ -11,7 +11,7 @@ module VagrantPlugins
end
def initialize(conn)
@logger = Log4r::Logger.new("vagrant::command::serve::client::machine")
@logger = Log4r::Logger.new("vagrant::command::serve::client::machineindex")
@logger.debug("connecting to target index service on #{conn}")
if !conn.nil?
@client = SDK::TargetIndexService::Stub.new(conn, :this_channel_is_insecure)

View File

@ -7,7 +7,7 @@ module VagrantPlugins
prepend Util::HasBroker
prepend Util::ExceptionLogger
LOG = Log4r::Logger.new("vagrant::command::serve::command")
LOGGER = Log4r::Logger.new("vagrant::command::serve::command")
def command_info_spec(*args)
SDK::FuncSpec.new
@ -81,7 +81,6 @@ module VagrantPlugins
cmd = cmd_klass.new(cmd_args, env)
result = cmd.execute
LOGGER.debug(result)
if !result.is_a?(Integer)
result = 1
end