vagrant-vbguest 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. data/CHANGELOG.md +10 -0
  2. data/lib/vagrant-vbguest.rb +1 -4
  3. data/lib/vagrant-vbguest/command.rb +4 -34
  4. data/lib/vagrant-vbguest/download.rb +14 -69
  5. data/lib/vagrant-vbguest/errors.rb +1 -1
  6. data/lib/vagrant-vbguest/hosts/base.rb +15 -9
  7. data/lib/vagrant-vbguest/hosts/virtualbox.rb +15 -0
  8. data/lib/vagrant-vbguest/installer.rb +1 -1
  9. data/lib/vagrant-vbguest/installers/base.rb +7 -7
  10. data/lib/vagrant-vbguest/installers/linux.rb +4 -4
  11. data/lib/vagrant-vbguest/machine.rb +3 -3
  12. data/lib/vagrant-vbguest/middleware.rb +11 -2
  13. data/lib/vagrant-vbguest/rebootable.rb +39 -0
  14. data/lib/vagrant-vbguest/vagrant_compat.rb +18 -0
  15. data/lib/vagrant-vbguest/vagrant_compat/vagrant_1_0/command.rb +17 -0
  16. data/lib/vagrant-vbguest/vagrant_compat/vagrant_1_0/download.rb +51 -0
  17. data/lib/vagrant-vbguest/vagrant_compat/vagrant_1_0/rebootable.rb +23 -0
  18. data/lib/vagrant-vbguest/vagrant_compat/vagrant_1_0/vm_compatible.rb +31 -0
  19. data/lib/vagrant-vbguest/vagrant_compat/vagrant_1_1/command.rb +18 -0
  20. data/lib/vagrant-vbguest/vagrant_compat/vagrant_1_1/download.rb +1 -0
  21. data/lib/vagrant-vbguest/vagrant_compat/vagrant_1_1/rebootable.rb +30 -0
  22. data/lib/vagrant-vbguest/vagrant_compat/vagrant_1_1/vm_compatible.rb +31 -0
  23. data/lib/vagrant-vbguest/vagrant_compat/vagrant_1_2/command.rb +1 -0
  24. data/lib/vagrant-vbguest/vagrant_compat/vagrant_1_2/download.rb +18 -0
  25. data/lib/vagrant-vbguest/vagrant_compat/vagrant_1_2/rebootable.rb +1 -0
  26. data/lib/vagrant-vbguest/vagrant_compat/vagrant_1_2/vm_compatible.rb +15 -0
  27. data/lib/vagrant-vbguest/version.rb +1 -1
  28. data/lib/vagrant_init.rb +1 -3
  29. data/locales/en.yml +54 -52
  30. metadata +17 -4
  31. data/lib/vagrant-vbguest/helpers.rb +0 -61
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.8.0
2
+
3
+ - Adds Vagrant 1.2 compatibility [GH-59], [GH-60], [GH-62] /
4
+ (thanks @Andrew8xx8 for pointing directions)
5
+ - Fix basic/fallback linux installer [GH-56]
6
+ - Guard auto-reload on broken vagrant builds.
7
+ Some varant 1.1.x versions have a bug regarding ssh and cleaning
8
+ up old connections, which results in varant crashing when a box
9
+ is reloaded.
10
+
1
11
  ## 0.7.1
2
12
 
3
13
  - Fix auto-reloading for vagrant 1.1 [GH-52]
@@ -8,7 +8,7 @@ end
8
8
  I18n.load_path << File.expand_path("../../locales/en.yml", __FILE__)
9
9
 
10
10
  require "vagrant-vbguest/errors"
11
- require 'vagrant-vbguest/helpers'
11
+ require 'vagrant-vbguest/vagrant_compat'
12
12
 
13
13
  require 'vagrant-vbguest/machine'
14
14
 
@@ -24,8 +24,6 @@ require 'vagrant-vbguest/installers/redhat'
24
24
 
25
25
  require 'vagrant-vbguest/middleware'
26
26
 
27
- require 'vagrant-vbguest/download'
28
-
29
27
  module VagrantVbguest
30
28
 
31
29
  class Plugin < Vagrant.plugin("2")
@@ -42,7 +40,6 @@ module VagrantVbguest
42
40
  end
43
41
 
44
42
  command('vbguest') do
45
- require File.expand_path("../vagrant-vbguest/command", __FILE__)
46
43
  Command
47
44
  end
48
45
 
@@ -73,48 +73,18 @@ module VagrantVbguest
73
73
  options = vm.config.vbguest.to_hash.merge(options)
74
74
  machine = VagrantVbguest::Machine.new(vm, options)
75
75
  status = machine.state
76
- vm.env.ui.send((:ok == status ? :success : :warn), I18n.t("vagrant.plugins.vbguest.status.#{status}", machine.info))
76
+ vm.env.ui.send((:ok == status ? :success : :warn), I18n.t("vagrant_vbguest.status.#{status}", machine.info))
77
77
 
78
78
  if _method != :status
79
79
  machine.send(_method)
80
80
  end
81
81
 
82
- reboot(vm, options) if _rebootable && machine.reboot?
82
+ reboot!(vm, options) if _rebootable && machine.reboot?
83
83
  end
84
84
 
