Make status work

This commit is contained in:
sophia 2021-07-06 14:52:55 -05:00 committed by Paul Hinze
parent 340c2d7b19
commit fc8fe0a106
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
4 changed files with 30 additions and 14 deletions

View File

@ -22,8 +22,14 @@ module Vagrant
# backed by.
# @param [Boolean] refresh If true, then if there is a cached version
# it is reloaded.
# @return [Machine]
def machine(name, provider, refresh=false)
# @return [Vagrant::Remote::Machine]
# def machine(name, provider, refresh=false)
# return Machine.new(
# name, provider.to_s, nil, nil, nil, {}, nil, nil, self, nil, false)
# end
# return [VagrantPlugins::CommandServe::Client::Machine]
def get_target(name)
return @client.target(name)
end
end

View File

@ -13,7 +13,7 @@ module Vagrant
def initialize(name, provider_name, provider_cls, provider_config, provider_options, config, data_dir, box, env, vagrantfile, base=false)
@logger = Log4r::Logger.new("vagrant::machine")
@client = VagrantPlugins::CommandServe::Client::Machine.new(env: env)
@client = env.get_target(name)
@env = env
@ui = Vagrant::UI::Prefixed.new(@env.ui, name)
@provider_name = provider_name

View File

@ -99,15 +99,23 @@ module VagrantPlugins
end
def get_state
req = Google::Protobuf::Empty.new
resp = @client.get_state(req)
# req = Google::Protobuf::Empty.new
# resp = @client.get_state(req)
# @logger.debug("Got state #{resp}")
# Vagrant::MachineState.new(
# resp.state.id.to_sym,
# resp.state.short_description,
# resp.state.long_description
# )
Vagrant::MachineState.new(
resp.state.id.to_sym,
resp.state.short_description,
resp.state.long_description
:UNKNOWN,
"all good",
"you know, all good"
)
end
alias state get_state
# @param [SRV::Operation::PhysicalState] state of the machine
def set_state(state)
req = SDK::Target::Machine::SetStateRequest.new(

View File

@ -5,15 +5,16 @@ module VagrantPlugins
attr_reader :client
def initialize(conn)
def initialize(conn, broker=nil)
@logger = Log4r::Logger.new("vagrant::command::serve::client::project")
@client = SDK::ProjectService::Stub.new(conn, :this_channel_is_insecure)
@broker = broker
end
def self.load(raw_project, broker:)
p = SDK::Args::Project.decode(raw_project)
conn = broker.dial(p.stream_id)
self.new(conn.to_s)
self.new(conn.to_s, broker)
end
# Returns a machine client for the given name
@ -22,15 +23,16 @@ module VagrantPlugins
req = SDK::Project::TargetRequest.new(name: name)
raw_target = @client.target(req)
@logger.debug("got target #{raw_target}")
conn = broker.dial(t.stream_id)
conn = @broker.dial(raw_target.stream_id)
target_service = SDK::TargetService::Stub.new(conn.to_s, :this_channel_is_insecure)
@logger.debug("specializing target")
machine = target_service.specialize(Google::Protobuf::Any.new)
@logger.debug("got machine #{machine}")
m = SDK::Args::Target::Machine.decode(machine.value)
conn = broker.dial(m.stream_id)
return Machine.new(conn)
conn = @broker.dial(m.stream_id)
return Machine.new(conn.to_s)
end
end
end