vagrant 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/Gemfile +4 -4
  2. data/Rakefile +3 -3
  3. data/VERSION +1 -1
  4. data/bin/vagrant +5 -13
  5. data/config/default.rb +1 -0
  6. data/keys/README.md +8 -1
  7. data/keys/vagrant.ppk +26 -0
  8. data/lib/vagrant.rb +3 -3
  9. data/lib/vagrant/actions/base.rb +15 -4
  10. data/lib/vagrant/actions/box/add.rb +1 -1
  11. data/lib/vagrant/actions/box/download.rb +72 -66
  12. data/lib/vagrant/actions/box/unpackage.rb +1 -4
  13. data/lib/vagrant/actions/runner.rb +1 -1
  14. data/lib/vagrant/actions/vm/boot.rb +5 -7
  15. data/lib/vagrant/actions/vm/customize.rb +2 -2
  16. data/lib/vagrant/actions/vm/destroy.rb +2 -2
  17. data/lib/vagrant/actions/vm/down.rb +7 -0
  18. data/lib/vagrant/actions/vm/export.rb +10 -4
  19. data/lib/vagrant/actions/vm/forward_ports.rb +5 -15
  20. data/lib/vagrant/actions/vm/halt.rb +5 -3
  21. data/lib/vagrant/actions/vm/import.rb +10 -3
  22. data/lib/vagrant/actions/vm/move_hard_drive.rb +1 -3
  23. data/lib/vagrant/actions/vm/package.rb +33 -10
  24. data/lib/vagrant/actions/vm/provision.rb +4 -4
  25. data/lib/vagrant/actions/vm/reload.rb +1 -1
  26. data/lib/vagrant/actions/vm/resume.rb +1 -1
  27. data/lib/vagrant/actions/vm/shared_folders.rb +7 -7
  28. data/lib/vagrant/actions/vm/start.rb +3 -2
  29. data/lib/vagrant/actions/vm/suspend.rb +2 -2
  30. data/lib/vagrant/actions/vm/up.rb +7 -17
  31. data/lib/vagrant/active_list.rb +52 -45
  32. data/lib/vagrant/box.rb +18 -11
  33. data/lib/vagrant/busy.rb +7 -0
  34. data/lib/vagrant/command.rb +27 -0
  35. data/lib/vagrant/commands/base.rb +163 -0
  36. data/lib/vagrant/commands/box.rb +16 -0
  37. data/lib/vagrant/commands/box/add.rb +24 -0
  38. data/lib/vagrant/commands/box/list.rb +30 -0
  39. data/lib/vagrant/commands/box/remove.rb +31 -0
  40. data/lib/vagrant/commands/destroy.rb +23 -0
  41. data/lib/vagrant/commands/down.rb +16 -0
  42. data/lib/vagrant/commands/halt.rb +23 -0
  43. data/lib/vagrant/commands/init.rb +32 -0
  44. data/lib/vagrant/commands/package.rb +46 -0
  45. data/lib/vagrant/commands/reload.rb +22 -0
  46. data/lib/vagrant/commands/resume.rb +22 -0
  47. data/lib/vagrant/commands/ssh.rb +22 -0
  48. data/lib/vagrant/commands/ssh_config.rb +30 -0
  49. data/lib/vagrant/commands/status.rb +58 -0
  50. data/lib/vagrant/commands/suspend.rb +23 -0
  51. data/lib/vagrant/commands/up.rb +26 -0
  52. data/lib/vagrant/config.rb +21 -11
  53. data/lib/vagrant/downloaders/file.rb +5 -5
  54. data/lib/vagrant/downloaders/http.rb +10 -15
  55. data/lib/vagrant/environment.rb +259 -0
  56. data/lib/vagrant/provisioners/base.rb +7 -0
  57. data/lib/vagrant/provisioners/chef.rb +24 -9
  58. data/lib/vagrant/provisioners/chef_server.rb +23 -48
  59. data/lib/vagrant/provisioners/chef_solo.rb +48 -22
  60. data/lib/vagrant/ssh.rb +95 -46
  61. data/lib/vagrant/util.rb +2 -2
  62. data/lib/vagrant/util/errors.rb +36 -0
  63. data/lib/vagrant/util/platform.rb +12 -0
  64. data/lib/vagrant/util/progress_meter.rb +33 -0
  65. data/lib/vagrant/util/stacked_proc_runner.rb +35 -0
  66. data/lib/vagrant/util/template_renderer.rb +83 -0
  67. data/lib/vagrant/vm.rb +1 -0
  68. data/templates/{Vagrantfile → Vagrantfile.erb} +2 -2
  69. data/templates/chef_server_client.erb +16 -0
  70. data/templates/chef_solo_solo.erb +4 -0
  71. data/templates/errors.yml +157 -0
  72. data/templates/package_Vagrantfile.erb +11 -0
  73. data/templates/ssh_config.erb +7 -0
  74. data/test/test_helper.rb +12 -15
  75. data/test/vagrant/actions/box/add_test.rb +1 -2
  76. data/test/vagrant/actions/box/destroy_test.rb +0 -1
  77. data/test/vagrant/actions/box/download_test.rb +40 -15
  78. data/test/vagrant/actions/box/unpackage_test.rb +2 -3
  79. data/test/vagrant/actions/collection_test.rb +8 -5
  80. data/test/vagrant/actions/runner_test.rb +8 -6
  81. data/test/vagrant/actions/vm/boot_test.rb +12 -11
  82. data/test/vagrant/actions/vm/customize_test.rb +2 -3
  83. data/test/vagrant/actions/vm/destroy_test.rb +2 -3
  84. data/test/vagrant/actions/vm/down_test.rb +16 -3
  85. data/test/vagrant/actions/vm/export_test.rb +4 -5
  86. data/test/vagrant/actions/vm/forward_ports_test.rb +6 -5
  87. data/test/vagrant/actions/vm/halt_test.rb +8 -2
  88. data/test/vagrant/actions/vm/import_test.rb +5 -5
  89. data/test/vagrant/actions/vm/move_hard_drive_test.rb +4 -6
  90. data/test/vagrant/actions/vm/package_test.rb +60 -22
  91. data/test/vagrant/actions/vm/provision_test.rb +7 -16
  92. data/test/vagrant/actions/vm/reload_test.rb +3 -2
  93. data/test/vagrant/actions/vm/resume_test.rb +0 -1
  94. data/test/vagrant/actions/vm/shared_folders_test.rb +17 -12
  95. data/test/vagrant/actions/vm/start_test.rb +10 -3
  96. data/test/vagrant/actions/vm/suspend_test.rb +1 -2
  97. data/test/vagrant/actions/vm/up_test.rb +19 -11
  98. data/test/vagrant/active_list_test.rb +148 -129
  99. data/test/vagrant/box_test.rb +26 -14
  100. data/test/vagrant/busy_test.rb +15 -6
  101. data/test/vagrant/command_test.rb +53 -0
  102. data/test/vagrant/commands/base_test.rb +118 -0
  103. data/test/vagrant/commands/box/add_test.rb +34 -0
  104. data/test/vagrant/commands/box/list_test.rb +32 -0
  105. data/test/vagrant/commands/box/remove_test.rb +41 -0
  106. data/test/vagrant/commands/destroy_test.rb +32 -0
  107. data/test/vagrant/commands/down_test.rb +17 -0
  108. data/test/vagrant/commands/halt_test.rb +28 -0
  109. data/test/vagrant/commands/init_test.rb +55 -0
  110. data/test/vagrant/commands/package_test.rb +84 -0
  111. data/test/vagrant/commands/reload_test.rb +28 -0
  112. data/test/vagrant/commands/resume_test.rb +33 -0
  113. data/test/vagrant/commands/ssh_config_test.rb +54 -0
  114. data/test/vagrant/commands/ssh_test.rb +32 -0
  115. data/test/vagrant/commands/status_test.rb +20 -0
  116. data/test/vagrant/commands/suspend_test.rb +33 -0
  117. data/test/vagrant/commands/up_test.rb +41 -0
  118. data/test/vagrant/config_test.rb +42 -17
  119. data/test/vagrant/downloaders/file_test.rb +7 -0
  120. data/test/vagrant/downloaders/http_test.rb +12 -0
  121. data/test/vagrant/environment_test.rb +595 -0
  122. data/test/vagrant/provisioners/base_test.rb +7 -1
  123. data/test/vagrant/provisioners/chef_server_test.rb +41 -51
  124. data/test/vagrant/provisioners/chef_solo_test.rb +93 -62
  125. data/test/vagrant/provisioners/chef_test.rb +61 -15
  126. data/test/vagrant/ssh_test.rb +166 -38
  127. data/test/vagrant/util/errors_test.rb +57 -0
  128. data/test/vagrant/util/progress_meter_test.rb +33 -0
  129. data/test/vagrant/{stacked_proc_runner_test.rb → util/stacked_proc_runner_test.rb} +3 -3
  130. data/test/vagrant/util/template_renderer_test.rb +138 -0
  131. data/test/vagrant/vm_test.rb +3 -2
  132. data/vagrant.gemspec +88 -33
  133. metadata +94 -51
  134. data/bin/vagrant-box +0 -34
  135. data/bin/vagrant-down +0 -27
  136. data/bin/vagrant-halt +0 -28
  137. data/bin/vagrant-init +0 -27
  138. data/bin/vagrant-package +0 -29
  139. data/bin/vagrant-reload +0 -29
  140. data/bin/vagrant-resume +0 -27
  141. data/bin/vagrant-ssh +0 -27
  142. data/bin/vagrant-status +0 -29
  143. data/bin/vagrant-suspend +0 -27
  144. data/bin/vagrant-up +0 -29
  145. data/lib/vagrant/commands.rb +0 -234
  146. data/lib/vagrant/env.rb +0 -189
  147. data/lib/vagrant/stacked_proc_runner.rb +0 -33
  148. data/test/vagrant/commands_test.rb +0 -269
  149. data/test/vagrant/env_test.rb +0 -418
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
1
  source :gemcutter