85
- def check_runable_on(vm); end
86
- end
87
-
88
-
89
- if Vagrant::VERSION < "1.1.0"
90
- require 'vagrant/command/start_mixins'
91
-
92
- class Command < Vagrant::Command::Base
93
- include CommandCommons
94
- include Vagrant::Command::StartMixins
95
-
96
- def check_runable_on(vm)
97
- raise Vagrant::Errors::VMNotCreatedError if !vm.created?
98
- raise Vagrant::Errors::VMInaccessible if !vm.state == :inaccessible
99
- raise Vagrant::Errors::VMNotRunningError if vm.state != :running
100
- end
85
+ def check_runable_on(vm)
86
+ raise NotImplementedError
101
87
  end
102
-
103
- else
104
- require Vagrant.source_root.join("plugins/commands/up/start_mixins")
105
-
106
- class Command < Vagrant.plugin("2", :command)
107
- include CommandCommons
108
- include VagrantPlugins::CommandUp::StartMixins
109
-
110
- def check_runable_on(vm)
111
- raise Vagrant::Errors::VMNotCreatedError if vm.state.id == :not_created
112
- raise Vagrant::Errors::VMInaccessible if vm.state.id == :inaccessible
113
- raise Vagrant::Errors::VMNotRunningError if vm.state.id != :running
114
- raise VagrantVbguest::NoVirtualBoxMachineError if vm.provider.class != VagrantPlugins::ProviderVirtualBox::Provider
115
- end
116
- end
117
-
118
88
  end
119
89
 
120
90
  end
@@ -1,83 +1,28 @@
1
1
  module VagrantVbguest
2
2
 
3
- # This implementation is based on Action::Box::Download by vagrant
4
- #
5
- # This adoption does not run as a action/middleware, but is called manually
6
- #
7
- # MIT License - Mitchell Hashimoto and John Bender - https://github.com/mitchellh/vagrant
8
- #
9
- #
10
- #
11
- class Download
3
+ class DownloadBase
4
+ attr_reader :source, :destination, :downloader
12
5
 
13
- BASENAME = "vbguest"
14
-
15
- include Vagrant::Util
16
-
17
- attr_reader :temp_path
18
-
19
- def initialize(env)
20
- @env = env
21
- @env["download.classes"] ||= []
22
- @env["download.classes"] += [Vagrant::Downloaders::HTTP, Vagrant::Downloaders::File]
6
+ def initialize(source, destination, options=nil)
23
7
  @downloader = nil
24
- end
25
-
26
- def instantiate_downloader
27
- # Assign to a temporary variable since this is easier to type out,
28
- # since it is used so many times.
29
- classes = @env["download.classes"]
30
-
31
- # Find the class to use.
32
- classes.each_index do |i|
33
- klass = classes[i]
34
-
35
- # Use the class if it matches the given URI or if this
36
- # is the last class...
37
- if classes.length == (i + 1) || klass.match?(@env[:url])
38
- @env[:ui].info I18n.t("vagrant.plugins.vbguest.download.with", :class => klass.to_s)
39
- @downloader = klass.new(@env[:ui])
40
- break
41
- end
8
+ @source = source
9
+ @destination = destination
10
+ if File.directory?(destination)
11
+ @destination = File.join(destination, "vbguest_download_#{Time.now.to_i.to_s}")
42
12
  end
43
-
44
- # This line should never be reached, but we'll keep this here
45
- # just in case for now.
46
- raise Errors::BoxDownloadUnknownType if !@downloader
47
-
48
- @downloader.prepare(@env[:url]) if @downloader.respond_to?(:prepare)
49
- true
13
+ @ui = options[:ui]
50
14
  end
51
15
 
52
- def download
53
- if instantiate_downloader
54
- with_tempfile do |tempfile|
55
- download_to(tempfile)
56
- @temp_path = @env["download.temp_path"] = tempfile.path
57
- end
58
- end
16
+ def download!
17
+ raise NotImplementedError
59
18
  end
60
19
 
61
20
  def cleanup
62
- if temp_path && File.exist?(temp_path)
63
- @env[:ui].info I18n.t("vagrant.plugins.vbguest.download.cleaning")
64
- File.unlink(temp_path)
21
+ if destination && File.exist?(destination)
22
+ @ui.info I18n.t("vagrant_vbguest.download.cleaning")
23
+ File.unlink(destination)
65
24
  end
66
25
  end
67
-
68
- def with_tempfile
69
- File.open(temp_filename, Platform.tar_file_options) do |tempfile|
70
- yield tempfile
71
- end
72
- end
73
-
74
- def temp_filename
75
- @env[:tmp_path].join(BASENAME + Time.now.to_i.to_s)
76
- end
77
-
78
- def download_to(f)
79
- @downloader.download!(@env[:url], f)
80
- end
81
-
82
26
  end
27
+
83
28
  end
@@ -1,7 +1,7 @@
1
1
  module VagrantVbguest
2
2
 
3
3
  class VbguestError < Vagrant::Errors::VagrantError
4
- def error_namespace; "vagrant.plugins.vbguest.errors"; end
4
+ def error_namespace; "vagrant_vbguest.errors"; end
5
5
  end
6
6
 
7
7
  class IsoPathAutodetectionError < VagrantVbguest::VbguestError
@@ -1,3 +1,5 @@
1
+ require 'uri'
2
+
1
3
  module VagrantVbguest
2
4
  module Hosts
3
5
  class Base
@@ -46,7 +48,7 @@ module VagrantVbguest
46
48
 
47
49
  path = versionize(path)
48
50
 
49
- if Vagrant::Downloaders::File.match? path
51
+ if file_match? path
50
52
  @additions_file = path
51
53
  else
52
54
  # :TODO: This will also raise, if the iso_url points to an invalid local path
@@ -62,6 +64,15 @@ module VagrantVbguest
62
64
 
