vagrantup 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3304b65afaca240d89ee451787ce3866c934ba3c
4
- data.tar.gz: 1b1626fddeb5369a91de4c1c7ba698c0a2bf280e
3
+ metadata.gz: 9e371c7a61dc9b8d9400cec30e3ebbbc1cfdd1b0
4
+ data.tar.gz: 312202b025df0c9526443a07fdac7ebe12a66b7f
5
5
  SHA512:
6
- metadata.gz: 3387e49f37c3400b4ba9ae9c2dc62ca293f5aa71143225f2e2ea3c7f8af30db37b81494af98587cf890f80869b5857834a0ad2e2fbfeca9ca0a5b745cf6d4a2c
7
- data.tar.gz: 2b32d38c8879d78f243f4d72b1e3f8600a701d6d3c8b77a7d22fdaec0664f03d2cb5d4e53ad292d5105682fc29bbf0f0401790549e3e9c0d1147e1777293fe13
6
+ metadata.gz: 06be04e82de2eb5bdde3c8a1461638b4861ba5d18924290d803c71248daad60a9474a38dc3baeda5dd5b3637f586dd4bc26cd823bdf0b639dbec06fd7fd82c8d
7
+ data.tar.gz: 34df0d3207ede54215a099f1a5ae60b89c4e05cd2f655106cb4ae4a1e5fad538432c5a1ae53d6a0fe8782d6c566a7cdc3c5a11982feb2fbfa45f2c97d8267971
@@ -1,3 +1,23 @@
1
+ ## 1.0.1 (March 11, 2012)
2
+
3
+ - Fix crashing issue which manifested itself in multi-VM environments.
4
+ - Add missing `rubygems` require in `environment.rb` to avoid
5
+ possible load errors. [GH-781]
6
+ - `vagrant destroy` shows a nice error when called without a
7
+ TTY (and hence can't confirm). [GH-779]
8
+ - Fix an issue with the `:vagrantfile_name` option to `Vagrant::Environment`
9
+ not working properly. [GH-778]
10
+ - `VAGRANT_CWD` environmental variable can be used to set the CWD to
11
+ something other than the current directory.
12
+ - Downloading boxes from servers that don't send a content-length
13
+ now works properly. [GH-788]
14
+ - The `:facter` option now works for puppet server. [GH-790]
15
+ - The `--no-provision` and `--provision-with` flags are available to
16
+ `vagrant reload` now.
17
+ - `:openbsd` guest which supports only halting at the moment. [GH-773]
18
+ - `ssh-config -h` now shows help, instead of assuming a host is being
19
+ specified. For host, you can still use `--host`. [GH-793]
20
+
1
21
  ## 1.0.0 (March 6, 2012)
2
22
 
3
23
  - `vagrant gem` should now be used to install Vagrant plugins that are
@@ -178,6 +178,7 @@ Vagrant.guests.register(:fedora) { Vagrant::Guest::Fedora }
178
178
  Vagrant.guests.register(:freebsd) { Vagrant::Guest::FreeBSD }
179
179
  Vagrant.guests.register(:gentoo) { Vagrant::Guest::Gentoo }
180
180
  Vagrant.guests.register(:linux) { Vagrant::Guest::Linux }
181
+ Vagrant.guests.register(:openbsd) { Vagrant::Guest::OpenBSD }
181
182
  Vagrant.guests.register(:redhat) { Vagrant::Guest::Redhat }
182
183
  Vagrant.guests.register(:solaris) { Vagrant::Guest::Solaris }
183
184
  Vagrant.guests.register(:suse) { Vagrant::Guest::Suse }
@@ -30,8 +30,15 @@ module Vagrant
30
30
  if options[:force]
31
31
  do_destroy = true
32
32
  else
33
- choice = @env.ui.ask(I18n.t("vagrant.commands.destroy.confirmation",
34
- :name => vm.name))
33
+ choice = nil
34
+ begin
35
+ choice = @env.ui.ask(I18n.t("vagrant.commands.destroy.confirmation",
36
+ :name => vm.name))
37
+ rescue Errors::UIExpectsTTY
38
+ # We raise a more specific error but one which basically
39
+ # means the same thing.
40
+ raise Errors::DestroyRequiresForce
41
+ end
35
42
  do_destroy = choice.upcase == "Y"
36
43
  end
37
44
 
@@ -1,13 +1,18 @@
1
1
  require 'optparse'
2
2
 
3
+ require 'vagrant/command/start_mixins'
4
+
3
5
  module Vagrant
4
6
  module Command
5
7
  class Reload < Base
8
+ include StartMixins
9
+
6
10
  def execute
7
11
  options = {}
8
-
9
12
  opts = OptionParser.new do |opts|
10
13
  opts.banner = "Usage: vagrant reload [vm-name]"
14
+ opts.separator ""
15
+ build_start_options(opts, options)
11
16
  end
12
17
 
13
18
  # Parse the options
@@ -18,7 +23,7 @@ module Vagrant
18
23
  with_target_vms(argv[0]) do |vm|
19
24
  if vm.created?
20
25
  @logger.info("Reloading: #{vm.name}")
21
- vm.reload
26
+ vm.reload(options)
22
27
  else
23
28
  @logger.info("Not created: #{vm.name}. Not reloading.")
24
29
  vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
@@ -11,7 +11,7 @@ module Vagrant
11
11
 
12
12
  opts.separator ""
13
13
 
14
- opts.on("-h", "--host COMMAND", "Name the host for the config..") do |h|
14
+ opts.on("--host COMMAND", "Name the host for the config..") do |h|
15
15
  options[:host] = h
16
16
  end
17
17
  end
@@ -0,0 +1,26 @@
1
+ module Vagrant
2
+ module Command
3
+ module StartMixins
4
+ # This adds the standard `start` command line flags to the given
5
+ # OptionParser, storing the result in the `options` dictionary.
6
+ #
7
+ # @param [OptionParser] parser
8
+ # @param [Hash] options
9
+ def build_start_options(parser, options)
10
+ # Setup the defaults
11
+ options["provision.enabled"] = true
12
+ options["provision.types"] = nil
13
+
14
+ # Add the options
15
+ parser.on("--[no-]provision", "Enable or disable provisioning") do |p|
16
+ options["provision.enabled"] = p
17
+ end
18
+
19
+ parser.on("--provision-with x,y,z", Array,
20
+ "Enable only certain provisioners, by type.") do |list|
21
+ options["provision.types"] = list
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,49 +1,34 @@
1
1
  require 'optparse'
2
2
 
3
+ require 'vagrant/command/start_mixins'
4
+
3
5
  module Vagrant
4
6
  module Command
5
7
  class Up < Base
6
- def execute
7
- options = {
8
- :provision => true,
9
- :provisioners => nil
10
- }
8
+ include StartMixins
11
9
 
10
+ def execute
11
+ options = {}
12
12
  opts = OptionParser.new do |opts|
13
13
  opts.banner = "Usage: vagrant up [vm-name] [--[no-]provision] [-h]"
14
-
15
14
  opts.separator ""
16
-
17
- opts.on("--[no-]provision", "Enable or disable provisioning") do |p|
18
- options[:provision] = p
19
- end
20
-
21
- opts.on("--provision-with x,y,z", Array,
22
- "Enable only certain provisioners, by type.") do |list|
23
- options[:provisioners] = list
24
- end
15
+ build_start_options(opts, options)
25
16
  end
26
17
 
27
18
  # Parse the options
28
19
  argv = parse_options(opts)
29
20
  return if !argv
30
21
 
31
- # Parameters to send to actions
32
- action_params = {
33
- "provision.enabled" => options[:provision],
34
- "provision.types" => options[:provisioners]
35
- }
36
-
37
22
  # Go over each VM and bring it up
38
23
  @logger.debug("'Up' each target VM...")
39
24
  with_target_vms(argv[0]) do |vm|
40
25
  if vm.created?
41
26
  @logger.info("Booting: #{vm.name}")
42
27
  vm.ui.info I18n.t("vagrant.commands.up.vm_created")
43
- vm.start(action_params)
28
+ vm.start(options)
44
29
  else
45
30
  @logger.info("Creating: #{vm.name}")
46
- vm.up(action_params)
31
+ vm.up(options)
47
32
  end
48
33
  end
49
34
  end
@@ -23,7 +23,7 @@ module Vagrant
23
23
  # The version of virtualbox that is running.
24
24
  attr_reader :version
25
25
 
26
- def initialize(uuid)
26
+ def initialize(uuid=nil)
27
27
  # Setup the base
28
28
  super()
29
29
 
@@ -2,6 +2,7 @@ require 'pathname'
2
2
  require 'fileutils'
3
3
 
4
4
  require 'log4r'
5
+ require 'rubygems' # This is needed for plugin loading below.
5
6
 
6
7
  require 'vagrant/util/file_mode'
7
8
  require 'vagrant/util/platform'
@@ -55,13 +56,16 @@ module Vagrant
55
56
  }.merge(opts || {})
56
57
 
57
58
  # Set the default working directory to look for the vagrantfile
59
+ opts[:cwd] ||= ENV["VAGRANT_CWD"] if ENV.has_key?("VAGRANT_CWD")
58
60
  opts[:cwd] ||= Dir.pwd
59
61
  opts[:cwd] = Pathname.new(opts[:cwd])
62
+ raise Errors::EnvironmentNonExistentCWD if !opts[:cwd].directory?
60
63
 
61
- # Set the default vagrantfile name, which can be either Vagrantfile
62
- # or vagrantfile (capital for backwards compatibility)
63
- opts[:vagrantfile_name] ||= ["Vagrantfile", "vagrantfile"]
64
+ # Set the Vagrantfile name up. We append "Vagrantfile" and "vagrantfile" so that
65
+ # those continue to work as well, but anything custom will take precedence.
66
+ opts[:vagrantfile_name] ||= []
64
67
  opts[:vagrantfile_name] = [opts[:vagrantfile_name]] if !opts[:vagrantfile_name].is_a?(Array)
68
+ opts[:vagrantfile_name] += ["Vagrantfile", "vagrantfile"]
65
69
 
66
70
  # Set instance variables for all the configuration parameters.
67
71
  @cwd = opts[:cwd]
@@ -148,6 +148,11 @@ module Vagrant
148
148
  error_key(:deprecation)
