vagrant 0.8.10 → 0.9.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 +77 -1
- data/Gemfile +0 -14
- data/LICENSE +1 -1
- data/bin/vagrant +47 -20
- data/config/default.rb +6 -14
- data/lib/vagrant.rb +132 -5
- data/lib/vagrant/action.rb +45 -123
- 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/box.rb +9 -55
- data/lib/vagrant/box_collection.rb +22 -17
- data/lib/vagrant/cli.rb +62 -47
- data/lib/vagrant/command.rb +18 -20
- 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/communication.rb +7 -0
- data/lib/vagrant/communication/base.rb +56 -0
- data/lib/vagrant/communication/ssh.rb +200 -0
- data/lib/vagrant/config.rb +29 -103
- 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.rb +115 -56
- data/lib/vagrant/config/vm/provisioner.rb +16 -20
- data/lib/vagrant/config/vm/sub_vm.rb +1 -1
- 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.rb +7 -0
- 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/environment.rb +221 -240
- data/lib/vagrant/errors.rb +74 -25
- data/lib/vagrant/guest.rb +16 -0
- 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/guest/linux.rb +78 -0
- data/lib/vagrant/{systems → guest}/linux/config.rb +2 -4
- data/lib/vagrant/guest/linux/error.rb +9 -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/hosts.rb +23 -6
- 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/provisioners.rb +10 -7
- 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/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/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 +214 -216
- 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.rb +0 -34
- 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/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.rb +0 -13
- 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.rb +0 -82
- data/lib/vagrant/systems/linux/error.rb +0 -9
- 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/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
@@ -0,0 +1,411 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
|
3
|
+
require 'vagrant/driver/virtualbox_base'
|
4
|
+
|
5
|
+
module Vagrant
|
6
|
+
module Driver
|
7
|
+
# Driver for VirtualBox 4.1.x
|
8
|
+
class VirtualBox_4_1 < VirtualBoxBase
|
9
|
+
def initialize(uuid)
|
10
|
+
super()
|
11
|
+
|
12
|
+
@logger = Log4r::Logger.new("vagrant::driver::virtualbox_4_1")
|
13
|
+
@uuid = uuid
|
14
|
+
end
|
15
|
+
|
16
|
+
def clear_forwarded_ports
|
17
|
+
args = []
|
18
|
+
read_forwarded_ports(@uuid).each do |nic, name, _, _|
|
19
|
+
args.concat(["--natpf#{nic}", "delete", name])
|
20
|
+
end
|
21
|
+
|
22
|
+
execute("modifyvm", @uuid, *args) if !args.empty?
|
23
|
+
end
|
24
|
+
|
25
|
+
def clear_shared_folders
|
26
|
+
execute("showvminfo", @uuid, "--machinereadable").split("\n").each do |line|
|
27
|
+
if line =~ /^SharedFolderNameMachineMapping\d+="(.+?)"$/
|
28
|
+
execute("sharedfolder", "remove", @uuid, "--name", $1.to_s)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_dhcp_server(network, options)
|
34
|
+
execute("dhcpserver", "add", "--ifname", network,
|
35
|
+
"--ip", options[:dhcp_ip],
|
36
|
+
"--netmask", options[:netmask],
|
37
|
+
"--lowerip", options[:dhcp_lower],
|
38
|
+
"--upperip", options[:dhcp_upper],
|
39
|
+
"--enable")
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_host_only_network(options)
|
43
|
+
# Create the interface
|
44
|
+
execute("hostonlyif", "create") =~ /^Interface '(.+?)' was successfully created$/
|
45
|
+
name = $1.to_s
|
46
|
+
|
47
|
+
# Configure it
|
48
|
+
execute("hostonlyif", "ipconfig", name,
|
49
|
+
"--ip", options[:adapter_ip],
|
50
|
+
"--netmask", options[:netmask])
|
51
|
+
|
52
|
+
# Return the details
|
53
|
+
return {
|
54
|
+
:name => name,
|
55
|
+
:ip => options[:adapter_ip],
|
56
|
+
:netmask => options[:netmask],
|
57
|
+
:dhcp => nil
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
def delete
|
62
|
+
execute("unregistervm", @uuid, "--delete")
|
63
|
+
end
|
64
|
+
|
65
|
+
def delete_unused_host_only_networks
|
66
|
+
networks = []
|
67
|
+
execute("list", "hostonlyifs").split("\n").each do |line|
|
68
|
+
networks << $1.to_s if line =~ /^Name:\s+(.+?)$/
|
69
|
+
end
|
70
|
+
|
71
|
+
execute("list", "vms").split("\n").each do |line|
|
72
|
+
if line =~ /^".+?"\s+\{(.+?)\}$/
|
73
|
+
execute("showvminfo", $1.to_s, "--machinereadable").split("\n").each do |info|
|
74
|
+
if info =~ /^hostonlyadapter\d+="(.+?)"$/
|
75
|
+
networks.delete($1.to_s)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
networks.each do |name|
|
82
|
+
# First try to remove any DHCP servers attached. We use `raw` because
|
83
|
+
# it is okay if this fails. It usually means that a DHCP server was
|
84
|
+
# never attached.
|
85
|
+
raw("dhcpserver", "remove", "--ifname", name)
|
86
|
+
|
87
|
+
# Delete the actual host only network interface.
|
88
|
+
execute("hostonlyif", "remove", name)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def discard_saved_state
|
93
|
+
execute("discardstate", @uuid)
|
94
|
+
end
|
95
|
+
|
96
|
+
def enable_adapters(adapters)
|
97
|
+
args = []
|
98
|
+
adapters.each do |adapter|
|
99
|
+
args.concat(["--nic#{adapter[:adapter]}", adapter[:type].to_s])
|
100
|
+
|
101
|
+
if adapter[:bridge]
|
102
|
+
args.concat(["--bridgeadapter#{adapter[:adapter]}",
|
103
|
+
adapter[:bridge]])
|
104
|
+
end
|
105
|
+
|
106
|
+
if adapter[:hostonly]
|
107
|
+
args.concat(["--hostonlyadapter#{adapter[:adapter]}",
|
108
|
+
adapter[:hostonly]])
|
109
|
+
end
|
110
|
+
|
111
|
+
if adapter[:mac_address]
|
112
|
+
args.concat(["--macaddress#{adapter[:adapter]}",
|
113
|
+
adapter[:mac_address]])
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
execute("modifyvm", @uuid, *args)
|
118
|
+
end
|
119
|
+
|
120
|
+
def execute_command(command)
|
121
|
+
raw(*command)
|
122
|
+
end
|
123
|
+
|
124
|
+
def export(path)
|
125
|
+
# TODO: Progress
|
126
|
+
execute("export", @uuid, "--output", path.to_s)
|
127
|
+
end
|
128
|
+
|
129
|
+
def forward_ports(ports)
|
130
|
+
args = []
|
131
|
+
ports.each do |options|
|
132
|
+
pf_builder = [options[:name],
|
133
|
+
options[:protocol] || "tcp",
|
134
|
+
"",
|
135
|
+
options[:hostport],
|
136
|
+
"",
|
137
|
+
options[:guestport]]
|
138
|
+
|
139
|
+
args.concat(["--natpf#{options[:adapter] || 1}",
|
140
|
+
pf_builder.join(",")])
|
141
|
+
end
|
142
|
+
|
143
|
+
execute("modifyvm", @uuid, *args)
|
144
|
+
end
|
145
|
+
|
146
|
+
def halt
|
147
|
+
execute("controlvm", @uuid, "poweroff")
|
148
|
+
end
|
149
|
+
|
150
|
+
def import(ovf, name)
|
151
|
+
total = ""
|
152
|
+
last = 0
|
153
|
+
execute("import", ovf, "--vsys", "0", "--vmname", name) do |type, data|
|
154
|
+
if type == :stderr
|
155
|
+
# Append the data so we can see the full view
|
156
|
+
total << data
|
157
|
+
|
158
|
+
# Break up the lines. We can't get the progress until we see an "OK"
|
159
|
+
lines = total.split("\n")
|
160
|
+
if lines.include?("OK.")
|
161
|
+
# The progress of the import will be in the last line. Do a greedy
|
162
|
+
# regular expression to find what we're looking for.
|
163
|
+
if lines.last =~ /.+(\d{2})%/
|
164
|
+
current = $1.to_i
|
165
|
+
if current > last
|
166
|
+
last = current
|
167
|
+
yield current if block_given?
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
output = execute("list", "vms")
|
175
|
+
if output =~ /^"#{name}" \{(.+?)\}$/
|
176
|
+
return $1.to_s
|
177
|
+
end
|
178
|
+
|
179
|
+
nil
|
180
|
+
end
|
181
|
+
|
182
|
+
def read_forwarded_ports(uuid=nil, active_only=false)
|
183
|
+
uuid ||= @uuid
|
184
|
+
|
185
|
+
@logger.debug("read_forward_ports: uuid=#{uuid} active_only=#{active_only}")
|
186
|
+
|
187
|
+
results = []
|
188
|
+
current_nic = nil
|
189
|
+
execute("showvminfo", uuid, "--machinereadable").split("\n").each do |line|
|
190
|
+
# This is how we find the nic that a FP is attached to,
|
191
|
+
# since this comes first.
|
192
|
+
current_nic = $1.to_i if line =~ /^nic(\d+)=".+?"$/
|
193
|
+
|
194
|
+
# If we care about active VMs only, then we check the state
|
195
|
+
# to verify the VM is running.
|
196
|
+
if active_only && line =~ /^VMState="(.+?)"$/ && $1.to_s != "running"
|
197
|
+
return []
|
198
|
+
end
|
199
|
+
|
200
|
+
# Parse out the forwarded port information
|
201
|
+
if line =~ /^Forwarding.+?="(.+?),.+?,.*?,(.+?),.*?,(.+?)"$/
|
202
|
+
result = [current_nic, $1.to_s, $2.to_i, $3.to_i]
|
203
|
+
@logger.debug(" - #{result.inspect}")
|
204
|
+
results << result
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
results
|
209
|
+
end
|
210
|
+
|
211
|
+
def read_bridged_interfaces
|
212
|
+
execute("list", "bridgedifs").split("\n\n").collect do |block|
|
213
|
+
info = {}
|
214
|
+
|
215
|
+
block.split("\n").each do |line|
|
216
|
+
if line =~ /^Name:\s+(.+?)$/
|
217
|
+
info[:name] = $1.to_s
|
218
|
+
elsif line =~ /^IPAddress:\s+(.+?)$/
|
219
|
+
info[:ip] = $1.to_s
|
220
|
+
elsif line =~ /^NetworkMask:\s+(.+?)$/
|
221
|
+
info[:netmask] = $1.to_s
|
222
|
+
elsif line =~ /^Status:\s+(.+?)$/
|
223
|
+
info[:status] = $1.to_s
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
# Return the info to build up the results
|
228
|
+
info
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
def read_guest_additions_version
|
233
|
+
output = execute("guestproperty", "get", @uuid, "/VirtualBox/GuestAdd/Version")
|
234
|
+
if output =~ /^Value: (.+?)$/
|
235
|
+
# Split the version by _ since some distro versions modify it
|
236
|
+
# to look like this: 4.1.2_ubuntu, and the distro part isn't
|
237
|
+
# too important.
|
238
|
+
value = $1.to_s
|
239
|
+
return value.split("_").first
|
240
|
+
end
|
241
|
+
|
242
|
+
return nil
|
243
|
+
end
|
244
|
+
|
245
|
+
def read_host_only_interfaces
|
246
|
+
dhcp = {}
|
247
|
+
execute("list", "dhcpservers").split("\n\n").each do |block|
|
248
|
+
info = {}
|
249
|
+
|
250
|
+
block.split("\n").each do |line|
|
251
|
+
if line =~ /^NetworkName:\s+HostInterfaceNetworking-(.+?)$/
|
252
|
+
info[:network] = $1.to_s
|
253
|
+
elsif line =~ /^IP:\s+(.+?)$/
|
254
|
+
info[:ip] = $1.to_s
|
255
|
+
elsif line =~ /^lowerIPAddress:\s+(.+?)$/
|
256
|
+
info[:lower] = $1.to_s
|
257
|
+
elsif line =~ /^upperIPAddress:\s+(.+?)$/
|
258
|
+
info[:upper] = $1.to_s
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
# Set the DHCP info
|
263
|
+
dhcp[info[:network]] = info
|
264
|
+
end
|
265
|
+
|
266
|
+
execute("list", "hostonlyifs").split("\n\n").collect do |block|
|
267
|
+
info = {}
|
268
|
+
|
269
|
+
block.split("\n").each do |line|
|
270
|
+
if line =~ /^Name:\s+(.+?)$/
|
271
|
+
info[:name] = $1.to_s
|
272
|
+
elsif line =~ /^IPAddress:\s+(.+?)$/
|
273
|
+
info[:ip] = $1.to_s
|
274
|
+
elsif line =~ /^NetworkMask:\s+(.+?)$/
|
275
|
+
info[:netmask] = $1.to_s
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
# Set the DHCP info if it exists
|
280
|
+
info[:dhcp] = dhcp[info[:name]] if dhcp[info[:name]]
|
281
|
+
|
282
|
+
info
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
def read_mac_address
|
287
|
+
execute("showvminfo", @uuid, "--machinereadable").split("\n").each do |line|
|
288
|
+
return $1.to_s if line =~ /^macaddress1="(.+?)"$/
|
289
|
+
end
|
290
|
+
|
291
|
+
nil
|
292
|
+
end
|
293
|
+
|
294
|
+
def read_machine_folder
|
295
|
+
execute("list", "systemproperties").split("\n").each do |line|
|
296
|
+
if line =~ /^Default machine folder:\s+(.+?)$/i
|
297
|
+
return $1.to_s
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
nil
|
302
|
+
end
|
303
|
+
|
304
|
+
def read_network_interfaces
|
305
|
+
nics = {}
|
306
|
+
execute("showvminfo", @uuid, "--machinereadable").split("\n").each do |line|
|
307
|
+
if line =~ /^nic(\d+)="(.+?)"$/
|
308
|
+
adapter = $1.to_i
|
309
|
+
type = $2.to_sym
|
310
|
+
|
311
|
+
nics[adapter] ||= {}
|
312
|
+
nics[adapter][:type] = type
|
313
|
+
elsif line =~ /^hostonlyadapter(\d+)="(.+?)"$/
|
314
|
+
adapter = $1.to_i
|
315
|
+
network = $2.to_s
|
316
|
+
|
317
|
+
nics[adapter] ||= {}
|
318
|
+
nics[adapter][:hostonly] = network
|
319
|
+
elsif line =~ /^bridgeadapter(\d+)="(.+?)"$/
|
320
|
+
adapter = $1.to_i
|
321
|
+
network = $2.to_s
|
322
|
+
|
323
|
+
nics[adapter] ||= {}
|
324
|
+
nics[adapter][:bridge] = network
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
nics
|
329
|
+
end
|
330
|
+
|
331
|
+
def read_state
|
332
|
+
output = execute("showvminfo", @uuid, "--machinereadable")
|
333
|
+
if output =~ /^name="<inaccessible>"$/
|
334
|
+
return :inaccessible
|
335
|
+
elsif output =~ /^VMState="(.+?)"$/
|
336
|
+
return $1.to_sym
|
337
|
+
end
|
338
|
+
|
339
|
+
nil
|
340
|
+
end
|
341
|
+
|
342
|
+
def read_used_ports
|
343
|
+
ports = []
|
344
|
+
execute("list", "vms").split("\n").each do |line|
|
345
|
+
if line =~ /^".+?" \{(.+?)\}$/
|
346
|
+
uuid = $1.to_s
|
347
|
+
|
348
|
+
# Ignore our own used ports
|
349
|
+
next if uuid == @uuid
|
350
|
+
|
351
|
+
read_forwarded_ports(uuid, true).each do |_, _, hostport, _|
|
352
|
+
ports << hostport
|
353
|
+
end
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
ports
|
358
|
+
end
|
359
|
+
|
360
|
+
def read_vms
|
361
|
+
results = []
|
362
|
+
execute("list", "vms").split("\n").each do |line|
|
363
|
+
if line =~ /^".+?" \{(.+?)\}$/
|
364
|
+
results << $1.to_s
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
results
|
369
|
+
end
|
370
|
+
|
371
|
+
def set_mac_address(mac)
|
372
|
+
execute("modifyvm", @uuid, "--macaddress1", mac)
|
373
|
+
end
|
374
|
+
|
375
|
+
def share_folders(folders)
|
376
|
+
folders.each do |folder|
|
377
|
+
execute("sharedfolder", "add", @uuid, "--name",
|
378
|
+
folder[:name], "--hostpath", folder[:hostpath])
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
def ssh_port(expected_port)
|
383
|
+
@logger.debug("Searching for SSH port: #{expected_port.inspect}")
|
384
|
+
|
385
|
+
# Look for the forwarded port only by comparing the guest port
|
386
|
+
read_forwarded_ports.each do |_, _, hostport, guestport|
|
387
|
+
return hostport if guestport == expected_port
|
388
|
+
end
|
389
|
+
|
390
|
+
nil
|
391
|
+
end
|
392
|
+
|
393
|
+
def start(mode)
|
394
|
+
execute("startvm", @uuid, "--type", mode.to_s)
|
395
|
+
end
|
396
|
+
|
397
|
+
def suspend
|
398
|
+
execute("controlvm", @uuid, "savestate")
|
399
|
+
end
|
400
|
+
|
401
|
+
def verify_image(path)
|
402
|
+
r = raw("import", path.to_s, "--dry-run")
|
403
|
+
return r.exit_code == 0
|
404
|
+
end
|
405
|
+
|
406
|
+
def vm_exists?(uuid)
|
407
|
+
raw("showvminfo", uuid).exit_code == 0
|
408
|
+
end
|
409
|
+
end
|
410
|
+
end
|
411
|
+
end
|
@@ -0,0 +1,284 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
|
3
|
+
require 'vagrant/util/busy'
|
4
|
+
require 'vagrant/util/platform'
|
5
|
+
require 'vagrant/util/subprocess'
|
6
|
+
|
7
|
+
module Vagrant
|
8
|
+
module Driver
|
9
|
+
# Base class for all VirtualBox drivers.
|
10
|
+
#
|
11
|
+
# This class provides useful tools for things such as executing
|
12
|
+
# VBoxManage and handling SIGINTs and so on.
|
13
|
+
class VirtualBoxBase
|
14
|
+
# Include this so we can use `Subprocess` more easily.
|
15
|
+
include Vagrant::Util
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@logger = Log4r::Logger.new("vagrant::driver::virtualbox_base")
|
19
|
+
|
20
|
+
# This flag is used to keep track of interrupted state (SIGINT)
|
21
|
+
@interrupted = false
|
22
|
+
|
23
|
+
# Set the path to VBoxManage
|
24
|
+
@vboxmanage_path = "VBoxManage"
|
25
|
+
|
26
|
+
if Util::Platform.windows?
|
27
|
+
@logger.debug("Windows. Trying VBOX_INSTALL_PATH for VBoxManage")
|
28
|
+
|
29
|
+
# On Windows, we use the VBOX_INSTALL_PATH environmental
|
30
|
+
# variable to find VBoxManage.
|
31
|
+
if ENV.has_key?("VBOX_INSTALL_PATH")
|
32
|
+
# The path usually ends with a \ but we make sure here
|
33
|
+
path = ENV["VBOX_INSTALL_PATH"]
|
34
|
+
path += "\\" if !path.end_with?("\\")
|
35
|
+
@vboxmanage_path = "#{path}VBoxManage.exe"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
@logger.info("VBoxManage path: #{@vboxmanage_path}")
|
40
|
+
end
|
41
|
+
|
42
|
+
# Clears the forwarded ports that have been set on the virtual machine.
|
43
|
+
def clear_forwarded_ports
|
44
|
+
end
|
45
|
+
|
46
|
+
# Clears the shared folders that have been set on the virtual machine.
|
47
|
+
def clear_shared_folders
|
48
|
+
end
|
49
|
+
|
50
|
+
# Creates a DHCP server for a host only network.
|
51
|
+
#
|
52
|
+
# @param [String] network Name of the host-only network.
|
53
|
+
# @param [Hash] options Options for the DHCP server.
|
54
|
+
def create_dhcp_server(network, options)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Creates a host only network with the given options.
|
58
|
+
#
|
59
|
+
# @param [Hash] options Options to create the host only network.
|
60
|
+
# @return [Hash] The details of the host only network, including
|
61
|
+
# keys `:name`, `:ip`, and `:netmask`
|
62
|
+
def create_host_only_network(options)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Deletes the virtual machine references by this driver.
|
66
|
+
def delete
|
67
|
+
end
|
68
|
+
|
69
|
+
# Deletes any host only networks that aren't being used for anything.
|
70
|
+
def delete_unused_host_only_networks
|
71
|
+
end
|
72
|
+
|
73
|
+
# Discards any saved state associated with this VM.
|
74
|
+
def discard_saved_state
|
75
|
+
end
|
76
|
+
|
77
|
+
# Enables network adapters on the VM.
|
78
|
+
#
|
79
|
+
# The format of each adapter specification should be like so:
|
80
|
+
#
|
81
|
+
# {
|
82
|
+
# :type => :hostonly,
|
83
|
+
# :hostonly => "vboxnet0",
|
84
|
+
# :mac_address => "tubes"
|
85
|
+
# }
|
86
|
+
#
|
87
|
+
# This must support setting up both host only and bridged networks.
|
88
|
+
#
|
89
|
+
# @param [Array<Hash>] adapters Array of adapters to enable.
|
90
|
+
def enable_adapters(adapters)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Execute a raw command straight through to VBoxManage.
|
94
|
+
#
|
95
|
+
# @param [Array] command Command to execute.
|
96
|
+
def execute_command(command)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Exports the virtual machine to the given path.
|
100
|
+
#
|
101
|
+
# @param [String] path Path to the OVF file.
|
102
|
+
# @yield [progress] Yields the block with the progress of the export.
|
103
|
+
def export(path)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Forwards a set of ports for a VM.
|
107
|
+
#
|
108
|
+
# This will not affect any previously set forwarded ports,
|
109
|
+
# so be sure to delete those if you need to.
|
110
|
+
#
|
111
|
+
# The format of each port hash should be the following:
|
112
|
+
#
|
113
|
+
# {
|
114
|
+
# :name => "foo",
|
115
|
+
# :hostport => 8500,
|
116
|
+
# :guestport => 80,
|
117
|
+
# :adapter => 1,
|
118
|
+
# :protocol => "tcp"
|
119
|
+
# }
|
120
|
+
#
|
121
|
+
# Note that "adapter" and "protocol" are optional and will default
|
122
|
+
# to 1 and "tcp" respectively.
|
123
|
+
#
|
124
|
+
# @param [Array<Hash>] ports An array of ports to set. See documentation
|
125
|
+
# for more information on the format.
|
126
|
+
def forward_ports(ports)
|
127
|
+
end
|
128
|
+
|
129
|
+
# Halts the virtual machine (pulls the plug).
|
130
|
+
def halt
|
131
|
+
end
|
132
|
+
|
133
|
+
# Imports the VM from an OVF file.
|
134
|
+
#
|
135
|
+
# @param [String] ovf Path to the OVF file.
|
136
|
+
# @param [String] name Name of the VM.
|
137
|
+
# @return [String] UUID of the imported VM.
|
138
|
+
def import(ovf, name)
|
139
|
+
end
|
140
|
+
|
141
|
+
# Returns a list of forwarded ports for a VM.
|
142
|
+
#
|
143
|
+
# @param [String] uuid UUID of the VM to read from, or `nil` if this
|
144
|
+
# VM.
|
145
|
+
# @param [Boolean] active_only If true, only VMs that are running will
|
146
|
+
# be checked.
|
147
|
+
# @return [Array<Array>]
|
148
|
+
def read_forwarded_ports(uuid=nil, active_only=false)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Returns a list of bridged interfaces.
|
152
|
+
#
|
153
|
+
# @return [Hash]
|
154
|
+
def read_bridged_interfaces
|
155
|
+
end
|
156
|
+
|
157
|
+
# Returns the guest additions version that is installed on this VM.
|
158
|
+
#
|
159
|
+
# @return [String]
|
160
|
+
def read_guest_additions_version
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns a list of available host only interfaces.
|
164
|
+
#
|
165
|
+
# @return [Hash]
|
166
|
+
def read_host_only_interfaces
|
167
|
+
end
|
168
|
+
|
169
|
+
# Returns the MAC address of the first network interface.
|
170
|
+
#
|
171
|
+
# @return [String]
|
172
|
+
def read_mac_address
|
173
|
+
end
|
174
|
+
|
175
|
+
# Returns the folder where VirtualBox places it's VMs.
|
176
|
+
#
|
177
|
+
# @return [String]
|
178
|
+
def read_machine_folder
|
179
|
+
end
|
180
|
+
|
181
|
+
# Returns a list of network interfaces of the VM.
|
182
|
+
#
|
183
|
+
# @return [Hash]
|
184
|
+
def read_network_interfaces
|
185
|
+
end
|
186
|
+
|
187
|
+
# Returns the current state of this VM.
|
188
|
+
#
|
189
|
+
# @return [Symbol]
|
190
|
+
def read_state
|
191
|
+
end
|
192
|
+
|
193
|
+
# Returns a list of all forwarded ports in use by active
|
194
|
+
# virtual machines.
|
195
|
+
#
|
196
|
+
# @return [Array]
|
197
|
+
def read_used_ports
|
198
|
+
end
|
199
|
+
|
200
|
+
# Returns a list of all UUIDs of virtual machines currently
|
201
|
+
# known by VirtualBox.
|
202
|
+
#
|
203
|
+
# @return [Array<String>]
|
204
|
+
def read_vms
|
205
|
+
end
|
206
|
+
|
207
|
+
# Sets the MAC address of the first network adapter.
|
208
|
+
#
|
209
|
+
# @param [String] mac MAC address without any spaces/hyphens.
|
210
|
+
def set_mac_address(mac)
|
211
|
+
end
|
212
|
+
|
213
|
+
# Share a set of folders on this VM.
|
214
|
+
#
|
215
|
+
# @param [Array<Hash>] folders
|
216
|
+
def share_folders(folders)
|
217
|
+
end
|
218
|
+
|
219
|
+
# Reads the SSH port of this VM.
|
220
|
+
#
|
221
|
+
# @param [Integer] expected Expected guest port of SSH.
|
222
|
+
def ssh_port(expected)
|
223
|
+
end
|
224
|
+
|
225
|
+
# Starts the virtual machine.
|
226
|
+
#
|
227
|
+
# @param [String] mode Mode to boot the VM. Either "headless"
|
228
|
+
# or "gui"
|
229
|
+
def start(mode)
|
230
|
+
end
|
231
|
+
|
232
|
+
# Suspend the virtual machine.
|
233
|
+
def suspend
|
234
|
+
end
|
235
|
+
|
236
|
+
# Verifies that an image can be imported properly.
|
237
|
+
#
|
238
|
+
# @param [String] path Path to an OVF file.
|
239
|
+
# @return [Boolean]
|
240
|
+
def verify_image(path)
|
241
|
+
end
|
242
|
+
|
243
|
+
# Checks if a VM with the given UUID exists.
|
244
|
+
#
|
245
|
+
# @return [Boolean]
|
246
|
+
def vm_exists?(uuid)
|
247
|
+
end
|
248
|
+
|
249
|
+
protected
|
250
|
+
|
251
|
+
# Execute the given subcommand for VBoxManage and return the output.
|
252
|
+
def execute(*command, &block)
|
253
|
+
# Execute the command
|
254
|
+
r = raw(*command, &block)
|
255
|
+
|
256
|
+
# If the command was a failure, then raise an exception that is
|
257
|
+
# nicely handled by Vagrant.
|
258
|
+
if r.exit_code != 0
|
259
|
+
if @interrupted
|
260
|
+
@logger.info("Exit code != 0, but interrupted. Ignoring.")
|
261
|
+
else
|
262
|
+
raise Errors::VBoxManageError, :command => command.inspect
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
# Return the output, making sure to replace any Windows-style
|
267
|
+
# newlines with Unix-style.
|
268
|
+
r.stdout.gsub("\r\n", "\n")
|
269
|
+
end
|
270
|
+
|
271
|
+
# Executes a command and returns the raw result object.
|
272
|
+
def raw(*command, &block)
|
273
|
+
int_callback = lambda do
|
274
|
+
@interrupted = true
|
275
|
+
@logger.info("Interrupted.")
|
276
|
+
end
|
277
|
+
|
278
|
+
Util::Busy.busy(int_callback) do
|
279
|
+
Subprocess.execute(@vboxmanage_path, *command, &block)
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|