63
65
  protected
64
66
 
67
+ # fix bug when the vagrant version is higher than 1.2, by moving method Vagrant::Vagrant::File.match? here
68
+ def file_match?(uri)
69
+ extracted = ::URI.extract(uri, "file")
70
+
71
+ return true if extracted && extracted.include?(uri)
72
+
73
+ return ::File.file?(::File.expand_path(uri))
74
+ end
75
+
65
76
  # Default web URI, where "additions file" can be downloaded.
66
77
  #
67
78
  # @return [String] A URI template containing the versions placeholder.
@@ -97,14 +108,9 @@ module VagrantVbguest
97
108
  #
98
109
  # @return [String] The path to the downloaded file
99
110
  def download(path)
100
- downloader_env = {
101
- :ui => @env.ui,
102
- :tmp_path => @env.tmp_path,
103
- :url => path
104
- }
105
- @download = VagrantVbguest::Download.new(downloader_env)
106
- @download.download
107
- @download.temp_path
111
+ @download = VagrantVbguest::Download.new(path, @env.tmp_path, :ui => @env.ui)
112
+ @download.download!
113
+ @download.destination
108
114
  end
109
115
 
110
116
  end
@@ -20,6 +20,21 @@ module VagrantVbguest
20
20
  media_manager_iso || guess_local_iso
21
21
  end
22
22
 
23
+ # Kicks off +VagrantVbguest::Download+ to download the additions file
24
+ # into a temp file.
25
+ #
26
+ # To remove the created tempfile call +cleanup+
27
+ #
28
+ # @param [String] The path or URI to download
29
+ #
30
+ # @return [String] The path to the downloaded file
31
+ def download(path)
32
+ temp_path = File.join(@env.tmp_path, "VBoxGuestAdditions_#{version}.iso")
33
+ @download = VagrantVbguest::Download.new(path, temp_path, :ui => @env.ui)
34
+ @download.download!
35
+ @download.destination
36
+ end
37
+
23
38
  private
24
39
 
25
40
  # Helper method which queries the VirtualBox media manager
@@ -6,7 +6,7 @@ module VagrantVbguest
6
6
  class Installer
7
7
 
8
8
  class NoInstallerFoundError < Vagrant::Errors::VagrantError
9
- error_namespace "vagrant.plugins.vbguest.errors.installer"
9
+ error_namespace "vagrant_vbguest.errors.installer"
10
10
  error_key "no_install_script_for_platform"
11
11
  end
12
12
 
@@ -1,7 +1,7 @@
1
1
  module VagrantVbguest
2
2
  module Installers
3
3
  class Error < Vagrant::Errors::VagrantError
4
- error_namespace "vagrant.plugins.vbguest.errors.installer"
4
+ error_namespace "vagrant_vbguest.errors.installer"
5
5
  end
6
6
 
7
7
  # This is the base class all installers must inherit from
@@ -144,16 +144,16 @@ module VagrantVbguest
144
144
  # will start _now_.
145
145
  # The message includes the host and installer version strings.
146
146
  def yield_installation_waring(path_to_installer)
147
- @env.ui.warn I18n.t("vagrant.plugins.vbguest.installing#{@options[:force] ? '_forced' : ''}",
147
+ @env.ui.warn I18n.t("vagrant_vbguest.installing#{@options[:force] ? '_forced' : ''}",
148
148
  :guest_version => guest_version,
149
- :installer_version => installer_version(path_to_installer) || I18n.t("vagrant.plugins.vbguest.unknown"))
149
+ :installer_version => installer_version(path_to_installer) || I18n.t("vagrant_vbguest.unknown"))
150
150
  end
151
151
 
152
152
  # Helper to yield a warning message to the user, that the installation
153
153
  # will be rebuild using the installed GuestAdditions.
154
154
  # The message includes the host and installer version strings.
155
155
  def yield_rebuild_warning
156
- @env.ui.warn I18n.t("vagrant.plugins.vbguest.rebuild#{@options[:force] ? '_forced' : ''}",
156
+ @env.ui.warn I18n.t("vagrant_vbguest.rebuild#{@options[:force] ? '_forced' : ''}",
157
157
  :guest_version => guest_version(true),
158
158
  :host_version => @host.version)
159
159
  end
@@ -165,8 +165,8 @@ module VagrantVbguest
165
165
  # knows there could be a problem. The message includles the installer
166
166
  # version.
167
167
  def yield_installation_error_warning(path_to_installer)
168
- @env.ui.warn I18n.t("vagrant.plugins.vbguest.install_error",
169
- :installer_version => installer_version(path_to_installer) || I18n.t("vagrant.plugins.vbguest.unknown"))
168
+ @env.ui.warn I18n.t("vagrant_vbguest.install_error",
169
+ :installer_version => installer_version(path_to_installer) || I18n.t("vagrant_vbguest.unknown"))
170
170
  end
171
171
 
172
172
  def iso_file
@@ -183,7 +183,7 @@ module VagrantVbguest
183
183
  #
184
184
  # @param [String] Path of the file to upload to the +tmp_path*
185
185
  def upload(file)
186
- env.ui.info(I18n.t("vagrant.plugins.vbguest.start_copy_iso", :from => file, :to => tmp_path))
186
+ env.ui.info(I18n.t("vagrant_vbguest.start_copy_iso", :from => file, :to => tmp_path))
187
187
  communicate.upload(file, tmp_path)
188
188
  end
189
189
 
@@ -13,7 +13,7 @@ module VagrantVbguest
13
13
  # @return [Symbol] One of `:debian`, `:ubuntu`, `:gentoo`, `:fedora`, `:redhat`, `:suse`, `:arch`
14
14
  def self.distro(vm)
15
15
  @@ditro ||= {}
16
- @@ditro[ VagrantVbguest::Helpers::VmCompatible.vm_id(vm) ] ||= vm.guest.distro_dispatch
16
+ @@ditro[ vm_id(vm) ] ||= distro_name vm
17
17
  end
18
18
 
19
19
  # Matches if the operating system name prints "Linux"
@@ -24,7 +24,7 @@ module VagrantVbguest
24
24
  # therefore should do a more specific check.
25
25
  def self.match?(vm)
26
26
  raise Error, :_key => :do_not_inherit_match_method if self != Linux
27
- communicate.test("uname | grep 'Linux'")
27
+ communicate_to(vm).test("uname | grep 'Linux'")
28
28
  end
29
29
 
30
30
  # defaults the temp path to "/tmp/VBoxGuestAdditions.iso" for all Linux based systems
@@ -44,7 +44,7 @@ module VagrantVbguest
44
44
  # @yieldparam [String] type Type of the output, `:stdout`, `:stderr`, etc.
45
45
  # @yieldparam [String] data Data for the given output.
46
46
  def install(opts=nil, &block)
47
- env.ui.warn I18n.t("vagrant.plugins.vbguest.errors.installer.generic_linux_installer") if self.class == Linux
47
+ env.ui.warn I18n.t("vagrant_vbguest.errors.installer.generic_linux_installer") if self.class == Linux
48
48
  upload(iso_file)
49
49
  mount_iso(opts, &block)
50
50
  execute_installer(opts, &block)
@@ -77,7 +77,7 @@ module VagrantVbguest
77
77
 
78
78
  communicate.sudo('VBoxService --version', :error_check => false) do |type, data|
79
79
  if (v = data.to_s.match(/^(\d+\.\d+.\d+)/)) && driver_version != v[1]
80
- @env.ui.warn(I18n.t("vagrant.plugins.vbguest.guest_version_reports_differ", :driver => driver_version, :service => v[1]))
80
+ @env.ui.warn(I18n.t("vagrant_vbguest.guest_version_reports_differ", :driver => driver_version, :service => v[1]))
81
81
  @guest_version = v[1]
82
82
  end
83
83
  end
@@ -23,7 +23,7 @@ module VagrantVbguest
23
23
  while (command = runlist.shift)
24
24
  @logger.debug("Running command #{command} from runlist")
25
25
  if !self.send(command)
26
- env.ui.error('vagrant.plugins.vbguest.machine_loop_guard', :command => command, :state => current_state)
26
+ env.ui.error('vagrant_vbguest.machine_loop_guard', :command => command, :state => current_state)
27
27
  return false
28
28
  end
29
29
  return run if current_state != state
@@ -32,12 +32,12 @@ module VagrantVbguest
32
32
  end
33
33
 
34
34
  def install
35
- return env.ui.warn(I18n.t("vagrant.plugins.vbguest.skipped_installation")) if options[:no_install] && !options[:force]
35
+ return env.ui.warn(I18n.t("vagrant_vbguest.skipped_installation")) if options[:no_install] && !options[:force]
36
36
  guest_additions_state.trigger :install
37
37
  end
38
38
 
39
39
  def rebuild
40
- return env.ui.warn(I18n.t("vagrant.plugins.vbguest.skipped_rebuild")) if options[:no_install] && !options[:force]
40
+ return env.ui.warn(I18n.t("vagrant_vbguest.skipped_rebuild")) if options[:no_install] && !options[:force]
41
41
  guest_additions_state.trigger :rebuild
42
42
  end
43
43
 
@@ -16,17 +16,26 @@ module VagrantVbguest
16
16
  @env = env
17
17
  vm = env[:vm] || env[:machine]
18
18
 
19
- options = vm.config.vbguest.to_hash.freeze
19
+ options = override_config(vm.config.vbguest.to_hash).freeze
20
20
 
21
21
  if options[:auto_update]
22
22
  machine = VagrantVbguest::Machine.new vm, options
23
23
  status = machine.state
24
- vm.env.ui.send((:ok == status ? :success : :warn), I18n.t("vagrant.plugins.vbguest.status.#{status}", machine.info))
24
+ vm.env.ui.send((:ok == status ? :success : :warn), I18n.t("vagrant_vbguest.status.#{status}", machine.info))
25
25
  machine.run
26
26
  reboot(vm, options) if machine.reboot?
27
27
  end
28
+
28
29
  @app.call(env)
29
30
  end
30
31
 
32
+ def override_config(opts)
33
+ if opts[:auto_reboot] && Vagrant::VERSION.between?("1.1.0", "1.1.5") && Vagrant::VERSION != "1.1.4"
34
+ @env[:ui].warn I18n.t("vagrant_vbguest.vagrant_11_reload_issues")
35
+ opts.merge!({:auto_reboot => false})
36
+ end
37
+ opts
38
+ end
39
+
31
40
  end
32
41
  end
@@ -0,0 +1,39 @@
1
+ module VagrantVbguest
2
+ module Helpers
3
+
4
+ module Rebootable
5
+ include VmCompatible
6
+ def self.included(base)
7
+ base.extend(ClassMethods)
8
+ end
9
+
10
+ @@rebooted = {}
11
+
12
+ def rebooted?(vm)
13
+ !!@@rebooted[ self.class.vm_id(vm) ]
14
+ end
15
+
16
+ def reboot?(vm, options)
17
+ if rebooted?(vm)
18
+ vm.env.ui.error(I18n.t("vagrant_vbguest.restart_loop_guard_activated"))
19
+ false
20
+ elsif options[:auto_reboot]
21
+ vm.env.ui.warn(I18n.t("vagrant_vbguest.restart_vm"))
22
+ @@rebooted[ self.class.vm_id(vm) ] = true
23
+ else
24
+ vm.env.ui.warn(I18n.t("vagrant_vbguest.suggest_restart", :name => vm.name))
25
+ false
26
+ end
27
+ end
28
+
29
+ def reboot(vm, options)
30
+ raise NotImplementedError
31
+ end
32
+
33
+ def reboot!(vm, options)
34
+ raise NotImplementedError
35
+ end
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,18 @@
1
+ vagrant_version = Gem::Version.new(Vagrant::VERSION)
2
+ supported_version = {
3
+ "< 1.1.0" => "1_0",
4
+ "~> 1.1.0" => "1_1",
5
+ "~> 1.2.0" => "1_2"
6
+ }
7
+ compat_version = supported_version.find { |requirement, version|
8
+ Gem::Requirement.new(requirement).satisfied_by?(vagrant_version)
9
+ }[1]
10
+
11
+ if !compat_version
12
+ # @TODO: yield warning
13
+ compat_version = supported_version.to_a.last[1]
14
+ end
15
+
16
+ %w{vm_compatible rebootable command download}.each do |r|
17
+ require File.expand_path("../vagrant_compat/vagrant_#{compat_version}/#{r}", __FILE__)
18
+ end
@@ -0,0 +1,17 @@
1
+ require 'vagrant-vbguest/command'
2
+ require 'vagrant/command/start_mixins'
3
+
4
+ module VagrantVbguest
5
+
6
+ class Command < Vagrant::Command::Base
7
+ include CommandCommons
8
+ include Vagrant::Command::StartMixins
9
+
10
+ def check_runable_on(vm)
11
+ raise Vagrant::Errors::VMNotCreatedError if !vm.created?
12
+ raise Vagrant::Errors::VMInaccessible if !vm.state == :inaccessible
13
+ raise Vagrant::Errors::VMNotRunningError if vm.state != :running
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,51 @@
1
+ require 'vagrant-vbguest/download'
2
+ module VagrantVbguest
3
+ # This implementation is based on Action::Box::Download by vagrant
4
+ #
5
+ # This adoption does not run as a action/middleware, but is called manually
6
+ #
7
+ # MIT License - Mitchell Hashimoto and John Bender - https://github.com/mitchellh/vagrant
8
+ #
9
+ #
10
+ #
11
+ class Download < DownloadBase
12
+
13
+ include Vagrant::Util
14
+
15
+ def download!
16
+ if instantiate_downloader
17
+ File.open(@destination, Platform.tar_file_options) do |destination_file|
18
+ @downloader.download!(@source, destination_file)
19
+ end
20
+ end
21
+ @destination
22
+ end
23
+
24
+ def instantiate_downloader
25
+ # Assign to a temporary variable since this is easier to type out,
26
+ # since it is used so many times.
27
+ classes = [Vagrant::Downloaders::HTTP, Vagrant::Downloaders::File]
28
+
29
+ # Find the class to use.
30
+ classes.each_index do |i|
31
+ klass = classes[i]
32
+
33
+ # Use the class if it matches the given URI or if this
34
+ # is the last class...
35
+ if classes.length == (i + 1) || klass.match?(@source)
36
+ @ui.info I18n.t("vagrant_vbguest.download.with", :class => klass.to_s)
37
+ @downloader = klass.new(@ui)
38
+ break
39
+ end
40
+ end
41
+
42
+ # This line should never be reached, but we'll keep this here
43
+ # just in case for now.
44
+ raise Errors::BoxDownloadUnknownType if !@downloader
45
+
46
+ @downloader.prepare(@source) if @downloader.respond_to?(:prepare)
47
+ true
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,23 @@
1
+ require 'vagrant-vbguest/rebootable'
2
+
3
+ module VagrantVbguest
4
+ module Helpers
5
+
6
+ module Rebootable
7
+ def reboot(vm, options)
8
+ if reboot? vm, options
9
+ @env[:action_runner].run(Vagrant::Action::VM::Halt, @env)
10
+ @env[:action_runner].run(Vagrant::Action::VM::Boot, @env)
11
+ end
12
+ end
13
+
14
+ # executes the whole reboot process
15
+ def reboot!(vm, options)
16
+ if reboot? vm, options
17
+ vm.reload(options)
18
+ end
19
+ end
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,31 @@
1
+ module VagrantVbguest
2
+ module Helpers
3
+ module VmCompatible
4
+ def communicate
5
+ vm.channel
6
+ end
7
+
8
+ def driver
9
+ vm.driver
10
+ end
11
+
12
+ def self.included(base)
13
+ base.extend(ClassMethods)
14
+ end
15
+
16
+ module ClassMethods
17
+ def vm_id(vm)
18
+ vm.uuid
19
+ end
20
+
21
+ def communicate_to(vm)
22
+ vm.channel
23
+ end
24
+
25
+ def distro_name(vm)
26
+ vm.guest.distro_dispatch
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,18 @@
1
+ require 'vagrant-vbguest/command'
2
+ require Vagrant.source_root.join("plugins/commands/up/start_mixins")
3
+
4
+ module VagrantVbguest
5
+
6
+ class Command < Vagrant.plugin("2", :command)
7
+ include CommandCommons
8
+ include VagrantPlugins::CommandUp::StartMixins
9
+
10
+ def check_runable_on(vm)
11
+ raise Vagrant::Errors::VMNotCreatedError if vm.state.id == :not_created
12
+ raise Vagrant::Errors::VMInaccessible if vm.state.id == :inaccessible
13
+ raise Vagrant::Errors::VMNotRunningError if vm.state.id != :running
14
+ raise VagrantVbguest::NoVirtualBoxMachineError if vm.provider.class != VagrantPlugins::ProviderVirtualBox::Provider
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1 @@
1
+ require File.expand_path("../../vagrant_1_0/download", __FILE__)
@@ -0,0 +1,30 @@
1
+ require 'vagrant-vbguest/rebootable'
2
+
3
+ module VagrantVbguest
4
+ module Helpers
5
+
6
+ module Rebootable
7
+ def reboot(vm, options)
8
+ if reboot? vm, options
9
+ simle_reboot = Vagrant::Action::Builder.new.tap do |b|
10
+ b.use Vagrant::Action::Builtin::Call, Vagrant::Action::Builtin::GracefulHalt, :poweroff, :running do |env2, b2|
11
+ if !env2[:result]
12
+ b2.use VagrantPlugins::ProviderVirtualBox::Action::ForcedHalt
13
+ end
14
+ end
15
+ b.use VagrantPlugins::ProviderVirtualBox::Action::Boot
16
+ end
17
+ @env[:action_runner].run(simle_reboot, @env)
18
+ end
19
+ end
20
+
21
+ # executes the whole reboot process
22
+ def reboot!(vm, options)
23
+ if reboot? vm, options
24
+ vm.action(:reload, options)
25
+ end
26
+ end
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+ module VagrantVbguest
2
+ module Helpers
3
+ module VmCompatible
4
+ def communicate
5
+ vm.communicate
6
+ end
7
+
8
+ def driver
9
+ vm.provider.driver
10
+ end
11
+
12
+ def self.included(base)
13
+ base.extend(ClassMethods)
14
+ end
15
+
16
+ module ClassMethods
17
+ def vm_id(vm)
18
+ vm.id
19
+ end
20
+
21
+ def communicate_to(vm)
22
+ vm.communicate
23
+ end
24
+
25
+ def distro_name(vm)
26
+ vm.guest.distro_dispatch
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1 @@
1
+ require File.expand_path("../../vagrant_1_1/command", __FILE__)
@@ -0,0 +1,18 @@
1
+ require 'vagrant-vbguest/download'
2
+ require "vagrant/util/downloader"
3
+
4
+ module VagrantVbguest
5
+
6
+ class Download < DownloadBase
7
+
8
+ def download!
9
+ downloader_options = {}
10
+ downloader_options[:ui] = @ui
11
+ @ui.info(I18n.t("vagrant_vbguest.download.started", :source => @source))
12
+ @downloader = Vagrant::Util::Downloader.new(@source, @destination, downloader_options)
13
+ @downloader.download!
14
+ end
15
+
16
+ end
17
+
18
+ end
@@ -0,0 +1 @@
1
+ require File.expand_path("../../vagrant_1_1/rebootable", __FILE__)
@@ -0,0 +1,15 @@
1
+ require File.expand_path("../../vagrant_1_1/vm_compatible", __FILE__)
2
+ module VagrantVbguest
3
+ module Helpers
4
+ module VmCompatible
5
+ def self.included(base)
6
+ base.extend(ClassMethods)
7
+ end
8
+ module ClassMethods
9
+ def distro_name(vm)
10
+ vm.guest.name
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module VagrantVbguest
2
- VERSION = "0.7.1"
2
+ VERSION = "0.8.0"
3
3
  end
data/lib/vagrant_init.rb CHANGED
@@ -9,7 +9,7 @@ end
9
9
  require 'vagrant-vbguest/core_ext/string/interpolate'
10
10
 
11
11
  require "vagrant-vbguest/errors"
12
- require 'vagrant-vbguest/helpers'
12
+ require 'vagrant-vbguest/vagrant_compat'
13
13
 
14
14
  require 'vagrant-vbguest/machine'
15
15
 
@@ -27,8 +27,6 @@ require 'vagrant-vbguest/config'
27
27
  require 'vagrant-vbguest/command'
28
28
  require 'vagrant-vbguest/middleware'
29
29
 
30
- require 'vagrant-vbguest/download'
31
-
32
30
  Vagrant.config_keys.register(:vbguest) { VagrantVbguest::Config }
33
31
 
34
32
  Vagrant.commands.register(:vbguest) { VagrantVbguest::Command }
data/locales/en.yml CHANGED
@@ -1,59 +1,61 @@
1
1
  en:
2
- vagrant:
3
- plugins:
4
- vbguest:
5
- skipped_installation: "Updating GuestAdditions skipped."
6
- skipped_rebuild: "Rebuilding GuestAdditions skipped."
7
- installing: "Installing Virtualbox Guest Additions %{installer_version} - guest version is %{guest_version}"
8
- installing_forced: "Forcing installation of Virtualbox Guest Additions %{installer_version} - guest version is %{guest_version}"
9
- rebuild: "Rebuilding Virtualbox Guest Additions %{guest_version} (Your host version is %{host_version})"
10
- rebuild_forced: "Forcing rebuilding of Virtualbox Guest Additions %{guest_version} (Your host version is %{host_version})"
11
- install_error: "An error occurred during installation of VirtualBox Guest Additions %{installer_version}. Some functionality may not work as intended."
12
- start_copy_iso: "Copy iso file %{from} into the box %{to}"
13
- restart_vm: "Restarting VM to apply changes..."
14
- suggest_restart: "Guest Additions got installed. However, they seem not be loaded correctly. Please restart the box running `vagrant reload %{name}`"
15
- restart_loop_guard_activated: "Guest Additions will not load, even after reboot."
16
- machine_loop_guard: "Could not execute %{command} from current state %{state}. To prevent running in circles, we'll stop."
17
- guest_version_reports_differ: |-
18
- Got different reports about installed GuestAdditions version:
19
- Virtualbox on your host claims: %{driver}
20
- VBoxService inside the vm claims: %{service}
21
- Going on, assuming VBoxService is correct...
22
- unknown: unknown
2
+ vagrant_vbguest:
3
+ skipped_installation: "Updating GuestAdditions skipped."
4
+ skipped_rebuild: "Rebuilding GuestAdditions skipped."
5
+ installing: "Installing Virtualbox Guest Additions %{installer_version} - guest version is %{guest_version}"
6
+ installing_forced: "Forcing installation of Virtualbox Guest Additions %{installer_version} - guest version is %{guest_version}"
7
+ rebuild: "Rebuilding Virtualbox Guest Additions %{guest_version} (Your host version is %{host_version})"
8
+ rebuild_forced: "Forcing rebuilding of Virtualbox Guest Additions %{guest_version} (Your host version is %{host_version})"
9
+ install_error: "An error occurred during installation of VirtualBox Guest Additions %{installer_version}. Some functionality may not work as intended."
10
+ start_copy_iso: "Copy iso file %{from} into the box %{to}"
11
+ restart_vm: "Restarting VM to apply changes..."
12
+ suggest_restart: "Guest Additions got installed. However, they seem not be loaded correctly. Please restart the box running `vagrant reload %{name}`"
13
+ restart_loop_guard_activated: "Guest Additions will not load, even after reboot."
14
+ machine_loop_guard: "Could not execute %{command} from current state %{state}. To prevent running in circles, we'll stop."
15
+ guest_version_reports_differ: |-
16
+ Got different reports about installed GuestAdditions version:
17
+ Virtualbox on your host claims: %{driver}
18
+ VBoxService inside the vm claims: %{service}
19
+ Going on, assuming VBoxService is correct...
20
+ vagrant_11_reload_issues: |-
21
+ This version of vagrant has issues with reloading boxes. `auto_reboot` got disabled as a precaution.
22
+ Expect errors and run `vagrant halt` and `vagrant up` instead of `vagrant reload`!
23
+ unknown: unknown
23
24
 
24
- status:
25
- clean: "No installation found."
26
- unmatched: "GuestAdditions versions on your host (%{host_version}) and guest (%{guest_version}) do not match."
27
- not_running: "GuestAdditions seems to be installed (%{guest_version}) correctly, but not running."
28
- ok: "GuestAdditions %{guest_version} running --- OK."
25
+ status:
26
+ clean: "No installation found."
27
+ unmatched: "GuestAdditions versions on your host (%{host_version}) and guest (%{guest_version}) do not match."
28
+ not_running: "GuestAdditions seems to be installed (%{guest_version}) correctly, but not running."
29
+ ok: "GuestAdditions %{guest_version} running --- OK."
29
30
 
30
- errors:
31
- autodetect_iso_path: |-
32
- Could not locate a local Virtualbox Guest Additions iso file.
33
- Please configure a local path to the iso using `config.vbguest.iso_path`
34
- in your Vagrantfile or the `--iso` command line option.
35
- If you think this is a bug and vbguest could have guessed the iso_path,
36
- please file an issue at: https://github.com/dotless-de/vagrant-vbguest/issues
31
+ errors:
32
+ autodetect_iso_path: |-
33
+ Could not locate a local Virtualbox Guest Additions iso file.
34
+ Please configure a local path to the iso using `config.vbguest.iso_path`
35
+ in your Vagrantfile or the `--iso` command line option.
36
+ If you think this is a bug and vbguest could have guessed the iso_path,
37
+ please file an issue at: https://github.com/dotless-de/vagrant-vbguest/issues
37
38
 
38
- downloading_disabled: |-
39
- Could not locate a local Virtualbox Guest Additions iso file.
40
- However, the no_remote option was set and thus I will not download it from
41
- %{from}
42
- Please configure a local path to the iso using `config.vbguest.iso_path`
43
- in your Vagrantfile or the `--iso` command line option.
39
+ downloading_disabled: |-
40
+ Could not locate a local Virtualbox Guest Additions iso file.
41
+ However, the no_remote option was set and thus I will not download it from
42
+ %{from}
43
+ Please configure a local path to the iso using `config.vbguest.iso_path`
44
+ in your Vagrantfile or the `--iso` command line option.
44
45
 
45
- no_virtualbox_machine: |-
46
- The VBGuest plugin must be used with VirtualBox Machines only.
46
+ no_virtualbox_machine: |-
47
+ The VBGuest plugin must be used with VirtualBox Machines only.
47
48
 
48
- installer:
49
- no_installer_for_platform: |-
50
- Sorry, don't know how to %{method} Virtualbox Guest Additions on this platform. Stopping installation.
51
- generic_linux_installer: |-
52
- The guest's platform is currently not supported, will try generic Linux method...
53
- do_not_inherit_match_method: |-
54
- Installer classes must provide their own `match?` method.
49
+ installer:
50
+ no_installer_for_platform: |-
51
+ Sorry, don't know how to %{method} Virtualbox Guest Additions on this platform. Stopping installation.
52
+ generic_linux_installer: |-
53
+ The guest's platform is currently not supported, will try generic Linux method...
54
+ do_not_inherit_match_method: |-
55
+ Installer classes must provide their own `match?` method.
55
56
 
56
- download:
57
- with: "Downloading VirtualBox Guest Additions ISO with %{class}..."
58
- cleaning: "Cleaning up downloaded VirtualBox Guest Additions ISO..."
59
- unknown_type: "Unknown or unsupported URI type given for VirtualBox Guest Additions ISO download."
57
+ download:
58
+ started: "Downloading VirtualBox Guest Additions ISO from %{source}"
59
+ with: "Downloading VirtualBox Guest Additions ISO with %{class}..."
60
+ cleaning: "Cleaning up downloaded VirtualBox Guest Additions ISO..."
61
+ unknown_type: "Unknown or unsupported URI type given for VirtualBox Guest Additions ISO download."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-vbguest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-30 00:00:00.000000000 Z
12
+ date: 2013-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: micromachine
@@ -95,7 +95,6 @@ files:
95
95
  - lib/vagrant-vbguest/core_ext/string/interpolate.rb
96
96
  - lib/vagrant-vbguest/download.rb
97
97
  - lib/vagrant-vbguest/errors.rb
98
- - lib/vagrant-vbguest/helpers.rb
99
98
  - lib/vagrant-vbguest/hosts/base.rb
100
99
  - lib/vagrant-vbguest/hosts/virtualbox.rb
101
100
  - lib/vagrant-vbguest/installer.rb
@@ -106,6 +105,20 @@ files:
106
105
  - lib/vagrant-vbguest/installers/ubuntu.rb
107
106
  - lib/vagrant-vbguest/machine.rb
108
107
  - lib/vagrant-vbguest/middleware.rb
108
+ - lib/vagrant-vbguest/rebootable.rb
109
+ - lib/vagrant-vbguest/vagrant_compat.rb
110
+ - lib/vagrant-vbguest/vagrant_compat/vagrant_1_0/command.rb
111
+ - lib/vagrant-vbguest/vagrant_compat/vagrant_1_0/download.rb
112
+ - lib/vagrant-vbguest/vagrant_compat/vagrant_1_0/rebootable.rb
113
+ - lib/vagrant-vbguest/vagrant_compat/vagrant_1_0/vm_compatible.rb
114
+ - lib/vagrant-vbguest/vagrant_compat/vagrant_1_1/command.rb
115
+ - lib/vagrant-vbguest/vagrant_compat/vagrant_1_1/download.rb
116
+ - lib/vagrant-vbguest/vagrant_compat/vagrant_1_1/rebootable.rb
117
+ - lib/vagrant-vbguest/vagrant_compat/vagrant_1_1/vm_compatible.rb
118
+ - lib/vagrant-vbguest/vagrant_compat/vagrant_1_2/command.rb
119
+ - lib/vagrant-vbguest/vagrant_compat/vagrant_1_2/download.rb
120
+ - lib/vagrant-vbguest/vagrant_compat/vagrant_1_2/rebootable.rb
121
+ - lib/vagrant-vbguest/vagrant_compat/vagrant_1_2/vm_compatible.rb
109
122
  - lib/vagrant-vbguest/version.rb
110
123
  - lib/vagrant_init.rb
111
124
  - locales/en.yml
@@ -125,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
138
  version: '0'
126
139
  segments:
127
140
  - 0
128
- hash: -3661598601384978746
141
+ hash: -1570498090693693149
129
142
  required_rubygems_version: !ruby/object:Gem::Requirement
130
143
  none: false
131
144
  requirements:
@@ -1,61 +0,0 @@
1
- module VagrantVbguest
2
- module Helpers
3
-
4
- module Rebootable
5
- @@rebooted = {}
6
-
7
- def rebooted?(vm)
8
- !!@@rebooted[ VmCompatible.vm_id(vm) ]
9
- end
10
-
11
- def reboot(vm, options)
12
- run_reboot = if rebooted?(vm)
13
- vm.env.ui.error(I18n.t("vagrant.plugins.vbguest.restart_loop_guard_activated"))
14
- false
15
- elsif options[:auto_reboot]
16
- vm.env.ui.warn(I18n.t("vagrant.plugins.vbguest.restart_vm"))
17
- @@rebooted[ VmCompatible.vm_id(vm) ] = true
18
- else
19
- vm.env.ui.warn(I18n.t("vagrant.plugins.vbguest.suggest_restart", :name => vm.name))
20
- false
21
- end
22
- return unless run_reboot
23
-
24
- if Vagrant::VERSION < '1.1.0'
25
- vm.reload(options)
26
- else
27
- vm.action(:reload, options)
28
- end
29
- end
30
- end
31
-
32
- module VmCompatible
33
-
34
- if Vagrant::VERSION < '1.1.0'
35
- def communicate
36
- vm.channel
37
- end
38
-
39
- def driver
40
- vm.driver
41
- end
42
-
43
- def self.vm_id(vm)
44
- vm.uuid
45
- end
46
- else # Vagrant 1.1, and hopefully upwards
47
- def communicate
48
- vm.communicate
49
- end
50
-
51
- def driver
52
- vm.provider.driver
53
- end
54
-
55
- def self.vm_id(vm)
56
- vm.id
57
- end
58
- end
59
- end
60
- end
61
- end