2
2
 
3
3
  # Gems required for the lib to even run
4
- gem "virtualbox", ">= 0.5.3"
4
+ gem "virtualbox", "~> 0.6.0"
5
5
  gem "net-ssh", ">= 2.0.19"
6
6
  gem "net-scp", ">= 1.0.2"
7
- gem "git-style-binaries", ">= 0.1.10"
8
- gem "json", ">= 1.2.0"
9
- gem "archive-tar-minitar", ">= 0.5.2"
7
+ gem "json_pure", ">= 1.2.0"
8
+ gem "archive-tar-minitar", "= 0.5.2"
9
+ gem "mario", "~> 0.0.6"
10
10
 
11
11
  # Gems required for testing only. To install run
12
12
  # gem bundle test
data/Rakefile CHANGED
@@ -10,12 +10,12 @@ begin
10
10
  gemspec.homepage = "http://github.com/mitchellh/vagrant"
11
11
  gemspec.authors = ["Mitchell Hashimoto", "John Bender"]
12
12
 
13
- gemspec.add_dependency('virtualbox', '>= 0.5.3')
13
+ gemspec.add_dependency('virtualbox', '~> 0.6.0')
14
14
  gemspec.add_dependency('net-ssh', '>= 2.0.19')
15
15
  gemspec.add_dependency('net-scp', '>= 1.0.2')
