Clean up plugin loading and compact registration
This commit is contained in:
parent
f915922f7d
commit
ae6639d301
@ -1,10 +1,7 @@
|
||||
# NOTE: Update the load path so the proto files can properly require dependencies
|
||||
$LOAD_PATH << File.expand_path("../service/proto/gen", __FILE__)
|
||||
|
||||
require_relative './service/proto/gen/ruby-server_pb'
|
||||
require_relative './service/proto/gen/ruby-server_services_pb'
|
||||
require_relative './service/proto/gen/plugin_pb'
|
||||
require_relative './service/proto/gen/plugin_services_pb'
|
||||
require 'vagrant/proto/gen/ruby-server_pb'
|
||||
require 'vagrant/proto/gen/ruby-server_services_pb'
|
||||
require 'vagrant/proto/gen/plugin/plugin_pb'
|
||||
require 'vagrant/proto/gen/plugin/plugin_services_pb'
|
||||
|
||||
require_relative "./service/plugin_service"
|
||||
require_relative "./service/provider_service"
|
||||
@ -53,23 +50,15 @@ module VagrantPlugins
|
||||
s = GRPC::RpcServer.new
|
||||
# Listen on port 10001 on all interfaces. Update for production use.
|
||||
s.add_http2_port("[::]:#{port}", :this_port_is_insecure)
|
||||
|
||||
s.handle(VagrantPlugins::CommandServe::Serve::PluginService.new)
|
||||
s.handle(VagrantPlugins::CommandServe::Serve::ProviderService.new)
|
||||
s.handle(Service::InternalService.new)
|
||||
s.handle(Service::HostService.new)
|
||||
s.handle(Service::CommandService.new)
|
||||
|
||||
health_checker = Grpc::Health::Checker.new
|
||||
health_checker.add_status(
|
||||
Service::InternalService,
|
||||
Grpc::Health::V1::HealthCheckResponse::ServingStatus::SERVING)
|
||||
health_checker.add_status(
|
||||
Service::HostService,
|
||||
Grpc::Health::V1::HealthCheckResponse::ServingStatus::SERVING)
|
||||
health_checker.add_status(
|
||||
Service::CommandService,
|
||||
Grpc::Health::V1::HealthCheckResponse::ServingStatus::SERVING)
|
||||
|
||||
[Service::PluginService, Service::ProviderService, Service::InternalService,
|
||||
Service::HostService, Service::CommandService].each do |service_klass|
|
||||
s.handle(service_klass.new)
|
||||
health_checker.add_status(service_klass,
|
||||
Grpc::Health::V1::HealthCheckResponse::ServingStatus::SERVING)
|
||||
end
|
||||
|
||||
s.handle(health_checker)
|
||||
|
||||
STDOUT.puts "1|1|tcp|127.0.0.1:#{port}|grpc"
|
||||
|
||||
@ -20,15 +20,6 @@ module VagrantPlugins
|
||||
|
||||
def synopsis_spec(*args)
|
||||
return Hashicorp::Vagrant::Sdk::FuncSpec.new
|
||||
Hashicorp::Vagrant::Sdk::FuncSpec.new(
|
||||
name: "synopsis",
|
||||
result: [
|
||||
Hashicorp::Vagrant::Sdk::FuncSpec::Value.new(
|
||||
type: "hashicorp.vagrant.sdk.Command.SynopsisResp",
|
||||
name: ""
|
||||
)
|
||||
]
|
||||
)
|
||||
end
|
||||
|
||||
def synopsis(*args)
|
||||
|
||||
@ -1,12 +1,8 @@
|
||||
require "vagrant/plugin/v2/plugin"
|
||||
|
||||
|
||||
require 'vagrant/proto/gen/ruby-server_pb'
|
||||
require 'vagrant/proto/gen/ruby-server_services_pb'
|
||||
|
||||
module VagrantPlugins
|
||||
module CommandServe
|
||||
module Serve
|
||||
module Service
|
||||
class PluginService < Hashicorp::Vagrant::RubyVagrant::Service
|
||||
def get_plugins(req, _unused_call)
|
||||
plugins = []
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
|
||||
require 'vagrant/proto/gen/plugin/plugin_pb'
|
||||
require 'vagrant/proto/gen/plugin/plugin_services_pb'
|
||||
require 'vagrant/machine'
|
||||
require 'vagrant/batch_action'
|
||||
require 'logger'
|
||||
|
||||
module VagrantPlugins
|
||||
module CommandServe
|
||||
module Serve
|
||||
module Service
|
||||
class ProviderService < Hashicorp::Vagrant::Sdk::ProviderService::Service
|
||||
LOG = Logger.new('/tmp/vagrant-ruby.txt')
|
||||
|
||||
@ -52,7 +49,7 @@ module VagrantPlugins
|
||||
machine_arg = Hashicorp::Vagrant::Sdk::Args::Machine.decode(raw_machine_arg)
|
||||
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.resource_id)
|
||||
LOG.debug("got machine: " + machine.name)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user