149
149
  end
150
150
 
151
+ class DestroyRequiresForce < VagrantError
152
+ status_code(74)
153
+ error_key(:destroy_requires_force)
154
+ end
155
+
151
156
  class DotfileIsDirectory < VagrantError
152
157
  status_code(46)
153
158
  error_key(:dotfile_is_directory)
@@ -168,6 +173,11 @@ module Vagrant
168
173
  error_key(:status_error, "vagrant.downloaders.http")
169
174
  end
170
175
 
176
+ class EnvironmentNonExistentCWD < VagrantError
177
+ status_code(75)
178
+ error_key(:environment_non_existent_cwd)
179
+ end
180
+
171
181
  class EnvironmentLockedError < VagrantError
172
182
  status_code(52)
173
183
  error_key(:environment_locked)
@@ -323,6 +333,11 @@ module Vagrant
323
333
  error_key(:ssh_unavailable_windows)
324
334
  end
325
335
 
336
+ class UIExpectsTTY < VagrantError
337
+ status_code(73)
338
+ error_key(:ui_expects_tty)
339
+ end
340
+
326
341
  class VagrantInterrupt < VagrantError
327
342
  status_code(40)
328
343
  error_key(:interrupted)
@@ -9,6 +9,7 @@ module Vagrant
9
9
  autoload :FreeBSD, 'vagrant/guest/freebsd'
10
10
  autoload :Gentoo, 'vagrant/guest/gentoo'
11
11
  autoload :Linux, 'vagrant/guest/linux'
12
+ autoload :OpenBSD, 'vagrant/guest/openbsd'
12
13
  autoload :Redhat, 'vagrant/guest/redhat'
13
14
  autoload :Solaris, 'vagrant/guest/solaris'
14
15
  autoload :Suse, 'vagrant/guest/suse'
@@ -0,0 +1,20 @@
1
+ module Vagrant
2
+ module Guest
3
+ class OpenBSD < Base
4
+ def halt
5
+ vm.channel.sudo("shutdown -p -h now")
6
+
7
+ # Wait until the VM's state is actually powered off. If this doesn't
8
+ # occur within a reasonable amount of time then simply return which
9
+ # will cause Vagrant to force kill the machine.
10
+ count = 0
11
+ while vm.state != :poweroff
12
+ count += 1
13
+
14
+ return if count >= 30
15
+ sleep 1
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -9,7 +9,9 @@ module Vagrant
9
9
  attr_accessor :puppet_server
10
10
  attr_accessor :puppet_node
11
11
  attr_accessor :options
12
+ attr_accessor :facter
12
13
 
14
+ def facter; @facter ||= {}; end
13
15
  def puppet_server; @puppet_server || "puppet"; end
14
16
  def options; @options ||= []; end
15
17
  end
@@ -53,7 +55,18 @@ module Vagrant
53
55
  options += ["--certname", cn] if cn
54
56
  options = options.join(" ")
55
57
 
56
- command = "puppetd #{options} --server #{config.puppet_server}"
58
+ # Build up the custom facts if we have any
59
+ facter = ""
60
+ if !config.facter.empty?
61
+ facts = []
62
+ config.facter.each do |key, value|
63
+ facts << "FACTER_#{key}='#{value}'"
64
+ end
65
+
66
+ facter = "#{facts.join(" ")} "
67
+ end
68
+
69
+ command = "#{facter}puppetd #{options} --server #{config.puppet_server}"
57
70
 
58
71
  env[:ui].info I18n.t("vagrant.provisioners.puppet_server.running_puppetd")
59
72
  env[:vm].channel.sudo(command) do |type, data|
@@ -31,7 +31,14 @@ module Vagrant
31
31
  end
32
32
 
33
33
  # This is a UI implementation that does nothing.
34
- class Silent < Interface; end
34
+ class Silent < Interface
35
+ def ask(*args)
36
+ super
37
+
38
+ # Silent can't do this, obviously.
39
+ raise Errors::UIExpectsTTY
40
+ end
41
+ end
35
42
 
36
43
  # This is a UI implementation that outputs the text as is. It
37
44
  # doesn't add any color.
@@ -51,6 +58,9 @@ module Vagrant
51
58
  def ask(message, opts=nil)
52
59
  super(message)
53
60
 
61
+ # We can't ask questions when the output isn't a TTY.
62
+ raise Errors::UIExpectsTTY if !$stdin.tty?
63
+
54
64
  # Setup the options so that the new line is suppressed
55
65
  opts ||= {}
56
66
  opts[:new_line] = false if !opts.has_key?(:new_line)
@@ -60,7 +70,7 @@ module Vagrant
60
70
  say(:info, message, opts)
61
71
 
62
72
  # Get the results and chomp off the newline
63
- STDIN.gets.chomp
73
+ $stdin.gets.chomp
64
74
  end
65
75
 
66
76
  # This is used to output progress reports to the UI.
@@ -68,9 +78,13 @@ module Vagrant
68
78
  # to the UI. Send `clear_line` to clear the line to show
69
79
  # a continuous progress meter.
70
80
  def report_progress(progress, total, show_parts=true)
71
- percent = (progress.to_f / total.to_f) * 100
72
- line = "Progress: #{percent.to_i}%"
73
- line << " (#{progress} / #{total})" if show_parts
81
+ if total && total > 0
82
+ percent = (progress.to_f / total.to_f) * 100
83
+ line = "Progress: #{percent.to_i}%"
84
+ line << " (#{progress} / #{total})" if show_parts
85
+ else
86
+ line = "Progress: #{progress}"
87
+ end
74
88
 
75
89
  info(line, :new_line => false)
76
90
  end
@@ -2,5 +2,5 @@ module Vagrant
2
2
  # This will always be up to date with the current version of Vagrant,
3
3
  # since it is used to generate the gemspec and is also the source of
4
4
  # the version for `vagrant -v`
5
- VERSION = "1.0.0"
5
+ VERSION = "1.0.1"
6
6
  end
@@ -156,8 +156,8 @@ module Vagrant
156
156
  run_action(:halt, options)
157
157
  end
158
158
 
159
- def reload
160
- run_action(:reload)
159
+ def reload(options=nil)
160
+ run_action(:reload, options)
161
161
  end
162
162
 
163
163
  def provision
@@ -36,6 +36,10 @@ en:
36
36
 
37
37
  %{message}
38
38
  Note that this error message will not appear in the next version of Vagrant.
39
+ destroy_requires_force: |-
40
+ Destroy doesn't have a TTY to ask for confirmation. Please pass the
41
+ `--force` flag to force a destroy, otherwise attach a TTY so that
42
+ the destroy can be confirmed.
39
43
  dotfile_is_directory: |-
40
44
  The local file Vagrant uses to store data ".vagrant" already exists
41
45
  and is a directory! If you are in your home directory, then please run
@@ -141,6 +145,11 @@ en:
141
145
  Port: %{port}