16
- gemspec.add_dependency('json', '>= 1.2.0')
17
- gemspec.add_dependency('git-style-binaries', '>= 0.1.10')
16
+ gemspec.add_dependency('json_pure', '>= 1.2.0')
18
17
  gemspec.add_dependency('archive-tar-minitar', '= 0.5.2')
18
+ gemspec.add_dependency('mario', '~> 0.0.6')
19
19
  end
20
20
  Jeweler::GemcutterTasks.new
21
21
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -1,15 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- begin
3
- require File.expand_path('../../.bundle/environment', __FILE__)
4
- rescue LoadError
5
- # Fallback on rubygems
6
- require "rubygems"
7
- end
2
+ # Get library
3
+ libdir = File.join(File.dirname(__FILE__), '..', 'lib')
4
+ require File.expand_path('vagrant', libdir)
8
5
 
9
- require 'git-style-binary/command'
10
-
11
- GitStyleBinary.primary do
12
- version "0.2.0"
13
-
14
- run { educate }
15
- end
6
+ # Call the command
7
+ Vagrant::Command.execute(*ARGV)
@@ -20,6 +20,7 @@ Vagrant::Config.run do |config|
20
20
  config.vm.provisioner = nil
21
21
  config.vm.shared_folder_uid = nil
22
22
  config.vm.shared_folder_gid = nil
