vagrantup 0.8.10 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +77 -1
- data/Gemfile +0 -14
- data/LICENSE +1 -1
- data/bin/vagrant +47 -20
- data/config/default.rb +6 -14
- data/lib/vagrant/action/box/destroy.rb +7 -3
- data/lib/vagrant/action/box/download.rb +8 -8
- data/lib/vagrant/action/box/package.rb +2 -2
- data/lib/vagrant/action/box/unpackage.rb +13 -7
- data/lib/vagrant/action/box/verify.rb +5 -5
- data/lib/vagrant/action/builder.rb +23 -19
- data/lib/vagrant/action/builtin.rb +117 -79
- data/lib/vagrant/action/env/set.rb +7 -4
- data/lib/vagrant/action/environment.rb +3 -41
- data/lib/vagrant/action/general/package.rb +14 -29
- data/lib/vagrant/action/general/validate.rb +2 -2
- data/lib/vagrant/action/runner.rb +53 -0
- data/lib/vagrant/action/vm/boot.rb +9 -9
- data/lib/vagrant/action/vm/check_accessible.rb +2 -2
- data/lib/vagrant/action/vm/check_box.rb +10 -12
- data/lib/vagrant/action/vm/check_guest_additions.rb +8 -8
- data/lib/vagrant/action/vm/check_port_collisions.rb +85 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +4 -4
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +3 -11
- data/lib/vagrant/action/vm/clear_network_interfaces.rb +31 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +2 -11
- data/lib/vagrant/action/vm/customize.rb +19 -9
- data/lib/vagrant/action/vm/destroy.rb +4 -4
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +2 -12
- data/lib/vagrant/action/vm/discard_state.rb +4 -4
- data/lib/vagrant/action/vm/export.rb +13 -8
- data/lib/vagrant/action/vm/forward_ports.rb +55 -102
- data/lib/vagrant/action/vm/halt.rb +9 -6
- data/lib/vagrant/action/vm/host_name.rb +4 -4
- data/lib/vagrant/action/vm/import.rb +19 -10
- data/lib/vagrant/action/vm/match_mac_address.rb +4 -9
- data/lib/vagrant/action/vm/network.rb +300 -94
- data/lib/vagrant/action/vm/nfs.rb +41 -26
- data/lib/vagrant/action/vm/package.rb +1 -1
- data/lib/vagrant/action/vm/package_vagrantfile.rb +5 -2
- data/lib/vagrant/action/vm/provision.rb +42 -13
- data/lib/vagrant/action/vm/provisioner_cleanup.rb +2 -2
- data/lib/vagrant/action/vm/{clear_nfs_exports.rb → prune_nfs_exports.rb} +7 -7
- data/lib/vagrant/action/vm/resume.rb +4 -4
- data/lib/vagrant/action/vm/setup_package_files.rb +54 -0
- data/lib/vagrant/action/vm/share_folders.rb +63 -39
- data/lib/vagrant/action/vm/suspend.rb +4 -4
- data/lib/vagrant/action/warden.rb +13 -6
- data/lib/vagrant/action.rb +45 -123
- data/lib/vagrant/box.rb +9 -55
- data/lib/vagrant/box_collection.rb +22 -17
- data/lib/vagrant/cli.rb +62 -47
- data/lib/vagrant/command/base.rb +135 -90
- data/lib/vagrant/command/box.rb +46 -21
- data/lib/vagrant/command/box_add.rb +33 -0
- data/lib/vagrant/command/box_list.rb +25 -0
- data/lib/vagrant/command/box_remove.rb +23 -0
- data/lib/vagrant/command/box_repackage.rb +23 -0
- data/lib/vagrant/command/destroy.rb +16 -5
- data/lib/vagrant/command/halt.rb +25 -7
- data/lib/vagrant/command/init.rb +30 -7
- data/lib/vagrant/command/package.rb +49 -18
- data/lib/vagrant/command/provision.rb +22 -9
- data/lib/vagrant/command/reload.rb +18 -5
- data/lib/vagrant/command/resume.rb +18 -5
- data/lib/vagrant/command/ssh.rb +69 -31
- data/lib/vagrant/command/ssh_config.rb +37 -22
- data/lib/vagrant/command/status.rb +22 -20
- data/lib/vagrant/command/suspend.rb +18 -5
- data/lib/vagrant/command/up.rb +41 -8
- data/lib/vagrant/command.rb +18 -20
- data/lib/vagrant/communication/base.rb +56 -0
- data/lib/vagrant/communication/ssh.rb +200 -0
- data/lib/vagrant/communication.rb +7 -0
- data/lib/vagrant/config/base.rb +18 -26
- data/lib/vagrant/config/container.rb +37 -0
- data/lib/vagrant/config/error_recorder.rb +1 -1
- data/lib/vagrant/config/loader.rb +125 -0
- data/lib/vagrant/config/nfs.rb +1 -3
- data/lib/vagrant/config/package.rb +1 -3
- data/lib/vagrant/config/ssh.rb +31 -16
- data/lib/vagrant/config/top.rb +36 -25
- data/lib/vagrant/config/vagrant.rb +2 -5
- data/lib/vagrant/config/vm/provisioner.rb +16 -20
- data/lib/vagrant/config/vm/sub_vm.rb +1 -1
- data/lib/vagrant/config/vm.rb +115 -56
- data/lib/vagrant/config.rb +29 -103
- data/lib/vagrant/data_store.rb +23 -15
- data/lib/vagrant/downloaders/base.rb +7 -5
- data/lib/vagrant/downloaders/file.rb +4 -4
- data/lib/vagrant/downloaders/http.rb +4 -5
- data/lib/vagrant/driver/virtualbox.rb +121 -0
- data/lib/vagrant/driver/virtualbox_4_0.rb +411 -0
- data/lib/vagrant/driver/virtualbox_4_1.rb +411 -0
- data/lib/vagrant/driver/virtualbox_base.rb +284 -0
- data/lib/vagrant/driver.rb +7 -0
- data/lib/vagrant/environment.rb +221 -240
- data/lib/vagrant/errors.rb +74 -25
- data/lib/vagrant/guest/arch.rb +48 -0
- data/lib/vagrant/{systems → guest}/base.rb +30 -18
- data/lib/vagrant/guest/debian.rb +61 -0
- data/lib/vagrant/{systems → guest}/freebsd.rb +11 -18
- data/lib/vagrant/guest/gentoo.rb +32 -0
- data/lib/vagrant/{systems → guest}/linux/config.rb +2 -4
- data/lib/vagrant/guest/linux/error.rb +9 -0
- data/lib/vagrant/guest/linux.rb +78 -0
- data/lib/vagrant/guest/redhat.rb +66 -0
- data/lib/vagrant/guest/solaris.rb +114 -0
- data/lib/vagrant/{systems → guest}/suse.rb +2 -2
- data/lib/vagrant/guest/ubuntu.rb +23 -0
- data/lib/vagrant/guest.rb +16 -0
- data/lib/vagrant/hosts/arch.rb +7 -3
- data/lib/vagrant/hosts/base.rb +36 -46
- data/lib/vagrant/hosts/bsd.rb +53 -16
- data/lib/vagrant/hosts/fedora.rb +14 -0
- data/lib/vagrant/hosts/freebsd.rb +6 -36
- data/lib/vagrant/hosts/linux.rb +45 -20
- data/lib/vagrant/hosts/windows.rb +16 -0
- data/lib/vagrant/hosts.rb +23 -6
- data/lib/vagrant/provisioners/base.rb +11 -34
- data/lib/vagrant/provisioners/chef.rb +30 -26
- data/lib/vagrant/provisioners/chef_client.rb +37 -23
- data/lib/vagrant/provisioners/chef_solo.rb +61 -16
- data/lib/vagrant/provisioners/puppet.rb +70 -38
- data/lib/vagrant/provisioners/puppet_server.rb +12 -13
- data/lib/vagrant/provisioners/shell.rb +24 -24
- data/lib/vagrant/provisioners.rb +10 -7
- data/lib/vagrant/registry.rb +49 -0
- data/lib/vagrant/ssh.rb +82 -153
- data/lib/vagrant/ui.rb +118 -50
- data/lib/vagrant/util/busy.rb +1 -1
- data/lib/vagrant/util/file_mode.rb +12 -0
- data/lib/vagrant/util/network_ip.rb +28 -0
- data/lib/vagrant/util/platform.rb +1 -0
- data/lib/vagrant/util/subprocess.rb +227 -0
- data/lib/vagrant/version.rb +1 -1
- data/lib/vagrant/vm.rb +111 -97
- data/lib/vagrant.rb +132 -5
- data/tasks/acceptance.rake +3 -3
- data/tasks/test.rake +7 -2
- data/templates/commands/init/Vagrantfile.erb +11 -4
- data/templates/{ssh_config.erb → commands/ssh_config/config.erb} +0 -0
- data/templates/guests/arch/network_dhcp.erb +7 -0
- data/templates/guests/arch/network_static.erb +7 -0
- data/templates/guests/debian/network_dhcp.erb +6 -0
- data/templates/guests/debian/network_static.erb +7 -0
- data/templates/guests/gentoo/network_dhcp.erb +4 -0
- data/templates/guests/gentoo/network_static.erb +4 -0
- data/templates/guests/redhat/network_dhcp.erb +6 -0
- data/templates/guests/redhat/network_static.erb +7 -0
- data/templates/locales/en.yml +241 -122
- data/templates/{chef_server_client.erb → provisioners/chef_client/client.erb} +0 -0
- data/templates/{chef_solo_solo.erb → provisioners/chef_solo/solo.erb} +0 -0
- data/test/acceptance/base.rb +10 -10
- data/test/acceptance/box_test.rb +28 -6
- data/test/acceptance/destroy_test.rb +1 -1
- data/test/acceptance/halt_test.rb +4 -4
- data/test/acceptance/init_test.rb +3 -3
- data/test/acceptance/networking/host_only_test.rb +37 -0
- data/test/acceptance/networking/port_forward_test.rb +125 -0
- data/test/acceptance/package_test.rb +46 -0
- data/test/acceptance/provisioning/basic_test.rb +61 -0
- data/test/acceptance/provisioning/chef_solo_test.rb +37 -0
- data/test/acceptance/provisioning/shell_test.rb +53 -0
- data/test/acceptance/resume_test.rb +1 -1
- data/test/acceptance/skeletons/chef_solo_basic/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_basic/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/skeletons/chef_solo_json/README.md +3 -0
- data/test/acceptance/skeletons/chef_solo_json/cookbooks/basic/recipes/default.rb +6 -0
- data/test/acceptance/skeletons/provisioner_multi/README.md +3 -0
- data/test/acceptance/skeletons/provisioner_multi/cookbooks/basic/recipes/default.rb +5 -0
- data/test/acceptance/ssh_test.rb +7 -2
- data/test/acceptance/support/config.rb +1 -1
- data/test/acceptance/support/isolated_environment.rb +41 -150
- data/test/acceptance/support/matchers/match_output.rb +1 -1
- data/test/acceptance/support/matchers/succeed.rb +14 -0
- data/test/acceptance/support/network_tests.rb +29 -0
- data/test/acceptance/support/output.rb +9 -1
- data/test/acceptance/support/shared/base_context.rb +16 -9
- data/test/acceptance/support/shared/command_examples.rb +4 -4
- data/test/acceptance/suspend_test.rb +1 -1
- data/test/acceptance/up_basic_test.rb +26 -7
- data/test/acceptance/up_with_box_url.rb +1 -1
- data/test/acceptance/vagrant_test.rb +1 -1
- data/test/acceptance/version_test.rb +0 -5
- data/test/support/isolated_environment.rb +46 -0
- data/test/{acceptance/support → support}/tempdir.rb +0 -0
- data/test/unit/base.rb +21 -0
- data/test/unit/support/isolated_environment.rb +39 -0
- data/test/unit/support/shared/base_context.rb +30 -0
- data/test/unit/vagrant/action/builder_test.rb +126 -177
- data/test/unit/vagrant/action/environment_test.rb +10 -21
- data/test/unit/vagrant/action/runner_test.rb +65 -0
- data/test/unit/vagrant/action/warden_test.rb +64 -97
- data/test/unit/vagrant/box_collection_test.rb +44 -33
- data/test/unit/vagrant/box_test.rb +25 -65
- data/test/unit/vagrant/command/base_test.rb +141 -14
- data/test/unit/vagrant/config/base_test.rb +16 -43
- data/test/unit/vagrant/config/loader_test.rb +79 -0
- data/test/unit/vagrant/config/top_test.rb +69 -0
- data/test/unit/vagrant/config/vm_test.rb +62 -47
- data/test/unit/vagrant/config_test.rb +16 -151
- data/test/unit/vagrant/data_store_test.rb +43 -61
- data/test/unit/vagrant/downloaders/base_test.rb +12 -22
- data/test/unit/vagrant/downloaders/file_test.rb +58 -31
- data/test/unit/vagrant/downloaders/http_test.rb +12 -86
- data/test/unit/vagrant/environment_test.rb +107 -536
- data/test/unit/vagrant/hosts_test.rb +36 -0
- data/test/unit/vagrant/registry_test.rb +56 -0
- data/test/unit/vagrant/util/file_checksum_test.rb +23 -0
- data/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +23 -24
- data/test/unit/vagrant/util/network_ip_test.rb +17 -0
- data/test/unit/vagrant/util/retryable_test.rb +90 -34
- data/test/unit/vagrant_test.rb +27 -0
- data/test/{unit → unit_legacy}/locales/en.yml +0 -0
- data/test/{unit → unit_legacy}/test_helper.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/destroy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/download_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/unpackage_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/box/verify_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/env/set_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/general/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/general/validate_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/boot_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_accessible_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_box_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/check_guest_additions_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clean_machine_folder_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_forwarded_ports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_nfs_exports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/clear_shared_folders_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/customize_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/discard_state_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/export_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/halt_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/host_name_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/import_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/match_mac_address_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/modify_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/network_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/package_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/package_vagrantfile_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/provision_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/provisioner_cleanup_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/resume_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/share_folders_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action/vm/suspend_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/action_test.rb +0 -0
- data/test/unit_legacy/vagrant/box_collection_test.rb +45 -0
- data/test/unit_legacy/vagrant/box_test.rb +74 -0
- data/test/{unit → unit_legacy}/vagrant/cli_test.rb +0 -0
- data/test/unit_legacy/vagrant/command/base_test.rb +23 -0
- data/test/{unit → unit_legacy}/vagrant/command/group_base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/helpers_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/init_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/command/package_test.rb +0 -0
- data/test/unit_legacy/vagrant/config/base_test.rb +52 -0
- data/test/{unit → unit_legacy}/vagrant/config/error_recorder_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/ssh_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/vagrant_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/config/vm/provisioner_test.rb +0 -0
- data/test/unit_legacy/vagrant/config/vm_test.rb +47 -0
- data/test/unit_legacy/vagrant/config_test.rb +148 -0
- data/test/unit_legacy/vagrant/downloaders/http_test.rb +93 -0
- data/test/unit_legacy/vagrant/environment_test.rb +539 -0
- data/test/{unit → unit_legacy}/vagrant/errors_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/bsd_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/hosts/linux_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/plugin_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_client_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_solo_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/chef_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_server_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/provisioners/shell_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/ssh/session_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/ssh_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/systems/base_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/systems/linux_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/busy_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/counter_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/platform_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/stacked_proc_runner_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/util/template_renderer_test.rb +0 -0
- data/test/{unit → unit_legacy}/vagrant/vm_test.rb +0 -0
- data/vagrant.gemspec +7 -9
- metadata +183 -179
- data/keys/vagrant.ppk +0 -26
- data/lib/vagrant/action/box.rb +0 -11
- data/lib/vagrant/action/env.rb +0 -7
- data/lib/vagrant/action/general.rb +0 -8
- data/lib/vagrant/action/vm/forward_ports_helpers.rb +0 -28
- data/lib/vagrant/action/vm/modify.rb +0 -37
- data/lib/vagrant/action/vm/nfs_helpers.rb +0 -11
- data/lib/vagrant/action/vm.rb +0 -34
- data/lib/vagrant/command/group_base.rb +0 -107
- data/lib/vagrant/command/helpers.rb +0 -33
- data/lib/vagrant/command/named_base.rb +0 -14
- data/lib/vagrant/command/upgrade_to_060.rb +0 -45
- data/lib/vagrant/command/version.rb +0 -13
- data/lib/vagrant/ssh/session.rb +0 -136
- data/lib/vagrant/systems/arch.rb +0 -34
- data/lib/vagrant/systems/debian.rb +0 -36
- data/lib/vagrant/systems/gentoo.rb +0 -27
- data/lib/vagrant/systems/linux/error.rb +0 -9
- data/lib/vagrant/systems/linux.rb +0 -82
- data/lib/vagrant/systems/redhat.rb +0 -48
- data/lib/vagrant/systems/solaris.rb +0 -113
- data/lib/vagrant/systems/ubuntu.rb +0 -17
- data/lib/vagrant/systems.rb +0 -13
- data/templates/network_entry_arch.erb +0 -9
- data/templates/network_entry_debian.erb +0 -8
- data/templates/network_entry_gentoo.erb +0 -5
- data/templates/network_entry_redhat.erb +0 -9
- data/test/unit/vagrant/ui_test.rb +0 -29
data/lib/vagrant/vm.rb
CHANGED
@@ -1,100 +1,98 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
|
1
3
|
module Vagrant
|
2
4
|
class VM
|
3
5
|
include Vagrant::Util
|
4
6
|
|
7
|
+
attr_reader :uuid
|
5
8
|
attr_reader :env
|
6
9
|
attr_reader :name
|
7
10
|
attr_reader :vm
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
attr_reader :box
|
12
|
+
attr_reader :config
|
13
|
+
attr_reader :driver
|
14
|
+
|
15
|
+
def initialize(name, env, config, opts=nil)
|
16
|
+
@logger = Log4r::Logger.new("vagrant::vm")
|
17
|
+
|
18
|
+
@name = name
|
19
|
+
@vm = nil
|
20
|
+
@env = env
|
21
|
+
@config = config
|
22
|
+
@box = env.boxes.find(config.vm.box)
|
23
|
+
|
24
|
+
opts ||= {}
|
25
|
+
if opts[:base]
|
26
|
+
# The name is the ID we use.
|
27
|
+
@uuid = name
|
28
|
+
else
|
29
|
+
# Load the UUID if its saved.
|
30
|
+
active = env.local_data[:active] || {}
|
31
|
+
@uuid = active[@name.to_s]
|
15
32
|
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def initialize(opts=nil)
|
19
|
-
defaults = {
|
20
|
-
:vm => nil,
|
21
|
-
:env => nil,
|
22
|
-
:name => nil
|
23
|
-
}
|
24
33
|
|
25
|
-
|
34
|
+
# Reload ourselves to get the state
|
35
|
+
reload!
|
26
36
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
if !opts[:env].nil?
|
31
|
-
# We have an environment, so we create a new child environment
|
32
|
-
# specifically for this VM. This step will load any custom
|
33
|
-
# config and such.
|
34
|
-
@env = Vagrant::Environment.new({
|
35
|
-
:cwd => opts[:env].cwd,
|
36
|
-
:parent => opts[:env],
|
37
|
-
:vm => self
|
38
|
-
}).load!
|
39
|
-
|
40
|
-
# Load the associated system.
|
41
|
-
load_system!
|
42
|
-
end
|
43
|
-
|
44
|
-
@loaded_system_distro = false
|
37
|
+
# Load the associated guest.
|
38
|
+
load_guest!
|
39
|
+
@loaded_guest_distro = false
|
45
40
|
end
|
46
41
|
|
47
|
-
# Loads the
|
42
|
+
# Loads the guest associated with the VM. The guest class is
|
48
43
|
# responsible for OS-specific functionality. More information
|
49
|
-
# can be found by reading the documentation on {Vagrant::
|
44
|
+
# can be found by reading the documentation on {Vagrant::Guest::Base}.
|
50
45
|
#
|
51
46
|
# **This method should never be called manually.**
|
52
|
-
def
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
if
|
57
|
-
raise Errors::
|
58
|
-
@
|
59
|
-
elsif
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
:ubuntu => Systems::Ubuntu,
|
64
|
-
:freebsd => Systems::FreeBSD,
|
65
|
-
:gentoo => Systems::Gentoo,
|
66
|
-
:redhat => Systems::Redhat,
|
67
|
-
:suse => Systems::Suse,
|
68
|
-
:linux => Systems::Linux,
|
69
|
-
:solaris => Systems::Solaris,
|
70
|
-
:arch => Systems::Arch
|
71
|
-
}
|
72
|
-
|
73
|
-
raise Errors::VMSystemError, :_key => :unknown_type, :system => system.to_s if !mapping.has_key?(system)
|
74
|
-
@system = mapping[system].new(self)
|
47
|
+
def load_guest!(guest=nil)
|
48
|
+
guest ||= config.vm.guest
|
49
|
+
@logger.info("Loading guest: #{guest}")
|
50
|
+
|
51
|
+
if guest.is_a?(Class)
|
52
|
+
raise Errors::VMGuestError, :_key => :invalid_class, :system => guest.to_s if !(guest <= Systems::Base)
|
53
|
+
@guest = guest.new(self)
|
54
|
+
elsif guest.is_a?(Symbol)
|
55
|
+
guest_klass = Vagrant.guests.get(guest)
|
56
|
+
raise Errors::VMGuestError, :_key => :unknown_type, :system => guest.to_s if !guest_klass
|
57
|
+
@guest = guest_klass.new(self)
|
75
58
|
else
|
76
|
-
raise Errors::
|
59
|
+
raise Errors::VMGuestError, :unspecified
|
77
60
|
end
|
78
61
|
end
|
79
62
|
|
80
|
-
# Returns
|
63
|
+
# Returns a channel object to communicate with the virtual
|
64
|
+
# machine.
|
65
|
+
def channel
|
66
|
+
@channel ||= Communication::SSH.new(self)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Returns the guest for this VM, loading the distro of the system if
|
81
70
|
# we can.
|
82
|
-
def
|
83
|
-
if !@
|
84
|
-
# Load the
|
85
|
-
result = @
|
86
|
-
|
87
|
-
@
|
71
|
+
def guest
|
72
|
+
if !@loaded_guest_distro && state == :running
|
73
|
+
# Load the guest distro for the first time
|
74
|
+
result = @guest.distro_dispatch
|
75
|
+
load_guest!(result)
|
76
|
+
@loaded_guest_distro = true
|
88
77
|
end
|
89
78
|
|
90
|
-
@
|
79
|
+
@guest
|
91
80
|
end
|
92
81
|
|
93
|
-
# Access the {Vagrant::SSH} object associated with this VM
|
94
|
-
#
|
95
|
-
# subsequent calls it will reuse the existing object.
|
82
|
+
# Access the {Vagrant::SSH} object associated with this VM, which
|
83
|
+
# is used to get SSH credentials with the virtual machine.
|
96
84
|
def ssh
|
97
|
-
@ssh ||= SSH.new(
|
85
|
+
@ssh ||= SSH.new(self)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Returns the state of the VM as a symbol.
|
89
|
+
#
|
90
|
+
# @return [Symbol]
|
91
|
+
def state
|
92
|
+
return :not_created if !@uuid
|
93
|
+
state = @driver.read_state
|
94
|
+
return :not_created if !state
|
95
|
+
return state
|
98
96
|
end
|
99
97
|
|
100
98
|
# Returns a boolean true if the VM has been created, otherwise
|
@@ -102,19 +100,17 @@ module Vagrant
|
|
102
100
|
#
|
103
101
|
# @return [Boolean]
|
104
102
|
def created?
|
105
|
-
|
103
|
+
state != :not_created
|
106
104
|
end
|
107
105
|
|
108
106
|
# Sets the currently active VM for this VM. If the VM is a valid,
|
109
107
|
# created virtual machine, then it will also update the local data
|
110
108
|
# to persist the VM. Otherwise, it will remove itself from the
|
111
109
|
# local data (if it exists).
|
112
|
-
def
|
113
|
-
@vm = value
|
110
|
+
def uuid=(value)
|
114
111
|
env.local_data[:active] ||= {}
|
115
|
-
|
116
|
-
|
117
|
-
env.local_data[:active][name.to_s] = value.uuid
|
112
|
+
if value
|
113
|
+
env.local_data[:active][name.to_s] = value
|
118
114
|
else
|
119
115
|
env.local_data[:active].delete(name.to_s)
|
120
116
|
end
|
@@ -122,60 +118,78 @@ module Vagrant
|
|
122
118
|
# Commit the local data so that the next time vagrant is initialized,
|
123
119
|
# it realizes the VM exists
|
124
120
|
env.local_data.commit
|
125
|
-
end
|
126
121
|
|
127
|
-
|
128
|
-
|
122
|
+
# Store the uuid and reload the instance
|
123
|
+
@uuid = value
|
124
|
+
reload!
|
129
125
|
end
|
130
126
|
|
131
127
|
def reload!
|
132
|
-
|
128
|
+
begin
|
129
|
+
@driver = Driver::VirtualBox.new(@uuid)
|
130
|
+
rescue Driver::VirtualBox::VMNotFound
|
131
|
+
# Clear the UUID since this VM doesn't exist. Note that this calls
|
132
|
+
# back into `reload!` but shouldn't ever result in infinite
|
133
|
+
# recursion since `@uuid` will be nil.
|
134
|
+
self.uuid = nil
|
135
|
+
end
|
133
136
|
end
|
134
137
|
|
135
138
|
def package(options=nil)
|
136
|
-
|
139
|
+
run_action(:package, { "validate" => false }.merge(options || {}))
|
137
140
|
end
|
138
141
|
|
139
142
|
def up(options=nil)
|
140
|
-
|
143
|
+
run_action(:up, options)
|
141
144
|
end
|
142
145
|
|
143
146
|
def start(options=nil)
|
144
|
-
|
145
|
-
return if
|
146
|
-
return resume if @vm.saved?
|
147
|
+
return if state == :running
|
148
|
+
return resume if state == :saved
|
147
149
|
|
148
|
-
|
150
|
+
run_action(:start, options)
|
149
151
|
end
|
150
152
|
|
151
153
|
def halt(options=nil)
|
152
|
-
|
154
|
+
run_action(:halt, options)
|
153
155
|
end
|
154
156
|
|
155
157
|
def reload
|
156
|
-
|
158
|
+
run_action(:reload)
|
157
159
|
end
|
158
160
|
|
159
161
|
def provision
|
160
|
-
|
162
|
+
run_action(:provision)
|
161
163
|
end
|
162
164
|
|
163
165
|
def destroy
|
164
|
-
|
166
|
+
run_action(:destroy)
|
165
167
|
end
|
166
168
|
|
167
169
|
def suspend
|
168
|
-
|
170
|
+
run_action(:suspend)
|
169
171
|
end
|
170
172
|
|
171
173
|
def resume
|
172
|
-
|
174
|
+
run_action(:resume)
|
173
175
|
end
|
174
176
|
|
175
|
-
def
|
176
|
-
@
|
177
|
+
def ui
|
178
|
+
return @_ui if defined?(@_ui)
|
179
|
+
@_ui = @env.ui.dup
|
180
|
+
@_ui.resource = @name
|
181
|
+
@_ui
|
177
182
|
end
|
178
183
|
|
179
|
-
|
184
|
+
protected
|
185
|
+
|
186
|
+
def run_action(name, options=nil)
|
187
|
+
options = {
|
188
|
+
:vm => self,
|
189
|
+
:ui => ui
|
190
|
+
}.merge(options || {})
|
191
|
+
|
192
|
+
env.action_runner.run(name, options)
|
193
|
+
end
|
180
194
|
end
|
181
195
|
end
|
data/lib/vagrant.rb
CHANGED
@@ -1,7 +1,36 @@
|
|
1
|
+
# Enable logging if it is requested. We do this before
|
2
|
+
# anything else so that we can setup the output before
|
3
|
+
# any logging occurs.
|
4
|
+
if ENV["VAGRANT_LOG"] && ENV["VAGRANT_LOG"] != ""
|
5
|
+
# Require Log4r and define the levels we'll be using
|
6
|
+
require 'log4r'
|
7
|
+
require 'log4r/config'
|
8
|
+
Log4r.define_levels(*Log4r::Log4rConfig::LogLevels)
|
9
|
+
|
10
|
+
level = nil
|
11
|
+
begin
|
12
|
+
level = Log4r.const_get(ENV["VAGRANT_LOG"].upcase)
|
13
|
+
rescue NameError
|
14
|
+
# This means that the logging constant wasn't found,
|
15
|
+
# which is fine. We just keep `level` as `nil`. But
|
16
|
+
# we tell the user.
|
17
|
+
$stderr.puts "Invalid VAGRANT_LOG level is set: #{ENV["VAGRANT_LOG"]}"
|
18
|
+
end
|
19
|
+
|
20
|
+
# Set the logging level on all "vagrant" namespaced
|
21
|
+
# logs as long as we have a valid level.
|
22
|
+
if level
|
23
|
+
logger = Log4r::Logger.new("vagrant")
|
24
|
+
logger.outputters = Log4r::Outputter.stdout
|
25
|
+
logger.level = level
|
26
|
+
logger = nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
1
30
|
require 'pathname'
|
31
|
+
require 'childprocess'
|
2
32
|
require 'json'
|
3
33
|
require 'i18n'
|
4
|
-
require 'virtualbox'
|
5
34
|
|
6
35
|
# OpenSSL must be loaded here since when it is loaded via `autoload`
|
7
36
|
# there are issues with ciphers not being properly loaded.
|
@@ -12,13 +41,19 @@ module Vagrant
|
|
12
41
|
autoload :Box, 'vagrant/box'
|
13
42
|
autoload :BoxCollection, 'vagrant/box_collection'
|
14
43
|
autoload :CLI, 'vagrant/cli'
|
44
|
+
autoload :Command, 'vagrant/command'
|
45
|
+
autoload :Communication, 'vagrant/communication'
|
15
46
|
autoload :Config, 'vagrant/config'
|
16
47
|
autoload :DataStore, 'vagrant/data_store'
|
17
48
|
autoload :Downloaders, 'vagrant/downloaders'
|
49
|
+
autoload :Driver, 'vagrant/driver'
|
18
50
|
autoload :Environment, 'vagrant/environment'
|
19
51
|
autoload :Errors, 'vagrant/errors'
|
52
|
+
autoload :Guest, 'vagrant/guest'
|
20
53
|
autoload :Hosts, 'vagrant/hosts'
|
21
54
|
autoload :Plugin, 'vagrant/plugin'
|
55
|
+
autoload :Provisioners, 'vagrant/provisioners'
|
56
|
+
autoload :Registry, 'vagrant/registry'
|
22
57
|
autoload :SSH, 'vagrant/ssh'
|
23
58
|
autoload :TestHelpers, 'vagrant/test_helpers'
|
24
59
|
autoload :UI, 'vagrant/ui'
|
@@ -30,15 +65,107 @@ module Vagrant
|
|
30
65
|
def self.source_root
|
31
66
|
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
32
67
|
end
|
68
|
+
|
69
|
+
# Global registry of commands that are available via the CLI.
|
70
|
+
#
|
71
|
+
# This registry is used to look up the sub-commands that are available
|
72
|
+
# to Vagrant.
|
73
|
+
def self.commands
|
74
|
+
@commands ||= Registry.new
|
75
|
+
end
|
76
|
+
|
77
|
+
# Global registry of config keys that are available.
|
78
|
+
#
|
79
|
+
# This registry is used to look up the keys for `config` objects.
|
80
|
+
# For example, `config.vagrant` looks up the `:vagrant` config key
|
81
|
+
# for the configuration class to use.
|
82
|
+
def self.config_keys
|
83
|
+
@config_keys ||= Registry.new
|
84
|
+
end
|
85
|
+
|
86
|
+
# Global registry of available host classes and shortcut symbols
|
87
|
+
# associated with them.
|
88
|
+
#
|
89
|
+
# This registry is used to look up the shorcuts for `config.vagrant.host`,
|
90
|
+
# or to query all hosts for automatically detecting the host system.
|
91
|
+
# The registry is global to all of Vagrant.
|
92
|
+
def self.hosts
|
93
|
+
@hosts ||= Registry.new
|
94
|
+
end
|
95
|
+
|
96
|
+
# Global registry of available guest classes and shortcut symbols
|
97
|
+
# associated with them.
|
98
|
+
#
|
99
|
+
# This registry is used to look up the shortcuts for `config.vm.guest`.
|
100
|
+
def self.guests
|
101
|
+
@guests ||= Registry.new
|
102
|
+
end
|
103
|
+
|
104
|
+
# Global registry of provisioners.
|
105
|
+
#
|
106
|
+
# This registry is used to look up the provisioners provided for
|
107
|
+
# `config.vm.provision`.
|
108
|
+
def self.provisioners
|
109
|
+
@provisioners ||= Registry.new
|
110
|
+
end
|
33
111
|
end
|
34
112
|
|
35
113
|
# # Default I18n to load the en locale
|
36
114
|
I18n.load_path << File.expand_path("templates/locales/en.yml", Vagrant.source_root)
|
37
115
|
|
116
|
+
# Register the built-in commands
|
117
|
+
Vagrant.commands.register(:box) { Vagrant::Command::Box }
|
118
|
+
Vagrant.commands.register(:destroy) { Vagrant::Command::Destroy }
|
119
|
+
Vagrant.commands.register(:halt) { Vagrant::Command::Halt }
|
120
|
+
Vagrant.commands.register(:init) { Vagrant::Command::Init }
|
121
|
+
Vagrant.commands.register(:package) { Vagrant::Command::Package }
|
122
|
+
Vagrant.commands.register(:provision) { Vagrant::Command::Provision }
|
123
|
+
Vagrant.commands.register(:reload) { Vagrant::Command::Reload }
|
124
|
+
Vagrant.commands.register(:resume) { Vagrant::Command::Resume }
|
125
|
+
Vagrant.commands.register(:ssh) { Vagrant::Command::SSH }
|
126
|
+
Vagrant.commands.register(:"ssh-config") { Vagrant::Command::SSHConfig }
|
127
|
+
Vagrant.commands.register(:status) { Vagrant::Command::Status }
|
128
|
+
Vagrant.commands.register(:suspend) { Vagrant::Command::Suspend }
|
129
|
+
Vagrant.commands.register(:up) { Vagrant::Command::Up }
|
130
|
+
|
131
|
+
# Register the built-in config keys
|
132
|
+
Vagrant.config_keys.register(:vagrant) { Vagrant::Config::VagrantConfig }
|
133
|
+
Vagrant.config_keys.register(:ssh) { Vagrant::Config::SSHConfig }
|
134
|
+
Vagrant.config_keys.register(:nfs) { Vagrant::Config::NFSConfig }
|
135
|
+
Vagrant.config_keys.register(:vm) { Vagrant::Config::VMConfig }
|
136
|
+
Vagrant.config_keys.register(:package) { Vagrant::Config::PackageConfig }
|
137
|
+
|
138
|
+
# Register the built-in hosts
|
139
|
+
Vagrant.hosts.register(:arch) { Vagrant::Hosts::Arch }
|
140
|
+
Vagrant.hosts.register(:bsd) { Vagrant::Hosts::BSD }
|
141
|
+
Vagrant.hosts.register(:fedora) { Vagrant::Hosts::Fedora }
|
142
|
+
Vagrant.hosts.register(:freebsd) { Vagrant::Hosts::FreeBSD }
|
143
|
+
Vagrant.hosts.register(:linux) { Vagrant::Hosts::Linux }
|
144
|
+
Vagrant.hosts.register(:windows) { Vagrant::Hosts::Windows }
|
145
|
+
|
146
|
+
# Register the built-in guests
|
147
|
+
Vagrant.guests.register(:arch) { Vagrant::Guest::Arch }
|
148
|
+
Vagrant.guests.register(:debian) { Vagrant::Guest::Debian }
|
149
|
+
Vagrant.guests.register(:freebsd) { Vagrant::Guest::FreeBSD }
|
150
|
+
Vagrant.guests.register(:gentoo) { Vagrant::Guest::Gentoo }
|
151
|
+
Vagrant.guests.register(:linux) { Vagrant::Guest::Linux }
|
152
|
+
Vagrant.guests.register(:redhat) { Vagrant::Guest::Redhat }
|
153
|
+
Vagrant.guests.register(:solaris) { Vagrant::Guest::Solaris }
|
154
|
+
Vagrant.guests.register(:suse) { Vagrant::Guest::Suse }
|
155
|
+
Vagrant.guests.register(:ubuntu) { Vagrant::Guest::Ubuntu }
|
156
|
+
|
157
|
+
# Register the built-in provisioners
|
158
|
+
Vagrant.provisioners.register(:chef_solo) { Vagrant::Provisioners::ChefSolo }
|
159
|
+
Vagrant.provisioners.register(:chef_client) { Vagrant::Provisioners::ChefClient }
|
160
|
+
Vagrant.provisioners.register(:puppet) { Vagrant::Provisioners::Puppet }
|
161
|
+
Vagrant.provisioners.register(:puppet_server) { Vagrant::Provisioners::PuppetServer }
|
162
|
+
Vagrant.provisioners.register(:shell) { Vagrant::Provisioners::Shell }
|
163
|
+
|
164
|
+
# Register the built-in systems
|
165
|
+
Vagrant.config_keys.register(:freebsd) { Vagrant::Guest::FreeBSD::FreeBSDConfig }
|
166
|
+
Vagrant.config_keys.register(:linux) { Vagrant::Guest::Linux::LinuxConfig }
|
167
|
+
Vagrant.config_keys.register(:solaris) { Vagrant::Guest::Solaris::SolarisConfig }
|
168
|
+
|
38
169
|
# Load the things which must be loaded before anything else.
|
39
|
-
require 'vagrant/command'
|
40
|
-
require 'vagrant/provisioners'
|
41
|
-
require 'vagrant/systems'
|
42
170
|
require 'vagrant/version'
|
43
|
-
Vagrant::Action.builtin!
|
44
171
|
Vagrant::Plugin.load!
|
data/tasks/acceptance.rake
CHANGED
@@ -12,7 +12,7 @@ namespace :acceptance do
|
|
12
12
|
desc "Downloads the boxes required for running the acceptance tests."
|
13
13
|
task :boxes, :directory do |t, args|
|
14
14
|
# Create the directory where the boxes will be downloaded
|
15
|
-
box_dir = Pathname.new(args[:directory] || File.expand_path("../../
|
15
|
+
box_dir = Pathname.new(args[:directory] || File.expand_path("../../boxes", __FILE__))
|
16
16
|
box_dir.mkpath
|
17
17
|
puts "Boxes will be placed in: #{box_dir}"
|
18
18
|
|
@@ -73,10 +73,10 @@ namespace :acceptance do
|
|
73
73
|
desc "Generates the configuration for acceptance tests from current source."
|
74
74
|
task :config, :box_dir do |t, args|
|
75
75
|
require File.expand_path("../../lib/vagrant/version", __FILE__)
|
76
|
-
require File.expand_path('../../test/
|
76
|
+
require File.expand_path('../../test/support/tempdir', __FILE__)
|
77
77
|
|
78
78
|
# Get the directory for the boxes
|
79
|
-
box_dir = Pathname.new(args[:box_dir] || File.expand_path("../../
|
79
|
+
box_dir = Pathname.new(args[:box_dir] || File.expand_path("../../boxes", __FILE__))
|
80
80
|
|
81
81
|
# Generate the binstubs for the Vagrant binary
|
82
82
|
tempdir = Tempdir.new
|
data/tasks/test.rake
CHANGED
@@ -2,12 +2,17 @@ require 'rake/testtask'
|
|
2
2
|
require 'rspec/core/rake_task'
|
3
3
|
|
4
4
|
namespace :test do
|
5
|
-
|
5
|
+
RSpec::Core::RakeTask.new do |t|
|
6
6
|
t.name = "unit"
|
7
|
-
t.libs << "test/unit"
|
8
7
|
t.pattern = "test/unit/**/*_test.rb"
|
9
8
|
end
|
10
9
|
|
10
|
+
Rake::TestTask.new do |t|
|
11
|
+
t.name = "unit_old"
|
12
|
+
t.libs << "test/unit_legacy"
|
13
|
+
t.pattern = "test/unit_legacy/**/*_test.rb"
|
14
|
+
end
|
15
|
+
|
11
16
|
RSpec::Core::RakeTask.new do |t|
|
12
17
|
t.name = "acceptance"
|
13
18
|
t.pattern = "test/acceptance/**/*_test.rb"
|
@@ -16,13 +16,20 @@ Vagrant::Config.run do |config|
|
|
16
16
|
# Boot with a GUI so you can see the screen. (Default is headless)
|
17
17
|
# config.vm.boot_mode = :gui
|
18
18
|
|
19
|
-
# Assign this VM to a host
|
20
|
-
# via the IP.
|
21
|
-
#
|
19
|
+
# Assign this VM to a host-only network IP, allowing you to access it
|
20
|
+
# via the IP. Host-only networks can talk to the host machine as well as
|
21
|
+
# any other machines on the same network, but cannot be accessed (through this
|
22
|
+
# network interface) by any external networks.
|
23
|
+
# config.vm.network :hostonly, "33.33.33.10"
|
24
|
+
|
25
|
+
# Assign this VM to a bridged network, allowing you to connect directly to a
|
26
|
+
# network using the host's network device. This makes the VM appear as another
|
27
|
+
# physical device on your network.
|
28
|
+
# config.vm.network :bridged
|
22
29
|
|
23
30
|
# Forward a port from the guest to the host, which allows for outside
|
24
31
|
# computers to access the VM, whereas host only networking does not.
|
25
|
-
# config.vm.forward_port
|
32
|
+
# config.vm.forward_port 80, 8080
|
26
33
|
|
27
34
|
# Share an additional folder to the guest VM. The first argument is
|
28
35
|
# an identifier, the second is the path on the guest to mount the
|
File without changes
|