`vagrant plugin license` command.
This commit is contained in:
parent
7e71b73e4a
commit
55c905b43b
|
@ -299,6 +299,10 @@ module Vagrant
|
||||||
error_key(:plugin_install_bad_entry_point)
|
error_key(:plugin_install_bad_entry_point)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class PluginInstallLicenseNotFound < VagrantError
|
||||||
|
error_key(:plugin_install_license_not_found)
|
||||||
|
end
|
||||||
|
|
||||||
class PluginInstallNotFound < VagrantError
|
class PluginInstallNotFound < VagrantError
|
||||||
error_key(:plugin_install_not_found)
|
error_key(:plugin_install_not_found)
|
||||||
end
|
end
|
||||||
|
@ -311,6 +315,10 @@ module Vagrant
|
||||||
error_key(:plugin_load_failed)
|
error_key(:plugin_load_failed)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class PluginNotFound < VagrantError
|
||||||
|
error_key(:plugin_not_found)
|
||||||
|
end
|
||||||
|
|
||||||
class SCPPermissionDenied < VagrantError
|
class SCPPermissionDenied < VagrantError
|
||||||
error_key(:scp_permission_denied)
|
error_key(:scp_permission_denied)
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,6 +14,14 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This middleware sequence licenses paid addons.
|
||||||
|
def self.action_license
|
||||||
|
Vagrant::Action::Builder.new.tap do |b|
|
||||||
|
b.use BundlerCheck
|
||||||
|
b.use LicensePlugin
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# This middleware sequence will list all installed plugins.
|
# This middleware sequence will list all installed plugins.
|
||||||
def self.action_list
|
def self.action_list
|
||||||
Vagrant::Action::Builder.new.tap do |b|
|
Vagrant::Action::Builder.new.tap do |b|
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
require "fileutils"
|
||||||
|
require "pathname"
|
||||||
|
require "rubygems"
|
||||||
|
require "set"
|
||||||
|
|
||||||
|
require "log4r"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module CommandPlugin
|
||||||
|
module Action
|
||||||
|
# This middleware licenses a plugin by copying the license file to
|
||||||
|
# the proper place.
|
||||||
|
class LicensePlugin
|
||||||
|
def initialize(app, env)
|
||||||
|
@app = app
|
||||||
|
@logger = Log4r::Logger.new("vagrant::plugins::plugincommand::license")
|
||||||
|
end
|
||||||
|
|
||||||
|
def call(env)
|
||||||
|
# Get the list of installed plugins according to the state file
|
||||||
|
installed = Set.new(env[:plugin_state_file].installed_plugins)
|
||||||
|
|
||||||
|
# If the plugin we're trying to license doesn't exist in the
|
||||||
|
# state file, then it is an error.
|
||||||
|
if !installed.include?(env[:plugin_name])
|
||||||
|
raise Vagrant::Errors::PluginNotFound, :name => env[:plugin_name]
|
||||||
|
end
|
||||||
|
|
||||||
|
# Verify the license file exists
|
||||||
|
license_file = Pathname.new(env[:plugin_license_path])
|
||||||
|
if !license_file.file?
|
||||||
|
raise Vagrant::Errors::PluginInstallLicenseNotFound,
|
||||||
|
:name => env[:plugin_name],
|
||||||
|
:path => license_file.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
# Copy it in.
|
||||||
|
final_path = env[:home_path].join("license-#{env[:plugin_name]}.lic")
|
||||||
|
@logger.info("Copying license from: #{license_file}")
|
||||||
|
@logger.info("Copying license to: #{final_path}")
|
||||||
|
env[:ui].info(I18n.t("vagrant.commands.plugin.installing_license",
|
||||||
|
:name => env[:plugin_name]))
|
||||||
|
FileUtils.cp(license_file, final_path)
|
||||||
|
|
||||||
|
# Installed!
|
||||||
|
env[:ui].success(I18n.t("vagrant.commands.plugin.installed_license"))
|
||||||
|
|
||||||
|
@app.call(env)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,31 @@
|
||||||
|
require 'optparse'
|
||||||
|
|
||||||
|
require_relative "base"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module CommandPlugin
|
||||||
|
module Command
|
||||||
|
class License < Base
|
||||||
|
def execute
|
||||||
|
opts = OptionParser.new do |o|
|
||||||
|
o.banner = "Usage: vagrant plugin license <name> <license-file> [-h]"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Parse the options
|
||||||
|
argv = parse_options(opts)
|
||||||
|
return if !argv
|
||||||
|
raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 2
|
||||||
|
|
||||||
|
# License the plugin
|
||||||
|
action(Action.action_license, {
|
||||||
|
:plugin_license_path => argv[1],
|
||||||
|
:plugin_name => argv[0]
|
||||||
|
})
|
||||||
|
|
||||||
|
# Success, exit status 0
|
||||||
|
0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -15,6 +15,11 @@ module VagrantPlugins
|
||||||
Install
|
Install
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@subcommands.register(:license) do
|
||||||
|
require_relative "license"
|
||||||
|
License
|
||||||
|
end
|
||||||
|
|
||||||
@subcommands.register(:list) do
|
@subcommands.register(:list) do
|
||||||
require_relative "list"
|
require_relative "list"
|
||||||
List
|
List
|
||||||
|
|
|
@ -175,6 +175,10 @@ en:
|
||||||
the entry point doesn't exist. The entry point attempted was
|
the entry point doesn't exist. The entry point attempted was
|
||||||
'%{entry_point}'. If this is not correct, please manually
|
'%{entry_point}'. If this is not correct, please manually
|
||||||
specify an `--entry-point` when installing the plugin.
|
specify an `--entry-point` when installing the plugin.
|
||||||
|
plugin_install_license_not_found: |-
|
||||||
|
The license file to install could not be found. Please verify
|
||||||
|
the path you gave is correct. The path to the license file given
|
||||||
|
was: '%{path}'
|
||||||
plugin_install_not_found: |-
|
plugin_install_not_found: |-
|
||||||
The plugin '%{name}' could not be found in local or remote
|
The plugin '%{name}' could not be found in local or remote
|
||||||
repositories. Please check the name of the plugin and try again.
|
repositories. Please check the name of the plugin and try again.
|
||||||
|
@ -183,6 +187,9 @@ en:
|
||||||
properly installed via `vagrant plugin`.
|
properly installed via `vagrant plugin`.
|
||||||
plugin_load_failed: |-
|
plugin_load_failed: |-
|
||||||
Failed to load the "%{plugin}" plugin. View logs for more details.
|
Failed to load the "%{plugin}" plugin. View logs for more details.
|
||||||
|
plugin_not_found: |-
|
||||||
|
The plugin '%{name}' could not be found. Please install this plugin
|
||||||
|
prior to attempting to do anything with it.
|
||||||
port_collision_resume: |-
|
port_collision_resume: |-
|
||||||
This VM cannot be resumed, because the forwarded ports would collide with
|
This VM cannot be resumed, because the forwarded ports would collide with
|
||||||
another running virtual machine. Normally, Vagrant will attempt to fix this
|
another running virtual machine. Normally, Vagrant will attempt to fix this
|
||||||
|
@ -420,6 +427,10 @@ en:
|
||||||
the comments in the Vagrantfile as well as documentation on
|
the comments in the Vagrantfile as well as documentation on
|
||||||
`vagrantup.com` for more information on using Vagrant.
|
`vagrantup.com` for more information on using Vagrant.
|
||||||
plugin:
|
plugin:
|
||||||
|
installed_license: |-
|
||||||
|
The license for '%{name}' was successfully installed!
|
||||||
|
installing_license: |-
|
||||||
|
Installing license for '%{name}'...
|
||||||
no_plugins: |-
|
no_plugins: |-
|
||||||
No plugins installed.
|
No plugins installed.
|
||||||
installed: |-
|
installed: |-
|
||||||
|
|
Loading…
Reference in New Issue