vagrant 0.9.7 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +41 -0
- data/config/default.rb +0 -1
- data/lib/vagrant.rb +9 -5
- data/lib/vagrant/action.rb +1 -0
- data/lib/vagrant/action/builtin.rb +10 -0
- data/lib/vagrant/action/general/check_virtualbox.rb +28 -0
- data/lib/vagrant/action/general/package.rb +10 -7
- data/lib/vagrant/action/general/validate.rb +2 -3
- data/lib/vagrant/action/vm/customize.rb +1 -1
- data/lib/vagrant/action/vm/network.rb +10 -9
- data/lib/vagrant/action/vm/nfs.rb +7 -0
- data/lib/vagrant/command.rb +1 -0
- data/lib/vagrant/command/base.rb +8 -2
- data/lib/vagrant/command/destroy.rb +29 -3
- data/lib/vagrant/command/gem.rb +35 -0
- data/lib/vagrant/command/package.rb +1 -1
- data/lib/vagrant/command/ssh.rb +1 -1
- data/lib/vagrant/command/ssh_config.rb +1 -1
- data/lib/vagrant/config/loader.rb +2 -0
- data/lib/vagrant/config/ssh.rb +0 -20
- data/lib/vagrant/config/vm.rb +0 -48
- data/lib/vagrant/data_store.rb +18 -9
- data/lib/vagrant/driver/virtualbox.rb +1 -0
- data/lib/vagrant/driver/virtualbox_4_0.rb +36 -14
- data/lib/vagrant/driver/virtualbox_4_1.rb +36 -14
- data/lib/vagrant/driver/virtualbox_base.rb +37 -19
- data/lib/vagrant/environment.rb +21 -2
- data/lib/vagrant/errors.rb +10 -0
- data/lib/vagrant/guest.rb +1 -0
- data/lib/vagrant/guest/arch.rb +10 -2
- data/lib/vagrant/guest/base.rb +1 -1
- data/lib/vagrant/guest/debian.rb +5 -2
- data/lib/vagrant/guest/fedora.rb +66 -0
- data/lib/vagrant/guest/freebsd.rb +18 -7
- data/lib/vagrant/guest/gentoo.rb +6 -0
- data/lib/vagrant/guest/linux.rb +1 -0
- data/lib/vagrant/guest/redhat.rb +1 -0
- data/lib/vagrant/guest/ubuntu.rb +1 -1
- data/lib/vagrant/hosts.rb +1 -0
- data/lib/vagrant/hosts/opensuse.rb +30 -0
- data/lib/vagrant/plugin.rb +21 -19
- data/lib/vagrant/provisioners/chef.rb +3 -1
- data/lib/vagrant/provisioners/puppet.rb +18 -7
- data/lib/vagrant/util/line_ending_helpers.rb +14 -0
- data/lib/vagrant/util/subprocess.rb +9 -0
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +6 -6
- data/templates/commands/init/Vagrantfile.erb +1 -1
- data/templates/guests/fedora/network_dhcp.erb +6 -0
- data/templates/guests/fedora/network_static.erb +13 -0
- data/templates/guests/freebsd/network_dhcp.erb +3 -0
- data/templates/guests/freebsd/network_static.erb +3 -0
- data/templates/locales/en.yml +26 -0
- data/templates/nfs/exports_linux.erb +1 -1
- data/test/acceptance/networking/host_only_test.rb +2 -2
- data/test/unit/vagrant/config/vm_test.rb +4 -4
- data/test/unit/vagrant/data_store_test.rb +12 -0
- data/test/unit/vagrant/environment_test.rb +20 -0
- data/test/unit/vagrant/util/line_endings_helper_test.rb +16 -0
- data/vagrant.gemspec +1 -1
- metadata +37 -27
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,44 @@
|
|
1
|
+
## 1.0.0 (March 6, 2012)
|
2
|
+
|
3
|
+
- `vagrant gem` should now be used to install Vagrant plugins that are
|
4
|
+
gems. This installs the gems to a private gem folder that Vagrant adds
|
5
|
+
to its own load path. This isolates Vagrant-related gems from system
|
6
|
+
gems.
|
7
|
+
- Plugin loading no longer happens right when Vagrant is loaded, but when
|
8
|
+
a Vagrant environment is loaded. I don't anticipate this causing any
|
9
|
+
problems but it is a backwards incompatible change should a plugin
|
10
|
+
depend on this (but I don't see any reason why they would).
|
11
|
+
- `vagrant destroy` now asks for confirmation by default. This can be
|
12
|
+
overridden with the `--force` flag. [GH-699]
|
13
|
+
- Fix issue with Puppet config inheritance. [GH-722]
|
14
|
+
- Fix issue where starting a VM on some systems was incorrectly treated
|
15
|
+
as failing. [GH-720]
|
16
|
+
- It is now an error to specify the packaging `output` as a directory. [GH-730]
|
17
|
+
- Unix-style line endings are used properly for guest OS. [GH-727]
|
18
|
+
- Retry certain VirtualBox operations, since they intermittently fail.
|
19
|
+
[GH-726]
|
20
|
+
- Fix issue where Vagrant would sometimes "lose" a VM if an exception
|
21
|
+
occurred. [GH-725]
|
22
|
+
- `vagrant destroy` destroys virtual machines in reverse order. [GH-739]
|
23
|
+
- Add an `fsid` option to Linux NFS exports. [GH-736]
|
24
|
+
- Fix edge case where an exception could be raised in networking code. [GH-742]
|
25
|
+
- Add missing translation for the "guru meditation" state. [GH-745]
|
26
|
+
- Check that VirtualBox exists before certain commands. [GH-746]
|
27
|
+
- NIC type can be defined for host-only network adapters. [GH-750]
|
28
|
+
- Fix issue where re-running chef-client would sometimes cause
|
29
|
+
problems due to file permissions. [GH-748]
|
30
|
+
- FreeBSD guests can now have their hostnames changed. [GH-757]
|
31
|
+
- FreeBSD guests now support host only networking and bridged networking. [GH-762]
|
32
|
+
- `VM#run_action` is now public so plugin-devs can hook into it.
|
33
|
+
- Fix crashing bug when attempting to run commands on the "primary"
|
34
|
+
VM in a multi-VM environment. [GH-761]
|
35
|
+
- With puppet you can now specify `:facter` as a dictionary of facts to
|
36
|
+
override what is generated by Puppet. [GH-753]
|
37
|
+
- Automatically convert all arguments to `customize` to strings.
|
38
|
+
- openSUSE host system. [GH-766]
|
39
|
+
- Fix subprocess IO deadlock which would occur on Windows. [GH-765]
|
40
|
+
- Fedora 16 guest support. [GH-772]
|
41
|
+
|
1
42
|
## 0.9.7 (February 9, 2012)
|
2
43
|
|
3
44
|
- Fix regression where all subprocess IO simply didn't work with
|
data/config/default.rb
CHANGED
data/lib/vagrant.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
|
1
3
|
# Enable logging if it is requested. We do this before
|
2
4
|
# anything else so that we can setup the output before
|
3
5
|
# any logging occurs.
|
4
6
|
if ENV["VAGRANT_LOG"] && ENV["VAGRANT_LOG"] != ""
|
5
7
|
# Require Log4r and define the levels we'll be using
|
6
|
-
require 'log4r'
|
7
8
|
require 'log4r/config'
|
8
9
|
Log4r.define_levels(*Log4r::Log4rConfig::LogLevels)
|
9
10
|
|
@@ -50,6 +51,10 @@ require 'i18n'
|
|
50
51
|
# there are issues with ciphers not being properly loaded.
|
51
52
|
require 'openssl'
|
52
53
|
|
54
|
+
# Always make the version available
|
55
|
+
require 'vagrant/version'
|
56
|
+
Log4r::Logger.new("vagrant::global").info("Vagrant version: #{Vagrant::VERSION}")
|
57
|
+
|
53
58
|
module Vagrant
|
54
59
|
autoload :Action, 'vagrant/action'
|
55
60
|
autoload :Box, 'vagrant/box'
|
@@ -136,6 +141,7 @@ I18n.load_path << File.expand_path("templates/locales/en.yml", Vagrant.source_ro
|
|
136
141
|
# Register the built-in commands
|
137
142
|
Vagrant.commands.register(:box) { Vagrant::Command::Box }
|
138
143
|
Vagrant.commands.register(:destroy) { Vagrant::Command::Destroy }
|
144
|
+
Vagrant.commands.register(:gem) { Vagrant::Command::Gem }
|
139
145
|
Vagrant.commands.register(:halt) { Vagrant::Command::Halt }
|
140
146
|
Vagrant.commands.register(:init) { Vagrant::Command::Init }
|
141
147
|
Vagrant.commands.register(:package) { Vagrant::Command::Package }
|
@@ -159,6 +165,7 @@ Vagrant.config_keys.register(:package) { Vagrant::Config::PackageConfig }
|
|
159
165
|
Vagrant.hosts.register(:arch) { Vagrant::Hosts::Arch }
|
160
166
|
Vagrant.hosts.register(:bsd) { Vagrant::Hosts::BSD }
|
161
167
|
Vagrant.hosts.register(:fedora) { Vagrant::Hosts::Fedora }
|
168
|
+
Vagrant.hosts.register(:opensuse) { Vagrant::Hosts::OpenSUSE }
|
162
169
|
Vagrant.hosts.register(:freebsd) { Vagrant::Hosts::FreeBSD }
|
163
170
|
Vagrant.hosts.register(:gentoo) { Vagrant::Hosts::Gentoo }
|
164
171
|
Vagrant.hosts.register(:linux) { Vagrant::Hosts::Linux }
|
@@ -167,6 +174,7 @@ Vagrant.hosts.register(:windows) { Vagrant::Hosts::Windows }
|
|
167
174
|
# Register the built-in guests
|
168
175
|
Vagrant.guests.register(:arch) { Vagrant::Guest::Arch }
|
169
176
|
Vagrant.guests.register(:debian) { Vagrant::Guest::Debian }
|
177
|
+
Vagrant.guests.register(:fedora) { Vagrant::Guest::Fedora }
|
170
178
|
Vagrant.guests.register(:freebsd) { Vagrant::Guest::FreeBSD }
|
171
179
|
Vagrant.guests.register(:gentoo) { Vagrant::Guest::Gentoo }
|
172
180
|
Vagrant.guests.register(:linux) { Vagrant::Guest::Linux }
|
@@ -186,7 +194,3 @@ Vagrant.provisioners.register(:shell) { Vagrant::Provisioners::Shell }
|
|
186
194
|
Vagrant.config_keys.register(:freebsd) { Vagrant::Guest::FreeBSD::FreeBSDConfig }
|
187
195
|
Vagrant.config_keys.register(:linux) { Vagrant::Guest::Linux::LinuxConfig }
|
188
196
|
Vagrant.config_keys.register(:solaris) { Vagrant::Guest::Solaris::SolarisConfig }
|
189
|
-
|
190
|
-
# Load the things which must be loaded before anything else.
|
191
|
-
require 'vagrant/version'
|
192
|
-
Vagrant::Plugin.load!
|
data/lib/vagrant/action.rb
CHANGED
@@ -20,6 +20,7 @@ module Vagrant
|
|
20
20
|
# provision - Provisions a running VM
|
21
21
|
register(:provision) do
|
22
22
|
Builder.new do
|
23
|
+
use General::CheckVirtualbox
|
23
24
|
use General::Validate
|
24
25
|
use VM::CheckAccessible
|
25
26
|
use VM::Provision
|
@@ -30,6 +31,7 @@ module Vagrant
|
|
30
31
|
# environment.
|
31
32
|
register(:start) do
|
32
33
|
Builder.new do
|
34
|
+
use General::CheckVirtualbox
|
33
35
|
use General::Validate
|
34
36
|
use VM::CheckAccessible
|
35
37
|
use VM::CleanMachineFolder
|
@@ -53,6 +55,7 @@ module Vagrant
|
|
53
55
|
# a restart if fails.
|
54
56
|
register(:halt) do
|
55
57
|
Builder.new do
|
58
|
+
use General::CheckVirtualbox
|
56
59
|
use General::Validate
|
57
60
|
use VM::CheckAccessible
|
58
61
|
use VM::DiscardState
|
@@ -63,6 +66,7 @@ module Vagrant
|
|
63
66
|
# suspend - Suspends the VM
|
64
67
|
register(:suspend) do
|
65
68
|
Builder.new do
|
69
|
+
use General::CheckVirtualbox
|
66
70
|
use General::Validate
|
67
71
|
use VM::CheckAccessible
|
68
72
|
use VM::Suspend
|
@@ -72,6 +76,7 @@ module Vagrant
|
|
72
76
|
# resume - Resume a VM
|
73
77
|
register(:resume) do
|
74
78
|
Builder.new do
|
79
|
+
use General::CheckVirtualbox
|
75
80
|
use General::Validate
|
76
81
|
use VM::CheckAccessible
|
77
82
|
use VM::CheckPortCollisions
|
@@ -82,6 +87,7 @@ module Vagrant
|
|
82
87
|
# reload - Halts then restarts the VM
|
83
88
|
register(:reload) do
|
84
89
|
Builder.new do
|
90
|
+
use General::CheckVirtualbox
|
85
91
|
use General::Validate
|
86
92
|
use VM::CheckAccessible
|
87
93
|
use registry.get(:halt)
|
@@ -92,6 +98,7 @@ module Vagrant
|
|
92
98
|
# up - Imports, prepares, then starts a fresh VM.
|
93
99
|
register(:up) do
|
94
100
|
Builder.new do
|
101
|
+
use General::CheckVirtualbox
|
95
102
|
use General::Validate
|
96
103
|
use VM::CheckAccessible
|
97
104
|
use VM::CheckBox
|
@@ -106,6 +113,7 @@ module Vagrant
|
|
106
113
|
# destroy - Halts, cleans up, and destroys an existing VM
|
107
114
|
register(:destroy) do
|
108
115
|
Builder.new do
|
116
|
+
use General::CheckVirtualbox
|
109
117
|
use General::Validate
|
110
118
|
use VM::CheckAccessible
|
111
119
|
use registry.get(:halt), :force => true
|
@@ -120,6 +128,7 @@ module Vagrant
|
|
120
128
|
# package - Export and package the VM
|
121
129
|
register(:package) do
|
122
130
|
Builder.new do
|
131
|
+
use General::CheckVirtualbox
|
123
132
|
use General::Validate
|
124
133
|
use VM::SetupPackageFiles
|
125
134
|
use VM::CheckAccessible
|
@@ -135,6 +144,7 @@ module Vagrant
|
|
135
144
|
# box_add - Download and add a box.
|
136
145
|
register(:box_add) do
|
137
146
|
Builder.new do
|
147
|
+
use General::CheckVirtualbox
|
138
148
|
use Box::Download
|
139
149
|
use Box::Unpackage
|
140
150
|
use Box::Verify
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Action
|
3
|
+
module General
|
4
|
+
# Checks that virtualbox is installed and ready to be used.
|
5
|
+
class CheckVirtualbox
|
6
|
+
def initialize(app, env)
|
7
|
+
@app = app
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
# Certain actions may not actually have a VM, and thus no
|
12
|
+
# driver, so we have to be clever about obtaining an instance
|
13
|
+
# of the driver.
|
14
|
+
driver = nil
|
15
|
+
driver = env[:vm].driver if env[:vm]
|
16
|
+
driver = Driver::VirtualBox.new(nil) if !driver
|
17
|
+
|
18
|
+
# Verify that it is ready to go! This will raise an exception
|
19
|
+
# if anything goes wrong.
|
20
|
+
driver.verify!
|
21
|
+
|
22
|
+
# Carry on.
|
23
|
+
@app.call(env)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -27,6 +27,7 @@ module Vagrant
|
|
27
27
|
def call(env)
|
28
28
|
@env = env
|
29
29
|
|
30
|
+
raise Errors::PackageOutputDirectory if File.directory?(tar_path)
|
30
31
|
raise Errors::PackageOutputExists if File.exist?(tar_path)
|
31
32
|
raise Errors::PackageRequiresDirectory if !env["package.directory"] ||
|
32
33
|
!File.directory?(env["package.directory"])
|
@@ -37,12 +38,14 @@ module Vagrant
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def recover(env)
|
40
|
-
#
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
# There are certain exceptions that we don't delete the file for.
|
42
|
+
ignore_exc = [Errors::PackageOutputDirectory, Errors::PackageOutputExists]
|
43
|
+
ignore_exc.each do |exc|
|
44
|
+
return if env["vagrant.error"].is_a?(exc)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Cleanup any packaged files if the packaging failed at some point.
|
48
|
+
File.delete(tar_path) if File.exist?(tar_path)
|
46
49
|
end
|
47
50
|
|
48
51
|
# This method copies the include files (passed in via command line)
|
@@ -90,7 +93,7 @@ module Vagrant
|
|
90
93
|
|
91
94
|
# Path to the final box output file
|
92
95
|
def tar_path
|
93
|
-
File.
|
96
|
+
File.expand_path(@env["package.output"], FileUtils.pwd)
|
94
97
|
end
|
95
98
|
end
|
96
99
|
end
|
@@ -6,12 +6,11 @@ module Vagrant
|
|
6
6
|
class Validate
|
7
7
|
def initialize(app, env)
|
8
8
|
@app = app
|
9
|
-
@env = env
|
10
9
|
end
|
11
10
|
|
12
11
|
def call(env)
|
13
|
-
|
14
|
-
@app.call(
|
12
|
+
env[:vm].config.validate!(env[:vm].env) if !env.has_key?("validate") || env["validate"]
|
13
|
+
@app.call(env)
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
@@ -37,12 +37,9 @@ module Vagrant
|
|
37
37
|
adapters << adapter
|
38
38
|
|
39
39
|
# Get the network configuration
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
else
|
44
|
-
@logger.info("Auto config disabled, not configuring: #{type}")
|
45
|
-
end
|
40
|
+
network = send("#{type}_network_config", config)
|
41
|
+
network[:_auto_config] = true if config[:auto_config]
|
42
|
+
networks << network
|
46
43
|
end
|
47
44
|
|
48
45
|
if !adapters.empty?
|
@@ -68,9 +65,11 @@ module Vagrant
|
|
68
65
|
# Determine the interface numbers for the guest.
|
69
66
|
assign_interface_numbers(networks, adapters)
|
70
67
|
|
71
|
-
# Configure all the network interfaces on the guest.
|
68
|
+
# Configure all the network interfaces on the guest. We only
|
69
|
+
# want to configure the networks that have `auto_config` setup.
|
70
|
+
networks_to_configure = networks.select { |n| n[:_auto_config] }
|
72
71
|
env[:ui].info I18n.t("vagrant.actions.vm.network.configuring")
|
73
|
-
env[:vm].guest.configure_networks(
|
72
|
+
env[:vm].guest.configure_networks(networks_to_configure)
|
74
73
|
end
|
75
74
|
end
|
76
75
|
|
@@ -253,7 +252,8 @@ module Vagrant
|
|
253
252
|
:adapter => config[:adapter],
|
254
253
|
:type => :hostonly,
|
255
254
|
:hostonly => interface[:name],
|
256
|
-
:mac_address => config[:mac]
|
255
|
+
:mac_address => config[:mac],
|
256
|
+
:nic_type => config[:nic_type]
|
257
257
|
}
|
258
258
|
end
|
259
259
|
|
@@ -309,6 +309,7 @@ module Vagrant
|
|
309
309
|
|
310
310
|
def bridged_config(args)
|
311
311
|
options = args[0] || {}
|
312
|
+
options = {} if !options.is_a?(Hash)
|
312
313
|
|
313
314
|
return {
|
314
315
|
:adapter => nil,
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'digest/md5'
|
1
2
|
require 'fileutils'
|
2
3
|
require 'pathname'
|
3
4
|
|
@@ -93,6 +94,12 @@ module Vagrant
|
|
93
94
|
opts[:map_gid] = prepare_permission(:gid, opts)
|
94
95
|
opts[:nfs_version] ||= 3
|
95
96
|
|
97
|
+
# The poor man's UUID. An MD5 hash here is sufficient since
|
98
|
+
# we need a 32 character "uuid" to represent the filesystem
|
99
|
+
# of an export. Hashing the host path is safe because two of
|
100
|
+
# the same host path will hash to the same fsid.
|
101
|
+
opts[:uuid] = Digest::MD5.hexdigest(opts[:hostpath])
|
102
|
+
|
96
103
|
acc[key] = opts
|
97
104
|
acc
|
98
105
|
end
|
data/lib/vagrant/command.rb
CHANGED
@@ -8,6 +8,7 @@ module Vagrant
|
|
8
8
|
autoload :BoxRepackage, 'vagrant/command/box_repackage'
|
9
9
|
autoload :BoxList, 'vagrant/command/box_list'
|
10
10
|
autoload :Destroy, 'vagrant/command/destroy'
|
11
|
+
autoload :Gem, 'vagrant/command/gem'
|
11
12
|
autoload :Halt, 'vagrant/command/halt'
|
12
13
|
autoload :Init, 'vagrant/command/init'
|
13
14
|
autoload :Package, 'vagrant/command/package'
|
data/lib/vagrant/command/base.rb
CHANGED
@@ -60,10 +60,13 @@ module Vagrant
|
|
60
60
|
# @param [String] name The name of the VM. Nil if every VM.
|
61
61
|
# @param [Boolean] single_target If true, then an exception will be
|
62
62
|
# raised if more than one target is found.
|
63
|
-
def with_target_vms(name=nil,
|
63
|
+
def with_target_vms(name=nil, options=nil)
|
64
64
|
# Using VMs requires a Vagrant environment to be properly setup
|
65
65
|
raise Errors::NoEnvironmentError if !@env.root_path
|
66
66
|
|
67
|
+
# Setup the options hash
|
68
|
+
options ||= {}
|
69
|
+
|
67
70
|
# First determine the proper array of VMs.
|
68
71
|
vms = []
|
69
72
|
if name
|
@@ -89,7 +92,10 @@ module Vagrant
|
|
89
92
|
end
|
90
93
|
|
91
94
|
# Make sure we're only working with one VM if single target
|
92
|
-
raise Errors::MultiVMTargetRequired if single_target && vms.length != 1
|
95
|
+
raise Errors::MultiVMTargetRequired if options[:single_target] && vms.length != 1
|
96
|
+
|
97
|
+
# If we asked for reversed ordering, then reverse it
|
98
|
+
vms.reverse! if options[:reverse]
|
93
99
|
|
94
100
|
# Go through each VM and yield it!
|
95
101
|
vms.each do |old_vm|
|
@@ -4,8 +4,15 @@ module Vagrant
|
|
4
4
|
module Command
|
5
5
|
class Destroy < Base
|
6
6
|
def execute
|
7
|
+
options = {}
|
8
|
+
|
7
9
|
opts = OptionParser.new do |opts|
|
8
10
|
opts.banner = "Usage: vagrant destroy [vm-name]"
|
11
|
+
opts.separator ""
|
12
|
+
|
13
|
+
opts.on("-f", "--force", "Destroy without confirmation.") do |f|
|
14
|
+
options[:force] = f
|
15
|
+
end
|
9
16
|
end
|
10
17
|
|
11
18
|
# Parse the options
|
@@ -13,10 +20,29 @@ module Vagrant
|
|
13
20
|
return if !argv
|
14
21
|
|
15
22
|
@logger.debug("'Destroy' each target VM...")
|
16
|
-
with_target_vms(argv[0]) do |vm|
|
23
|
+
with_target_vms(argv[0], :reverse => true) do |vm|
|
17
24
|
if vm.created?
|
18
|
-
|
19
|
-
|
25
|
+
# Boolean whether we should actually go through with the destroy
|
26
|
+
# or not. This is true only if the "--force" flag is set or if the
|
27
|
+
# user confirms it.
|
28
|
+
do_destroy = false
|
29
|
+
|
30
|
+
if options[:force]
|
31
|
+
do_destroy = true
|
32
|
+
else
|
33
|
+
choice = @env.ui.ask(I18n.t("vagrant.commands.destroy.confirmation",
|
34
|
+
:name => vm.name))
|
35
|
+
do_destroy = choice.upcase == "Y"
|
36
|
+
end
|
37
|
+
|
38
|
+
if do_destroy
|
39
|
+
@logger.info("Destroying: #{vm.name}")
|
40
|
+
vm.destroy
|
41
|
+
else
|
42
|
+
@logger.info("Not destroying #{vm.name} since confirmation was declined.")
|
43
|
+
@env.ui.success(I18n.t("vagrant.commands.destroy.will_not_destroy",
|
44
|
+
:name => vm.name), :prefix => false)
|
45
|
+
end
|
20
46
|
else
|
21
47
|
@logger.info("Not destroying #{vm.name}, since it isn't created.")
|
22
48
|
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "rubygems/gem_runner"
|
3
|
+
|
4
|
+
module Vagrant
|
5
|
+
module Command
|
6
|
+
class Gem < Base
|
7
|
+
def execute
|
8
|
+
# Bundler sets up its own custom gem load paths such that our
|
9
|
+
# own gems are never loaded. Therefore, give an error if a user
|
10
|
+
# tries to install gems while within a Bundler-managed environment.
|
11
|
+
if defined?(Bundler)
|
12
|
+
require 'bundler/shared_helpers'
|
13
|
+
if Bundler::SharedHelpers.in_bundle?
|
14
|
+
raise Errors::GemCommandInBundler
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# If the user needs some help, we add our own little message at the
|
19
|
+
# top so that they're aware of what `vagrant gem` is doing, really.
|
20
|
+
if @argv.empty? || @argv.include?("-h") || @argv.include?("--help")
|
21
|
+
@env.ui.info(I18n.t("vagrant.commands.gem.help_preamble"),
|
22
|
+
:prefix => false)
|
23
|
+
puts
|
24
|
+
end
|
25
|
+
|
26
|
+
# We just proxy the arguments onto a real RubyGems command
|
27
|
+
# but change `GEM_HOME` so that the gems are installed into
|
28
|
+
# our own private gem folder.
|
29
|
+
ENV["GEM_HOME"] = @env.gems_path.to_s
|
30
|
+
::Gem.clear_paths
|
31
|
+
::Gem::GemRunner.new.run(@argv.dup)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|