diff --git a/plugins/providers/hyperv/action.rb b/plugins/providers/hyperv/action.rb index 81b99e8cb..81807d44c 100644 --- a/plugins/providers/hyperv/action.rb +++ b/plugins/providers/hyperv/action.rb @@ -87,6 +87,7 @@ module VagrantPlugins b2.use Package b2.use Export b2.use PackageVagrantfile + b2.use PackageMetadataJson end end end @@ -291,6 +292,7 @@ module VagrantPlugins autoload :PackageSetupFolders, action_root.join("package_setup_folders") autoload :PackageSetupFiles, action_root.join("package_setup_files") autoload :PackageVagrantfile, action_root.join("package_vagrantfile") + autoload :PackageMetadataJson, action_root.join("package_metadata_json") autoload :Export, action_root.join("export") autoload :CheckEnabled, action_root.join("check_enabled") diff --git a/plugins/providers/hyperv/action/package_metadata_json.rb b/plugins/providers/hyperv/action/package_metadata_json.rb new file mode 100644 index 000000000..de2364268 --- /dev/null +++ b/plugins/providers/hyperv/action/package_metadata_json.rb @@ -0,0 +1,34 @@ +require "json" + +#require 'vagrant/util/template_renderer' + +module VagrantPlugins + module HyperV + module Action + class PackageMetadataJson + # For TemplateRenderer + include Vagrant::Util + + def initialize(app, env) + @app = app + end + + def call(env) + @env = env + create_metadata + @app.call(env) + end + + # This method creates a metadata.json file to tell vagrant this is a + # Hyper V box + def create_metadata + File.open(File.join(@env["export.temp_dir"], "metadata.json"), "w") do |f| + f.write(JSON.generate({ + provider: "hyperv" + })) + end + end + end + end + end +end