23
+ config.vm.boot_mode = "vrdp"
23
24
 
24
25
  config.package.name = 'vagrant'
25
26
  config.package.extension = '.box'
@@ -7,4 +7,11 @@ vagrant installations can automatically SSH into the boxes.
7
7
  If you're working with a team or company or with a custom box and
8
8
  you want more secure SSH, you should create your own keypair
9
9
  and configure the private key in the Vagrantfile with
10
- `config.ssh.private_key_path`
10
+ `config.ssh.private_key_path`
11
+
12
+ # Putty
13
+
14
+ If you are using Vagrant on windows, the .ppk file contained here, in the keys directory,
15
+ has been generated from the private key and should be used to connect Putty to any VMs that
16
+ are leveraging the default key pair. See [guide](http://vagrantup.com/docs/getting-started/windows.html)
17
+ in the documentation for more details on using Putty with Vagrant.
@@ -0,0 +1,26 @@
1
+ PuTTY-User-Key-File-2: ssh-rsa
2
+ Encryption: none
3
+ Comment: imported-openssh-key
4
+ Public-Lines: 6
5
+ AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+k
6
+ z4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdO
7
+ KLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4
8
+ O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGj
9
+ yiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPK
10
+ cF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ==
11
+ Private-Lines: 14
12
+ AAABAQDiKpY8le3NkDryYp0QuziMmx3KTL57B1l412zm2NycdTnNRgTbkr598kQP
13
+ 2pRYgJwtkNzzVMZaMfICoPUHDtemBTAWB5QnBSXNC6sC/7/JKfGLC5oYl+EUzUJp
14
+ AfN9emGBWaX59lS+clRO/N9MrYuDoR1tQT1NqtSUF//E9+4SExKUgTmR5v9nPf8t
15
+ SVGDzIOrPnD5BZUni62cqcqKrBk3SbCnBTthLImGVPhhXUXefhiMuzAznAmzaiqb
16
+ SOyxC78FPS3IRc0NgEsQXgCwKVpa5InaSOrsqGuthfNqCqGdJ6L04NgVKEm7xRZV
17
+ 5zciFvlleXM7q901DUn1ex/ib7bLAAAAgQD6qFxx/Rv9CNN96l/4rb14HKirC2o/
18
+ orApiHmHDsURs5rUKDx0f9iPcXN7S1uePXuJRK/5hsubaOCx3Owd2u9gD6Oq0CsM
19
+ kE4CUSiJcYrMANtx54cGH7RkEjFZxK8xAv1ldELEyxrFqkbE4BKd8QOt414qjvTG
20
+ yAK+OLD3M2QdCQAAAIEA7cfKTQgMUe8oR2yFk9QB+uvl1jfG16u5d0Tv7pHmnIvf
21
+ CX5G5MVEWYbcVfxx7r1IZzy3V908MoDwWGRTaOKc1RIc1qE7ZxLaxbniscnN/i42
22
+ abqPpgZUOjkbX4JK/YAVaYV2RmBM5Ag95VXZfC+HMPQVaSqyQrNXObWhow4HSJ0A
23
+ AACANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH+vq/
24
+ 5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQNE5O
25
+ gEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s=
26
+ Private-MAC: bc710f345e67c736d57dd72aab10fe4625345dae
@@ -3,13 +3,13 @@ PROJECT_ROOT = File.join(libdir, '..') unless defined?(PROJECT_ROOT)
3
3
 
4
4
  # The libs which must be loaded prior to the rest
5
5
  %w{tempfile open-uri json pathname logger uri net/http virtualbox net/ssh archive/tar/minitar
6
- net/scp fileutils}.each do |lib|
6
+ net/scp fileutils mario}.each do |lib|
7
7
  require lib
8
8
  end
9
9
 
10
10
  # The vagrant specific files which must be loaded prior to the rest
11
- %w{vagrant/util vagrant/stacked_proc_runner vagrant/actions/base vagrant/downloaders/base vagrant/actions/collection
12
- vagrant/actions/runner vagrant/config vagrant/provisioners/base vagrant/provisioners/chef}.each do |f|
11
+ %w{vagrant/util vagrant/util/stacked_proc_runner vagrant/util/progress_meter vagrant/actions/base vagrant/downloaders/base vagrant/actions/collection
12
+ vagrant/actions/runner vagrant/config vagrant/provisioners/base vagrant/provisioners/chef vagrant/commands/base vagrant/commands/box}.each do |f|
13
13
  require File.expand_path(f, libdir)
14
14
  end
15
15
 
@@ -84,15 +84,15 @@ module Vagrant
84
84
  def rescue(exception); end
85
85
 
86
86
  # The following two methods are used for declaring action dependencies.
87
- # For example, you require that the reload action be in place before
87
+ # For example, you require that the reload action be in place before
88
88
  # a your new FooAction you might do the following
89
89
  #
90
90
  # def follows; [Reload] end
91
-
91
+
92
92
  # This method is called when the runner is determining the actions that
93
93
  # must precede a given action. You would say "This action follows [Action1, Action2]"
94
94
  def follows; [] end
95
-
95
+
96
96
  # This method is called when the runner is determining the actions that
97
97
  # must follow a given action. You would say "This action precedes [Action3, Action4]
98
98
  def precedes; [] end
@@ -102,6 +102,17 @@ module Vagrant
102
102
  # {Vagrant::Util#error_and_exit error_and_exit}, since it allows the {Runner} to call
103
103
  # {Base#rescue rescue} on all the actions and properly exit. Any message
104
104
  # passed into the {ActionException} is then shown and and vagrant exits.
105
- class ActionException < Exception; end
105
+ class ActionException < Exception
106
+ attr_reader :key
107
+ attr_reader :data
108
+
109
+ def initialize(key, data = {})
110
+ @key = key
111
+ @data = data
112
+
113
+ message = Vagrant::Util::Errors.error_string(key, data)
114
+ super(message)
115
+ end
116
+ end
106
117
  end
107
118
  end
@@ -10,7 +10,7 @@ module Vagrant
10
10
  class Add < Base
11
11
  def prepare
12
12
  if File.exists?(@runner.directory)
13
- raise ActionException.new("A box with the name '#{@runner.name}' already exists, please use another name or use `vagrant box remove #{@runner.name}`")
13
+ raise ActionException.new(:box_add_already_exists, :box_name => @runner.name)
14
14
  end
15
15
 
16
16
  @runner.add_action(Download)
@@ -1,66 +1,72 @@
1
- module Vagrant
2
- module Actions
3
- module Box
4
- # An action which acts on a box by downloading the box file from
5
- # the given URI into a temporary location. This action parses a
6
- # given URI and handles downloading it via one of the many Vagrant
7
- # downloads (such as {Vagrant::Downloaders::File}).
8
- #
9
- # This action cleans itself up by removing the downloaded box file.
10
- class Download < Base
11
- BASENAME = "box"
12
- BUFFERSIZE = 1048576 # 1 MB
13
-
14
- attr_reader :downloader
15
-
16
- def prepare
17
- # Parse the URI given and prepare a downloader
18
- uri = URI.parse(@runner.uri)
19
- uri_map = [[URI::HTTP, Downloaders::HTTP], [URI::Generic, Downloaders::File]]
20
-
21
- uri_map.find do |uri_type, downloader_klass|
22
- if uri.is_a?(uri_type)
23
- logger.info "#{uri_type} for URI, downloading via #{downloader_klass}..."
24
- @downloader = downloader_klass.new
25
- end
26
- end
27
-
28
- raise ActionException.new("Unknown URI type for box download.") unless @downloader
29
-
30
- # Prepare the downloader
31
- @downloader.prepare(@runner.uri)
32
- end
33
-
34
- def execute!
35
- with_tempfile do |tempfile|
36
- download_to(tempfile)
37
- @runner.temp_path = tempfile.path
38
- end
39
- end
40
-
41
- def cleanup
42
- if @runner.temp_path && File.exist?(@runner.temp_path)
43
- logger.info "Cleaning up downloaded box..."
44
- File.unlink(@runner.temp_path)
45
- end
46
- end
47
-
48
- def rescue(exception)
49
- cleanup
50
- end
51
-
52
- def with_tempfile
53
- logger.info "Creating tempfile for storing box file..."
54
- Tempfile.open(BASENAME, Env.tmp_path) do |tempfile|
55
- yield tempfile
56
- end
57
- end
58
-
59
- def download_to(f)
60
- logger.info "Copying box to temporary location..."
61
- downloader.download!(@runner.uri, f)
62
- end
63
- end
64
- end
65
- end
66
- end
1
+ module Vagrant
2
+ module Actions
3
+ module Box
4
+ # An action which acts on a box by downloading the box file from
5
+ # the given URI into a temporary location. This action parses a
6
+ # given URI and handles downloading it via one of the many Vagrant
7
+ # downloads (such as {Vagrant::Downloaders::File}).
8
+ #
9
+ # This action cleans itself up by removing the downloaded box file.
10
+ class Download < Base
11
+ BASENAME = "box"
12
+ BUFFERSIZE = 1048576 # 1 MB
13
+
14
+ attr_reader :downloader
15
+
16
+ def prepare
17
+ # Check the URI given and prepare a downloader
18
+ [Downloaders::HTTP, Downloaders::File].each do |dler|
19
+ if dler.match?(@runner.uri)
20
+ logger.info "Downloading via #{dler}..."
21
+ @downloader = dler.new
22
+ end
23
+ end
24
+
25
+ raise ActionException.new(:box_download_unknown_type) unless @downloader
26
+
27
+ # Prepare the downloader
28
+ @downloader.prepare(@runner.uri)
29
+ end
30
+
31
+ def execute!
32
+ with_tempfile do |tempfile|
33
+ download_to(tempfile)
34
+ @runner.temp_path = tempfile.path
35
+ end
36
+ end
37
+
38
+ def cleanup
39
+ if @runner.temp_path && File.exist?(@runner.temp_path)
40
+ logger.info "Cleaning up downloaded box..."
41
+ File.unlink(@runner.temp_path)
42
+ end
43
+ end
44
+
45
+ def rescue(exception)
46
+ cleanup
47
+ end
48
+
49
+ def with_tempfile
50
+ logger.info "Creating tempfile for storing box file..."
51
+ File.open(box_temp_path, file_options) do |tempfile|
52
+ yield tempfile
53
+ end
54
+ end
55
+
56
+ def file_options
57
+ # create, write only, fail if the file exists, binary if windows
58
+ File::WRONLY|File::EXCL|File::CREAT|(Mario::Platform.windows? ? File::BINARY : 0)
59
+ end
60
+
61
+ def box_temp_path
62
+ File.join(@runner.env.tmp_path, BASENAME + Time.now.to_i.to_s)
63
+ end
64
+
65
+ def download_to(f)
66
+ logger.info "Copying box to temporary location..."
67
+ downloader.download!(@runner.uri, f)
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -21,10 +21,7 @@ module Vagrant
21
21
 
22
22
  def setup_box_dir
23
23
  if File.directory?(box_dir)
24
- error_and_exit(<<-msg)
25
- This box appears to already exist! Please call `vagrant box remove #{@runner.name}`
26
- and then try to add it again.
27
- msg
24
+ error_and_exit(:box_already_exists, :box_name => @runner.name)
28
25
  end
29
26
 
30
27
  FileUtils.mkdir_p(box_dir)
@@ -94,7 +94,7 @@ module Vagrant
94
94
 
95
95
  # If its an ActionException, error and exit the message
96
96
  if e.is_a?(ActionException)
97
- error_and_exit(e.message)
97
+ error_and_exit(e.key, e.data)
98
98
  return
99
99
  end
100
100
 
@@ -3,7 +3,7 @@ module Vagrant
3
3
  module VM
4
4
  class Boot < Base
5
5
  def prepare
6
- Vagrant.config.vm.share_folder("vagrant-root", Vagrant.config.vm.project_directory, Env.root_path)
6
+ @runner.env.config.vm.share_folder("v-root", @runner.env.config.vm.project_directory, @runner.env.root_path)
7
7
  end
8
8
 
9
9
  def execute!
@@ -14,25 +14,23 @@ module Vagrant
14
14
  # Wait for it to complete booting, or error if we could
15
15
  # never detect it booted up successfully
16
16
  if !wait_for_boot
17
- error_and_exit(<<-error)
18
- Failed to connect to VM! Failed to boot?
19
- error
17
+ error_and_exit(:vm_failed_to_boot)
20
18
  end
21
19
  end
22
20
  end
23
21
 
24
22
  def boot
25
23
  logger.info "Booting VM..."
26
- @runner.vm.start(:headless, true)
24
+ @runner.vm.start(@runner.env.config.vm.boot_mode)
27
25
  end
28
26
 
29
27
  def wait_for_boot(sleeptime=5)
30
28
  logger.info "Waiting for VM to boot..."
31
29
 
32
- Vagrant.config[:ssh][:max_tries].to_i.times do |i|
30
+ @runner.env.config.ssh.max_tries.to_i.times do |i|
33
31
  logger.info "Trying to connect (attempt ##{i+1} of #{Vagrant.config[:ssh][:max_tries]})..."
34
32
 
35
- if Vagrant::SSH.up?
33
+ if @runner.env.ssh.up?
36
34
  logger.info "VM booted and ready for use!"
37
35
  return true
38
36
  end
@@ -6,10 +6,10 @@ module Vagrant
6
6
  logger.info "Running any VM customizations..."
7
7
 
8
8
  # Run the customization procs over the VM
9
- Vagrant.config.vm.run_procs!(@runner.vm)
9
+ @runner.env.config.vm.run_procs!(@runner.vm)
10
10
 
11
11
  # Save the vm
12
- @runner.vm.save(true)
12
+ @runner.vm.save
13
13
  end
14
14
  end
15
15
  end
@@ -11,11 +11,11 @@ module Vagrant
11
11
 
12
12
  def destroy_vm
13
13
  logger.info "Destroying VM and associated drives..."
14
- @runner.vm.destroy(:destroy_image => true)
14
+ @runner.vm.destroy(:destroy_medium => :delete)
15
15
  end
16
16
 
17
17
  def depersist
18
- Env.depersist_vm(@runner)
18
+ @runner.env.depersist_vm
19
19
  end
20
20
  end
21
21
  end
@@ -6,6 +6,13 @@ module Vagrant
6
6
  @runner.add_action(Halt) if @runner.vm.running?
7
7
  @runner.add_action(Destroy)
8
8
  end
9
+
10
+ def after_halt
11
+ # This sleep is necessary to wait for the GUI to clean itself up.
12
+ # There appears to be nothing in the API that does this "wait"
13
+ # for us.
14
+ Kernel.sleep(1) if @runner.env.config.vm.boot_mode == "gui"
15
+ end
9
16
  end
10
17
  end
11
18
  end
@@ -2,6 +2,8 @@ module Vagrant
2
2
  module Actions
3
3
  module VM
4
4
  class Export < Base
5
+ include Util::ProgressMeter
6
+
5
7
  attr_reader :temp_dir
6
8
 
7
9
  def execute!
@@ -21,19 +23,23 @@ module Vagrant
21
23
  end
22
24
 
23
25
  def setup_temp_dir
24
- @temp_dir = File.join(Env.tmp_path, Time.now.to_i.to_s)
26
+ @temp_dir = File.join(@runner.env.tmp_path, Time.now.to_i.to_s)
25
27
 
26
28
  logger.info "Creating temporary directory for export..."
27
29
  FileUtils.mkpath(temp_dir)
28
30
  end
29
31
 
30
32
  def ovf_path
31
- File.join(temp_dir, Vagrant.config.vm.box_ovf)
33
+ File.join(temp_dir, @runner.env.config.vm.box_ovf)
32
34
  end
33
35
 
34
36
  def export
35
- logger.info "Exporting VM to #{ovf_path} ..."
36
- @runner.vm.export(ovf_path, {}, true)
37
+ logger.info "Exporting VM to #{ovf_path}..."
38
+ @runner.vm.export(ovf_path) do |progress|
39
+ update_progress(progress, 100, false)
40
+ end
41
+
42
+ complete_progress
37
43
  end
38
44
  end
39
45
  end