142
146
  Username: %{username}
143
147
  Private key: %{key_path}
148
+ ui_expects_tty: |-
149
+ Vagrant is attempting to interface with the UI in a way that requires
150
+ a TTY. Most actions in Vagrant that require a TTY have configuration
151
+ switches to disable this requirement. Please do that or run Vagrant
152
+ with TTY.
144
153
  vagrantfile_exists: |-
145
154
  `Vagrantfile` already exists in this directory. Remove it before
146
155
  running `vagrant init`.
@@ -274,6 +283,11 @@ en:
274
283
  not_created: |-
275
284
  The environment has not yet been created. Run `vagrant up` to
276
285
  create the environment.
286
+ paused: |-
287
+ The VM is paused. This VM may have been paused via the VirtualBox
288
+ GUI or the VBoxManage command line interface. To unpause, please
289
+ use the VirtualBox GUI and/or VBoxManage command line interface so
290
+ that vagrant would be able to control the VM again.
277
291
  poweroff: |-
278
292
  The VM is powered off. To restart the VM, simply run `vagrant up`
279
293
  running: |-
@@ -16,6 +16,14 @@ module Unit
16
16
  Vagrant::Environment.new(options)
17
17
  end
18
18
 
19
+ # This creates a file in the isolated environment. By default this file
20
+ # will be created in the working directory of the isolated environment.
21
+ def file(name, contents)
22
+ @workdir.join(name).open("w+") do |f|
23
+ f.write(contents)
24
+ end
25
+ end
26
+
19
27
  def vagrantfile(contents, root=nil)
20
28
  root ||= @workdir
21
29
  root.join("Vagrantfile").open("w+") do |f|
@@ -17,8 +17,18 @@ describe Vagrant::Environment do
17
17
  end
18
18
 
19
19
  it "is set to the cwd given" do
20
- instance = described_class.new(:cwd => "foobarbaz")
21
- instance.cwd.should == Pathname.new("foobarbaz")
20
+ directory = File.dirname(__FILE__)
21
+ instance = described_class.new(:cwd => directory)
22
+ instance.cwd.should == Pathname.new(directory)
23
+ end
24
+
25
+ it "is set to the environmental variable VAGRANT_CWD" do
26
+ pending "A good temporary ENV thing"
27
+ end
28
+
29
+ it "raises an exception if the CWD doesn't exist" do
30
+ expect { described_class.new(:cwd => "doesntexist") }.
31
+ to raise_error(Vagrant::Errors::EnvironmentNonExistentCWD)
22
32
  end
23
33
  end
24
34
 
@@ -120,6 +130,19 @@ VF
120
130
  env.config.global.vagrant.dotfile_name.should == "foo"
121
131
  end
122
132
 
133
+ it "should load from a custom Vagrantfile" do
134
+ environment = isolated_environment do |env|
135
+ env.file("non_standard_name", <<-VF)
136
+ Vagrant::Config.run do |config|
137
+ config.vagrant.dotfile_name = "custom"
138
+ end
139
+ VF
140
+ end
141
+
142
+ env = environment.create_vagrant_env(:vagrantfile_name => "non_standard_name")
143
+ env.config.global.vagrant.dotfile_name.should == "custom"
144
+ end
145
+
123
146
  it "should load VM configuration" do
124
147
  environment = isolated_environment do |env|
125
148
  env.vagrantfile(<<-VF)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrantup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitchell Hashimoto
@@ -313,6 +313,7 @@ files:
313
313
  - lib/vagrant/command/resume.rb
314
314
  - lib/vagrant/command/ssh.rb
315
315
  - lib/vagrant/command/ssh_config.rb
316
+ - lib/vagrant/command/start_mixins.rb
316
317
  - lib/vagrant/command/status.rb
317
318
  - lib/vagrant/command/suspend.rb
318
319
  - lib/vagrant/command/up.rb
@@ -354,6 +355,7 @@ files:
354
355
  - lib/vagrant/guest/linux.rb
355
356
  - lib/vagrant/guest/linux/config.rb
356
357
  - lib/vagrant/guest/linux/error.rb
358
+ - lib/vagrant/guest/openbsd.rb
357
359
  - lib/vagrant/guest/redhat.rb
358
360
  - lib/vagrant/guest/solaris.rb
359
361
  - lib/vagrant/guest/suse.rb