vagrant-vbguest 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ ## 0.5.1 (2012-11-30)
2
+
3
+ - Fix: Provisioning will not run twice when rebooted due
4
+ to incomplete GuestAdditions installation [GH-27]
5
+ (thanks @gregsymons for pointing)
6
+
1
7
  ## 0.5.0 (2012-11-19)
2
8
 
3
9
  - Box will be rebooted if the GuestAdditions installation
data/Readme.md CHANGED
@@ -158,6 +158,13 @@ The `auto-reboot` is tured off by default, when running as a command. Vbguest wi
158
158
  $ vagrant vbguest --auto-reboot
159
159
  ```
160
160
 
161
+ You can also pass vagrant's `reload` options like:
162
+
163
+ ```bash
164
+ $ vagrant vbguest --auto-reboot --no-provision
165
+ ```
166
+
167
+
161
168
 
162
169
  ### ISO autodetection
163
170
 
@@ -1,8 +1,11 @@
1
1
  require 'optparse'
2
+ require 'vagrant/command/start_mixins'
2
3
 
3
4
  module VagrantVbguest
4
5
 
5
6
  class Command < Vagrant::Command::Base
7
+ include Vagrant::Command::StartMixins
8
+ include VagrantVbguest::Helpers::Rebootable
6
9
 
7
10
  # Runs the vbguest installer on the VMs that are represented
8
11
  # by this environment.
@@ -33,6 +36,8 @@ module VagrantVbguest
33
36
  opts.on("--iso file_or_uri", "Full path or URI to the VBoxGuestAdditions.iso") do |file_or_uri|
34
37
  options[:iso_path] = file_or_uri
35
38
  end
39
+
40
+ build_start_options(opts, options)
36
41
  end
37
42
 
38
43
  argv = parse_options(opts)
@@ -54,6 +59,13 @@ module VagrantVbguest
54
59
  def execute_on_vm(vm, options)
55
60
  options = vm.config.vbguest.to_hash.merge(options)
56
61
  VagrantVbguest::Installer.new(vm, options).run!
62
+ reboot(vm, options) if need_reboot?(vm)
63
+ end
64
+
65
+ def reboot vm, options
66
+ if super
67
+ vm.reload(options)
68
+ end
57
69
  end
58
70
  end
59
71
  end
@@ -37,5 +37,29 @@ module VagrantVbguest
37
37
  end
38
38
 
39
39
  end
40
+
41
+ module Rebootable
42
+ @@rebooted = {}
43
+
44
+ def rebooted?(vm)
45
+ !!@@rebooted[vm.name]
46
+ end
47
+
48
+ def need_reboot?(vm)
49
+ !VagrantVbguest::Helpers.kernel_module_running?(vm)
50
+ end
51
+
52
+ def reboot(vm, options)
53
+ if options[:auto_reboot]
54
+ vm.ui.warn(I18n.t("vagrant.plugins.vbguest.restart_vm"))
55
+ @@rebooted[vm.name] = true
56
+ true
57
+ else
58
+ @vm.ui.warn(I18n.t("vagrant.plugins.vbguest.suggest_restart", :name => vm.name))
59
+ false
60
+ end
61
+ end
62
+ end
63
+
40
64
  end
41
65
  end
@@ -3,7 +3,6 @@ module VagrantVbguest
3
3
  # Handles the guest addins installation process
4
4
 
5
5
  class Installer
6
- @@rebooted = {}
7
6
 
8
7
  def initialize(vm, options = {})
9
8
  @env = {
@@ -32,12 +31,8 @@ module VagrantVbguest
32
31
  @vm.ui.warn(I18n.t("vagrant.plugins.vbguest.check_failed", :host => vb_version, :guest => guest_version)) if @options[:no_install]
33
32
 
34
33
  if @options[:force] || (!@options[:no_install] && needs_update?)
35
- if rebooted?
36
- @vm.ui.error(I18n.t("vagrant.plugins.vbguest.restart_loop_guard_activated"))
37
- else
38
- @vm.ui.warn(I18n.t("vagrant.plugins.vbguest.installing#{@options[:force] ? '_forced' : ''}", :host => vb_version, :guest => guest_version))
39
- install
40
- end
34
+ @vm.ui.warn(I18n.t("vagrant.plugins.vbguest.installing#{@options[:force] ? '_forced' : ''}", :host => vb_version, :guest => guest_version))
35
+ install
41
36
  end
42
37
  ensure
43
38
  cleanup
@@ -67,26 +62,9 @@ module VagrantVbguest
67
62
  end
68
63
 
69
64
  cleanup
70
- reboot
71
65
  end
72
66
  end
73
67
 
74
- def reboot
75
- if !VagrantVbguest::Helpers.kernel_module_running?(@vm)
76
- if @options[:auto_reboot]
77
- @vm.ui.warn(I18n.t("vagrant.plugins.vbguest.restart_vm"))
78
- @@rebooted[@vm.name] = true
79
- @vm.reload(@options[:run_env])
80
- else
81
- @vm.ui.warn(I18n.t("vagrant.plugins.vbguest.suggest_restart", :name => @vm.name))
82
- end
83
- end
84
- end
85
-
86
- def rebooted?
87
- !!@@rebooted[@vm.name]
88
- end
89
-
90
68
  def needs_update?
91
69
  !(guest_version && vb_version == guest_version)
92
70
  end
@@ -5,6 +5,8 @@ module VagrantVbguest
5
5
  # host system.
6
6
 
7
7
  class Middleware
8
+ include VagrantVbguest::Helpers::Rebootable
9
+
8
10
  def initialize(app, env, options = {})
9
11
  @app = app
10
12
  @env = env
@@ -13,11 +15,25 @@ module VagrantVbguest
13
15
 
14
16
  def call(env)
15
17
  options = @vm.config.vbguest.to_hash
16
- options[:run_env] = env
17
18
  VagrantVbguest::Installer.new(@vm, options).run
18
19
 
20
+ if need_reboot?(@vm)
21
+ if rebooted?(@vm)
22
+ @vm.ui.error(I18n.t("vagrant.plugins.vbguest.restart_loop_guard_activated"))
23
+ else
24
+ reboot(@vm, options) if need_reboot?(@vm)
25
+ end
26
+ end
27
+
19
28
  @app.call(env)
20
29
  end
21
30
 
31
+ def reboot vm, options
32
+ if super
33
+ @env[:action_runner].run(Vagrant::Action::VM::Halt, @env)
34
+ @env[:action_runner].run(Vagrant::Action::VM::Boot, @env)
35
+ end
36
+ end
37
+
22
38
  end
23
39
  end
@@ -1,3 +1,3 @@
1
1
  module VagrantVbguest
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
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.5.0
4
+ version: 0.5.1
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: 2012-11-19 00:00:00.000000000 Z
12
+ date: 2012-11-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler