diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index 1dbb73fc8..53ed08ebf 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -25,33 +25,24 @@ module Vagrant # @param [String] machine id # @return [Machine] def get_machine(id) - machine_ref = Hashicorp::Vagrant::Sdk::Ref::Machine.new(:id => id) - req = Hashicorp::Vagrant::Sdk::GetMachineRequest.new( - :ref => machine_ref + machine_ref = Hashicorp::Vagrant::Sdk::Ref::Machine.new(resource_id: id) + req = Hashicorp::Vagrant::Sdk::Machine::GetNameRequest.new( + machine: machine_ref ) - resp_machine = @client.get_machine(req) - m = resp_machine.machine + resp_machine = @client.get_name(req) + m = resp_machine.name - provider_plugin = Vagrant.plugin("2").manager.providers[m.provider_name.to_sym] + provider_plugin = Vagrant.plugin("2").manager.providers[:virtualbox] provider_cls = provider_plugin[0] provider_options = provider_plugin[1] Machine.new( - m.name, m.provider_name, provider_cls, - m.provider_config, provider_options, m.config, - m.data_dir, m.box, m.env, m.vagrantfile, + m, "virtualbox", provider_cls, + {}, provider_options, {}, + "", "", {}, nil, base=false, client=@client ) end - - # Update/insert a machine - # - # @param [Machine] machine to upsert - # @return [Machine] the final state of the machine - def upsert_machine(machine) - - end - end # This represents a machine that Vagrant manages. This provides a singular diff --git a/lib/vagrant/proto/gen/plugin/core_pb.rb b/lib/vagrant/proto/gen/plugin/core_pb.rb index dfefa7c58..f2147294e 100644 --- a/lib/vagrant/proto/gen/plugin/core_pb.rb +++ b/lib/vagrant/proto/gen/plugin/core_pb.rb @@ -3,7 +3,9 @@ require 'google/protobuf' +require_relative './plugin_pb' require 'google/protobuf/any_pb' +require 'google/protobuf/timestamp_pb' Google::Protobuf::DescriptorPool.generated_pool.build do add_file("core.proto", :syntax => :proto3) do add_message "hashicorp.vagrant.sdk.StateBag" do @@ -90,66 +92,90 @@ Google::Protobuf::DescriptorPool.generated_pool.build do optional :metadata_url, :string, 6 end add_message "hashicorp.vagrant.sdk.Environment" do - optional :cwd, :string, 1 - optional :data_dir, :string, 2 - optional :vagrantfile_name, :string, 3 - optional :ui, :message, 4, "hashicorp.vagrant.sdk.UI" - optional :home_path, :string, 5 - optional :local_data_path, :string, 6 - optional :tmp_path, :string, 7 - optional :aliases_path, :string, 8 - optional :boxes_path, :string, 9 - optional :gems_path, :string, 10 - optional :default_private_key_path, :string, 11 end add_message "hashicorp.vagrant.sdk.MachineProvider" do end add_message "hashicorp.vagrant.sdk.Configuration" do end - add_message "hashicorp.vagrant.sdk.Machine" do - optional :box, :message, 1, "hashicorp.vagrant.sdk.Box" - optional :config, :message, 2, "hashicorp.vagrant.sdk.Configuration" - optional :data_dir, :string, 3 - optional :env, :message, 4, "hashicorp.vagrant.sdk.Environment" - optional :id, :string, 5 - optional :name, :string, 6 - optional :provider, :message, 7, "hashicorp.vagrant.sdk.MachineProvider" - optional :provider_config, :message, 8, "hashicorp.vagrant.sdk.Configuration" - optional :provider_name, :string, 9 - optional :provider_options, :message, 10, "hashicorp.vagrant.sdk.Options" - optional :ui, :message, 11, "hashicorp.vagrant.sdk.UI" - optional :vagrantfile, :message, 12, "hashicorp.vagrant.sdk.Vagrantfile" - end add_message "hashicorp.vagrant.sdk.Vagrantfile" do end - add_message "hashicorp.vagrant.sdk.UI" do - optional :stream_id, :uint32, 1 - end add_message "hashicorp.vagrant.sdk.Ref" do end add_message "hashicorp.vagrant.sdk.Ref.Machine" do + optional :resource_id, :string, 1 + end + add_message "hashicorp.vagrant.sdk.Machine" do + end + add_message "hashicorp.vagrant.sdk.Machine.SetNameRequest" do + optional :machine, :message, 1, "hashicorp.vagrant.sdk.Ref.Machine" + optional :name, :string, 2 + end + add_message "hashicorp.vagrant.sdk.Machine.SetNameResponse" do + end + add_message "hashicorp.vagrant.sdk.Machine.GetNameRequest" do + optional :machine, :message, 1, "hashicorp.vagrant.sdk.Ref.Machine" + end + add_message "hashicorp.vagrant.sdk.Machine.GetNameResponse" do + optional :name, :string, 1 + end + add_message "hashicorp.vagrant.sdk.Machine.SetIDRequest" do + optional :machine, :message, 1, "hashicorp.vagrant.sdk.Ref.Machine" + optional :id, :string, 2 + end + add_message "hashicorp.vagrant.sdk.Machine.SetIDResponse" do + end + add_message "hashicorp.vagrant.sdk.Machine.GetIDRequest" do + optional :machine, :message, 1, "hashicorp.vagrant.sdk.Ref.Machine" + end + add_message "hashicorp.vagrant.sdk.Machine.GetIDResponse" do optional :id, :string, 1 end - add_message "hashicorp.vagrant.sdk.Ref.Workspace" do - optional :workspace, :string, 1 + add_message "hashicorp.vagrant.sdk.Machine.BoxRequest" do + optional :machine, :message, 1, "hashicorp.vagrant.sdk.Ref.Machine" end - add_message "hashicorp.vagrant.sdk.UpsertMachineRequest" do - optional :machine, :message, 1, "hashicorp.vagrant.sdk.Machine" + add_message "hashicorp.vagrant.sdk.Machine.BoxResponse" do + optional :box, :message, 1, "hashicorp.vagrant.sdk.Box" end - add_message "hashicorp.vagrant.sdk.UpsertMachineResponse" do - optional :machine, :message, 1, "hashicorp.vagrant.sdk.Machine" + add_message "hashicorp.vagrant.sdk.Machine.DatadirRequest" do + optional :machine, :message, 1, "hashicorp.vagrant.sdk.Ref.Machine" end - add_message "hashicorp.vagrant.sdk.GetMachineRequest" do - optional :ref, :message, 1, "hashicorp.vagrant.sdk.Ref.Machine" + add_message "hashicorp.vagrant.sdk.Machine.DatadirResponse" do + optional :datadir, :message, 1, "hashicorp.vagrant.sdk.Args.DataDir.Machine" end - add_message "hashicorp.vagrant.sdk.GetMachineResponse" do - optional :machine, :message, 1, "hashicorp.vagrant.sdk.Machine" + add_message "hashicorp.vagrant.sdk.Machine.LocalDataPathRequest" do + optional :machine, :message, 1, "hashicorp.vagrant.sdk.Ref.Machine" end - add_message "hashicorp.vagrant.sdk.ListMachineRequest" do - optional :workspace, :message, 2, "hashicorp.vagrant.sdk.Ref.Workspace" + add_message "hashicorp.vagrant.sdk.Machine.LocalDataPathResponse" do + optional :path, :string, 1 end - add_message "hashicorp.vagrant.sdk.ListMachineResponse" do - repeated :machines, :message, 1, "hashicorp.vagrant.sdk.Machine" + add_message "hashicorp.vagrant.sdk.Machine.ProviderRequest" do + optional :machine, :message, 1, "hashicorp.vagrant.sdk.Ref.Machine" + end + add_message "hashicorp.vagrant.sdk.Machine.ProviderResponse" do + end + add_message "hashicorp.vagrant.sdk.Machine.VagrantfileNameRequest" do + optional :machine, :message, 1, "hashicorp.vagrant.sdk.Ref.Machine" + end + add_message "hashicorp.vagrant.sdk.Machine.VagrantfileNameResponse" do + optional :name, :string, 1 + end + add_message "hashicorp.vagrant.sdk.Machine.VagrantfilePathRequest" do + optional :machine, :message, 1, "hashicorp.vagrant.sdk.Ref.Machine" + end + add_message "hashicorp.vagrant.sdk.Machine.VagrantfilePathResponse" do + optional :path, :string, 1 + end + add_message "hashicorp.vagrant.sdk.Machine.UpdatedAtRequest" do + optional :machine, :message, 1, "hashicorp.vagrant.sdk.Ref.Machine" + end + add_message "hashicorp.vagrant.sdk.Machine.UpdatedAtResponse" do + optional :updated_at, :message, 1, "google.protobuf.Timestamp" + end + add_message "hashicorp.vagrant.sdk.Machine.UIRequest" do + optional :machine, :message, 1, "hashicorp.vagrant.sdk.Ref.Machine" + end + add_message "hashicorp.vagrant.sdk.Machine.UIResponse" do + optional :ui, :message, 1, "hashicorp.vagrant.sdk.Args.TerminalUI" end end end @@ -172,18 +198,34 @@ module Hashicorp Environment = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Environment").msgclass MachineProvider = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.MachineProvider").msgclass Configuration = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Configuration").msgclass - Machine = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine").msgclass Vagrantfile = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Vagrantfile").msgclass - UI = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.UI").msgclass Ref = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Ref").msgclass Ref::Machine = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Ref.Machine").msgclass - Ref::Workspace = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Ref.Workspace").msgclass - UpsertMachineRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.UpsertMachineRequest").msgclass - UpsertMachineResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.UpsertMachineResponse").msgclass - GetMachineRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.GetMachineRequest").msgclass - GetMachineResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.GetMachineResponse").msgclass - ListMachineRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.ListMachineRequest").msgclass - ListMachineResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.ListMachineResponse").msgclass + Machine = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine").msgclass + Machine::SetNameRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.SetNameRequest").msgclass + Machine::SetNameResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.SetNameResponse").msgclass + Machine::GetNameRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.GetNameRequest").msgclass + Machine::GetNameResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.GetNameResponse").msgclass + Machine::SetIDRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.SetIDRequest").msgclass + Machine::SetIDResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.SetIDResponse").msgclass + Machine::GetIDRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.GetIDRequest").msgclass + Machine::GetIDResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.GetIDResponse").msgclass + Machine::BoxRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.BoxRequest").msgclass + Machine::BoxResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.BoxResponse").msgclass + Machine::DatadirRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.DatadirRequest").msgclass + Machine::DatadirResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.DatadirResponse").msgclass + Machine::LocalDataPathRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.LocalDataPathRequest").msgclass + Machine::LocalDataPathResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.LocalDataPathResponse").msgclass + Machine::ProviderRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.ProviderRequest").msgclass + Machine::ProviderResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.ProviderResponse").msgclass + Machine::VagrantfileNameRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.VagrantfileNameRequest").msgclass + Machine::VagrantfileNameResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.VagrantfileNameResponse").msgclass + Machine::VagrantfilePathRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.VagrantfilePathRequest").msgclass + Machine::VagrantfilePathResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.VagrantfilePathResponse").msgclass + Machine::UpdatedAtRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.UpdatedAtRequest").msgclass + Machine::UpdatedAtResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.UpdatedAtResponse").msgclass + Machine::UIRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.UIRequest").msgclass + Machine::UIResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Machine.UIResponse").msgclass end end end diff --git a/lib/vagrant/proto/gen/plugin/core_services_pb.rb b/lib/vagrant/proto/gen/plugin/core_services_pb.rb index 6796f23c9..29bc50344 100644 --- a/lib/vagrant/proto/gen/plugin/core_services_pb.rb +++ b/lib/vagrant/proto/gen/plugin/core_services_pb.rb @@ -9,7 +9,7 @@ module Hashicorp module Sdk module MachineService # ******************************************************************* - # Core services + # Machine services # ****************************************************************** class Service @@ -19,12 +19,18 @@ module Hashicorp self.unmarshal_class_method = :decode self.service_name = 'hashicorp.vagrant.sdk.MachineService' - # GetMachine returns the achine. - rpc :GetMachine, ::Hashicorp::Vagrant::Sdk::GetMachineRequest, ::Hashicorp::Vagrant::Sdk::GetMachineResponse - # ListMachines returns a list of all the machine. - rpc :ListMachines, ::Hashicorp::Vagrant::Sdk::ListMachineRequest, ::Hashicorp::Vagrant::Sdk::ListMachineResponse - # UpsertMachine updates or inserts a machine. - rpc :UpsertMachine, ::Hashicorp::Vagrant::Sdk::UpsertMachineRequest, ::Hashicorp::Vagrant::Sdk::UpsertMachineResponse + rpc :SetName, ::Hashicorp::Vagrant::Sdk::Machine::SetNameRequest, ::Hashicorp::Vagrant::Sdk::Machine::SetNameResponse + rpc :GetName, ::Hashicorp::Vagrant::Sdk::Machine::GetNameRequest, ::Hashicorp::Vagrant::Sdk::Machine::GetNameResponse + rpc :SetID, ::Hashicorp::Vagrant::Sdk::Machine::SetIDRequest, ::Hashicorp::Vagrant::Sdk::Machine::SetIDResponse + rpc :GetID, ::Hashicorp::Vagrant::Sdk::Machine::GetIDRequest, ::Hashicorp::Vagrant::Sdk::Machine::GetIDResponse + rpc :Box, ::Hashicorp::Vagrant::Sdk::Machine::BoxRequest, ::Hashicorp::Vagrant::Sdk::Machine::BoxResponse + rpc :Datadir, ::Hashicorp::Vagrant::Sdk::Machine::DatadirRequest, ::Hashicorp::Vagrant::Sdk::Machine::DatadirResponse + rpc :LocalDataPath, ::Hashicorp::Vagrant::Sdk::Machine::LocalDataPathRequest, ::Hashicorp::Vagrant::Sdk::Machine::LocalDataPathResponse + rpc :Provider, ::Hashicorp::Vagrant::Sdk::Machine::ProviderRequest, ::Hashicorp::Vagrant::Sdk::Machine::ProviderResponse + rpc :VagrantfileName, ::Hashicorp::Vagrant::Sdk::Machine::VagrantfileNameRequest, ::Hashicorp::Vagrant::Sdk::Machine::VagrantfileNameResponse + rpc :VagrantfilePath, ::Hashicorp::Vagrant::Sdk::Machine::VagrantfilePathRequest, ::Hashicorp::Vagrant::Sdk::Machine::VagrantfilePathResponse + rpc :UpdatedAt, ::Hashicorp::Vagrant::Sdk::Machine::UpdatedAtRequest, ::Hashicorp::Vagrant::Sdk::Machine::UpdatedAtResponse + rpc :UI, ::Hashicorp::Vagrant::Sdk::Machine::UIRequest, ::Hashicorp::Vagrant::Sdk::Machine::UIResponse end Stub = Service.rpc_stub_class diff --git a/lib/vagrant/proto/gen/plugin/plugin_pb.rb b/lib/vagrant/proto/gen/plugin/plugin_pb.rb index 12fc7f37d..883d64806 100644 --- a/lib/vagrant/proto/gen/plugin/plugin_pb.rb +++ b/lib/vagrant/proto/gen/plugin/plugin_pb.rb @@ -7,7 +7,6 @@ require 'google/protobuf/any_pb' require 'google/protobuf/empty_pb' require 'google/rpc/status_pb' require_relative './protostructure_pb' -require_relative './core_pb' Google::Protobuf::DescriptorPool.generated_pool.build do add_file("plugin.proto", :syntax => :proto3) do add_message "hashicorp.vagrant.sdk.Args" do @@ -54,14 +53,6 @@ Google::Protobuf::DescriptorPool.generated_pool.build do add_message "hashicorp.vagrant.sdk.Args.BoxCollection" do optional :directory, :string, 1 end - add_message "hashicorp.vagrant.sdk.Args.Box" do - optional :name, :string, 1 - optional :provider, :string, 2 - optional :version, :string, 3 - optional :directory, :string, 4 - optional :metadata, :message, 5, "hashicorp.vagrant.sdk.Args.Options" - optional :metadata_url, :string, 6 - end add_message "hashicorp.vagrant.sdk.Args.Environment" do optional :cwd, :string, 1 optional :data_dir, :string, 2 @@ -76,7 +67,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do optional :default_private_key_path, :string, 11 end add_message "hashicorp.vagrant.sdk.Args.Machine" do - optional :machineId, :string, 1 + optional :resource_id, :string, 1 optional :serverAddr, :string, 2 end add_message "hashicorp.vagrant.sdk.Args.Configuration" do @@ -271,9 +262,9 @@ Google::Protobuf::DescriptorPool.generated_pool.build do add_message "hashicorp.vagrant.sdk.Communicator.FileTransferResp" do end add_message "hashicorp.vagrant.sdk.Communicator.ExecutionRequest" do - optional :machine, :message, 1, "hashicorp.vagrant.sdk.Machine" + optional :machine, :message, 1, "hashicorp.vagrant.sdk.Args.Machine" optional :command, :string, 2 - optional :options, :message, 3, "hashicorp.vagrant.sdk.LabelSet" + optional :options, :message, 3, "hashicorp.vagrant.sdk.Args.LabelSet" end add_message "hashicorp.vagrant.sdk.Communicator.ExecuteResp" do optional :exit_code, :int32, 1 @@ -328,7 +319,6 @@ module Hashicorp Args::MachineIndex = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Args.MachineIndex").msgclass Args::MachineIndex::Entry = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Args.MachineIndex.Entry").msgclass Args::BoxCollection = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Args.BoxCollection").msgclass - Args::Box = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Args.Box").msgclass Args::Environment = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Args.Environment").msgclass Args::Machine = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Args.Machine").msgclass Args::Configuration = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Args.Configuration").msgclass diff --git a/plugins/commands/serve/service/provider_service.rb b/plugins/commands/serve/service/provider_service.rb index 1fa012fe5..fc42f42b5 100644 --- a/plugins/commands/serve/service/provider_service.rb +++ b/plugins/commands/serve/service/provider_service.rb @@ -35,19 +35,19 @@ module VagrantPlugins end def action_up(req, _unused_call) + LOG.debug("Coming up") machine = machine_arg_to_machine(req) - LOG.debug(machine) Hashicorp::Vagrant::Sdk::Provider::ActionResp.new(success: true) end def machine_arg_to_machine(req) raw_machine_arg = req.args[0].value.value machine_arg = Hashicorp::Vagrant::Sdk::Args::Machine.decode(raw_machine_arg) - LOG.debug("machine id: " + machine_arg.machineId) + LOG.debug("machine id: " + machine_arg.resource_id) LOG.debug("server addr: " + machine_arg.serverAddr) mclient = Vagrant::MachineClient.new(machine_arg.serverAddr) - machine = mclient.get_machine(machine_arg.machineId) + machine = mclient.get_machine(machine_arg.resource_id) LOG.debug("got machine: " + machine.name) LOG.debug("using provider: " + machine.provider_name) machine