From 8f034b24e2a4bf66d34762b13b03c2c11517d02d Mon Sep 17 00:00:00 2001 From: sophia Date: Wed, 13 Jan 2021 13:40:25 -0600 Subject: [PATCH] Parse vagrantfile --- .../serve/service/ruby_vagrant_service.rb | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/plugins/commands/serve/service/ruby_vagrant_service.rb b/plugins/commands/serve/service/ruby_vagrant_service.rb index 291870959..a5e313630 100644 --- a/plugins/commands/serve/service/ruby_vagrant_service.rb +++ b/plugins/commands/serve/service/ruby_vagrant_service.rb @@ -1,4 +1,9 @@ require "vagrant/plugin/v2/plugin" +require "vagrant/vagrantfile" +require "vagrant/box_collection" +require "vagrant/config" +require 'pp' +require "pathname" require 'vagrant/proto/gen/ruby-server_pb' require 'vagrant/proto/gen/ruby-server_services_pb' @@ -41,6 +46,21 @@ module VagrantPlugins def parse_vagrantfile(req, _unused_call) vagrantfile_path = req.path raw = File.read(vagrantfile_path) + + LOG.debug("got vagrantfile at " + vagrantfile_path) + config_loader = Vagrant::Config::Loader.new( + Vagrant::Config::VERSIONS, Vagrant::Config::VERSIONS_ORDER) + config_loader.set(:root, vagrantfile_path) + v = Vagrant::Vagrantfile.new(config_loader, [:root]) + + LOG.debug("machines: ") + v.machine_names.each do |mach| + LOG.debug(mach) + machine_info = v.machine_config(mach, nil, nil) + root_config = machine_info[:config] + config = root_config.vm + LOG.debug(config.box) + end vagrantfile = Hashicorp::Vagrant::Vagrantfile.new(raw: raw) Hashicorp::Vagrant::ParseVagrantfileResponse.new( vagrantfile: vagrantfile