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
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module Command
|
5
|
+
class BoxRemove < Base
|
6
|
+
def execute
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: vagrant box remove <name>"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Parse the options
|
14
|
+
argv = parse_options(opts)
|
15
|
+
return if !argv
|
16
|
+
|
17
|
+
b = @env.boxes.find(argv[0])
|
18
|
+
raise Errors::BoxNotFound, :name => argv[0] if !b
|
19
|
+
b.destroy
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module Command
|
5
|
+
class BoxRepackage < Base
|
6
|
+
def execute
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: vagrant box repackage <name>"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Parse the options
|
14
|
+
argv = parse_options(opts)
|
15
|
+
return if !argv
|
16
|
+
|
17
|
+
b = @env.boxes.find(argv[0])
|
18
|
+
raise Errors::BoxNotFound, :name => argv[0] if !b
|
19
|
+
b.repackage
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,14 +1,25 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
1
3
|
module Vagrant
|
2
4
|
module Command
|
3
|
-
class
|
4
|
-
register "destroy", "Destroy the environment, deleting the created virtual machines"
|
5
|
-
|
5
|
+
class Destroy < Base
|
6
6
|
def execute
|
7
|
-
|
7
|
+
opts = OptionParser.new do |opts|
|
8
|
+
opts.banner = "Usage: vagrant destroy [vm-name]"
|
9
|
+
end
|
10
|
+
|
11
|
+
# Parse the options
|
12
|
+
argv = parse_options(opts)
|
13
|
+
return if !argv
|
14
|
+
|
15
|
+
@logger.debug("'Destroy' each target VM...")
|
16
|
+
with_target_vms(argv[0]) do |vm|
|
8
17
|
if vm.created?
|
18
|
+
@logger.info("Destroying: #{vm.name}")
|
9
19
|
vm.destroy
|
10
20
|
else
|
11
|
-
|
21
|
+
@logger.info("Not destroying #{vm.name}, since it isn't created.")
|
22
|
+
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
|
12
23
|
end
|
13
24
|
end
|
14
25
|
end
|
data/lib/vagrant/command/halt.rb
CHANGED
@@ -1,15 +1,33 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
1
3
|
module Vagrant
|
2
4
|
module Command
|
3
|
-
class
|
4
|
-
class_option :force, :type => :boolean, :default => false, :aliases => "-f"
|
5
|
-
register "halt", "Halt the running VMs in the environment"
|
6
|
-
|
5
|
+
class Halt < Base
|
7
6
|
def execute
|
8
|
-
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: vagrant halt [vm-name] [--force] [-h]"
|
11
|
+
|
12
|
+
opts.separator ""
|
13
|
+
|
14
|
+
opts.on("-f", "--force", "Force shut down (equivalent of pulling power)") do |f|
|
15
|
+
options[:force] = f
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Parse the options
|
20
|
+
argv = parse_options(opts)
|
21
|
+
return if !argv
|
22
|
+
|
23
|
+
@logger.debug("Halt command: #{argv.inspect} #{options.inspect}")
|
24
|
+
with_target_vms(argv[0]) do |vm|
|
9
25
|
if vm.created?
|
10
|
-
vm.
|
26
|
+
@logger.info("Halting #{vm.name}")
|
27
|
+
vm.halt(:force => options[:force])
|
11
28
|
else
|
12
|
-
|
29
|
+
@logger.info("Not halting #{vm.name}, since not created.")
|
30
|
+
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
|
13
31
|
end
|
14
32
|
end
|
15
33
|
end
|
data/lib/vagrant/command/init.rb
CHANGED
@@ -1,13 +1,36 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
require 'vagrant/util/template_renderer'
|
4
|
+
|
1
5
|
module Vagrant
|
2
6
|
module Command
|
3
|
-
class
|
4
|
-
argument :box_name, :type => :string, :optional => true, :default => "base"
|
5
|
-
argument :box_url, :type => :string, :optional => true
|
6
|
-
source_root File.expand_path("templates/commands/init", Vagrant.source_root)
|
7
|
-
register "init [box_name] [box_url]", "Initializes the current folder for Vagrant usage"
|
8
|
-
|
7
|
+
class Init < Base
|
9
8
|
def execute
|
10
|
-
|
9
|
+
options = {}
|
10
|
+
|
11
|
+
opts = OptionParser.new do |opts|
|
12
|
+
opts.banner = "Usage: vagrant init [box-name] [box-url]"
|
13
|
+
end
|
14
|
+
|
15
|
+
# Parse the options
|
16
|
+
argv = parse_options(opts)
|
17
|
+
return if !argv
|
18
|
+
|
19
|
+
save_path = @env.cwd.join("Vagrantfile")
|
20
|
+
raise Errors::VagrantfileExistsError if save_path.exist?
|
21
|
+
|
22
|
+
template_path = ::Vagrant.source_root.join("templates/commands/init/Vagrantfile")
|
23
|
+
contents = Vagrant::Util::TemplateRenderer.render(template_path,
|
24
|
+
:box_name => argv[0] || "base",
|
25
|
+
:box_url => argv[1])
|
26
|
+
|
27
|
+
# Write out the contents
|
28
|
+
save_path.open("w+") do |f|
|
29
|
+
f.write(contents)
|
30
|
+
end
|
31
|
+
|
32
|
+
@env.ui.info(I18n.t("vagrant.commands.init.success"),
|
33
|
+
:prefix => false)
|
11
34
|
end
|
12
35
|
end
|
13
36
|
end
|
@@ -1,33 +1,64 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
1
3
|
module Vagrant
|
2
4
|
module Command
|
3
|
-
class
|
4
|
-
class_option :base, :type => :string, :default => nil
|
5
|
-
class_option :output, :type => :string, :default => nil
|
6
|
-
class_option :include, :type => :array, :default => nil
|
7
|
-
class_option :vagrantfile, :type => :string, :default => nil
|
8
|
-
register "package", "Package a Vagrant environment for distribution"
|
9
|
-
|
5
|
+
class Package < Base
|
10
6
|
def execute
|
11
|
-
|
12
|
-
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: vagrant package [vm-name] [--base name] [--output name.box]"
|
11
|
+
opts.separator " [--include one,two,three] [--vagrantfile file]"
|
12
|
+
|
13
|
+
opts.separator ""
|
14
|
+
|
15
|
+
opts.on("--base NAME", "Name of a VM in virtualbox to package as a base box") do |b|
|
16
|
+
options[:base] = b
|
17
|
+
end
|
18
|
+
|
19
|
+
opts.on("--output NAME", "Name of the file to output") do |o|
|
20
|
+
options[:output] = o
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on("--include x,y,z", Array, "Additional files to package with the box.") do |i|
|
24
|
+
options[:include] = i
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on("--vagrantfile file", "Vagrantfile to package with the box.") do |v|
|
28
|
+
options[:vagrantfile] = v
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Parse the options
|
33
|
+
argv = parse_options(opts)
|
34
|
+
return if !argv
|
35
|
+
|
36
|
+
@logger.debug("package options: #{options.inspect}")
|
37
|
+
if options[:base]
|
38
|
+
package_base(options)
|
39
|
+
else
|
40
|
+
package_target(argv[0], options)
|
41
|
+
end
|
13
42
|
end
|
14
43
|
|
15
44
|
protected
|
16
45
|
|
17
|
-
def package_base
|
18
|
-
vm = VM.
|
46
|
+
def package_base(options)
|
47
|
+
vm = VM.new(options[:base], @env, @env.config.global, :base => true)
|
19
48
|
raise Errors::BaseVMNotFound, :name => options[:base] if !vm.created?
|
20
|
-
|
49
|
+
@logger.debug("Packaging base VM: #{vm.name}")
|
50
|
+
package_vm(vm, options)
|
21
51
|
end
|
22
52
|
|
23
|
-
def package_target
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
53
|
+
def package_target(name, options)
|
54
|
+
with_target_vms(name, true) do |vm|
|
55
|
+
raise Errors::VMNotCreatedError if !vm.created?
|
56
|
+
@logger.debug("Packaging VM: #{vm.name}")
|
57
|
+
package_vm(vm, options)
|
58
|
+
end
|
28
59
|
end
|
29
60
|
|
30
|
-
def package_vm(vm)
|
61
|
+
def package_vm(vm, options)
|
31
62
|
opts = options.inject({}) do |acc, data|
|
32
63
|
k,v = data
|
33
64
|
acc["package.#{k}"] = v
|
@@ -1,20 +1,33 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
1
3
|
module Vagrant
|
2
4
|
module Command
|
3
|
-
class
|
4
|
-
register "provision", "Rerun the provisioning scripts on a running VM"
|
5
|
-
|
5
|
+
class Provision < Base
|
6
6
|
def execute
|
7
|
-
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: vagrant provision [vm-name]"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Parse the options
|
14
|
+
argv = parse_options(opts)
|
15
|
+
return if !argv
|
16
|
+
|
17
|
+
# Go over each VM and provision!
|
18
|
+
@logger.debug("'provision' each target VM...")
|
19
|
+
with_target_vms(argv[0]) do |vm|
|
8
20
|
if vm.created?
|
9
|
-
if
|
10
|
-
|
11
|
-
elsif vm.vm.running?
|
21
|
+
if vm.state == :running
|
22
|
+
@logger.info("Provisioning: #{vm.name}")
|
12
23
|
vm.provision
|
13
24
|
else
|
14
|
-
|
25
|
+
@logger.info("#{vm.name} not running. Not provisioning.")
|
26
|
+
vm.ui.info I18n.t("vagrant.commands.common.vm_not_running")
|
15
27
|
end
|
16
28
|
else
|
17
|
-
|
29
|
+
@logger.info("#{vm.name} not created. Not provisioning.")
|
30
|
+
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
|
18
31
|
end
|
19
32
|
end
|
20
33
|
end
|
@@ -1,14 +1,27 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
1
3
|
module Vagrant
|
2
4
|
module Command
|
3
|
-
class
|
4
|
-
register "reload", "Reload the environment, halting it then restarting it."
|
5
|
-
|
5
|
+
class Reload < Base
|
6
6
|
def execute
|
7
|
-
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: vagrant reload [vm-name]"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Parse the options
|
14
|
+
argv = parse_options(opts)
|
15
|
+
return if !argv
|
16
|
+
|
17
|
+
@logger.debug("'reload' each target VM...")
|
18
|
+
with_target_vms(argv[0]) do |vm|
|
8
19
|
if vm.created?
|
20
|
+
@logger.info("Reloading: #{vm.name}")
|
9
21
|
vm.reload
|
10
22
|
else
|
11
|
-
|
23
|
+
@logger.info("Not created: #{vm.name}. Not reloading.")
|
24
|
+
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
|
12
25
|
end
|
13
26
|
end
|
14
27
|
end
|
@@ -1,14 +1,27 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
1
3
|
module Vagrant
|
2
4
|
module Command
|
3
|
-
class
|
4
|
-
register "resume", "Resume a suspended Vagrant environment."
|
5
|
-
|
5
|
+
class Resume < Base
|
6
6
|
def execute
|
7
|
-
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: vagrant resume [vm-name]"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Parse the options
|
14
|
+
argv = parse_options(opts)
|
15
|
+
return if !argv
|
16
|
+
|
17
|
+
@logger.debug("'resume' each target VM...")
|
18
|
+
with_target_vms(argv[0]) do |vm|
|
8
19
|
if vm.created?
|
20
|
+
@logger.info("Resume: #{vm.name}")
|
9
21
|
vm.resume
|
10
22
|
else
|
11
|
-
|
23
|
+
@logger.info("Not created: #{vm.name}. Not resuming.")
|
24
|
+
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
|
12
25
|
end
|
13
26
|
end
|
14
27
|
end
|
data/lib/vagrant/command/ssh.rb
CHANGED
@@ -1,49 +1,87 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
1
3
|
module Vagrant
|
2
4
|
module Command
|
3
|
-
class
|
4
|
-
class_option :command, :type => :string, :default => false, :aliases => "-c"
|
5
|
-
register "ssh", "SSH into the currently running Vagrant environment."
|
6
|
-
|
5
|
+
class SSH < Base
|
7
6
|
def execute
|
8
|
-
|
9
|
-
ssh_execute
|
10
|
-
else
|
11
|
-
ssh_connect
|
12
|
-
end
|
13
|
-
end
|
7
|
+
options = {}
|
14
8
|
|
15
|
-
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: vagrant ssh [vm-name] [-c command] [-- extra ssh args]"
|
11
|
+
|
12
|
+
opts.separator ""
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
# force a new line so that the output is properly preserved
|
23
|
-
ssh_vm.env.ui.info(data.to_s, :prefix => false, :new_line => false)
|
24
|
-
end
|
14
|
+
opts.on("-c", "--command COMMAND", "Execute an SSH command directly.") do |c|
|
15
|
+
options[:command] = c
|
16
|
+
end
|
17
|
+
opts.on("-p", "--plain", "Plain mode, leaves authentication up to user.") do |p|
|
18
|
+
options[:plain_mode] = p
|
25
19
|
end
|
26
20
|
end
|
27
|
-
end
|
28
21
|
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
# Parse the options and return if we don't have any target.
|
23
|
+
argv = parse_options(opts)
|
24
|
+
return if !argv
|
32
25
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
26
|
+
# Parse out the extra args to send to SSH, which is everything
|
27
|
+
# after the "--"
|
28
|
+
ssh_args = ARGV.drop_while { |i| i != "--" }
|
29
|
+
ssh_args = ssh_args[1..-1]
|
30
|
+
options[:ssh_args] = ssh_args
|
38
31
|
|
32
|
+
# If the remaining arguments ARE the SSH arguments, then just
|
33
|
+
# clear it out. This happens because optparse returns what is
|
34
|
+
# after the "--" as remaining ARGV, and Vagrant can think it is
|
35
|
+
# a multi-vm name (wrong!)
|
36
|
+
argv = [] if argv == ssh_args
|
37
|
+
|
38
|
+
# Execute the actual SSH
|
39
|
+
with_target_vms(argv[0], true) do |vm|
|
39
40
|
# Basic checks that are required for proper SSH
|
40
41
|
raise Errors::VMNotCreatedError if !vm.created?
|
41
|
-
raise Errors::VMInaccessible if !vm.
|
42
|
-
raise Errors::VMNotRunningError if
|
42
|
+
raise Errors::VMInaccessible if !vm.state == :inaccessible
|
43
|
+
raise Errors::VMNotRunningError if vm.state != :running
|
44
|
+
|
45
|
+
if options[:command]
|
46
|
+
ssh_execute(vm, options[:command])
|
47
|
+
else
|
48
|
+
opts = {
|
49
|
+
:plain_mode => options[:plain_mode],
|
50
|
+
:extra_args => options[:ssh_args]
|
51
|
+
}
|
43
52
|
|
44
|
-
|
53
|
+
ssh_connect(vm, opts)
|
54
|
+
end
|
45
55
|
end
|
46
56
|
end
|
57
|
+
|
58
|
+
protected
|
59
|
+
|
60
|
+
def ssh_execute(vm, command=nil)
|
61
|
+
exit_status = 0
|
62
|
+
|
63
|
+
@logger.debug("Executing command: #{command}")
|
64
|
+
exit_status = vm.channel.execute(command, :error_check => false) do |type, data|
|
65
|
+
# Determine the proper channel to send the output onto depending
|
66
|
+
# on the type of data we are receiving.
|
67
|
+
channel = type == :stdout ? :out : :error
|
68
|
+
|
69
|
+
# Print the SSH output as it comes in, but don't prefix it and don't
|
70
|
+
# force a new line so that the output is properly preserved
|
71
|
+
vm.ui.info(data.to_s,
|
72
|
+
:prefix => false,
|
73
|
+
:new_line => false,
|
74
|
+
:channel => channel)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Exit with the exit status we got from executing the command
|
78
|
+
exit exit_status
|
79
|
+
end
|
80
|
+
|
81
|
+
def ssh_connect(vm, opts)
|
82
|
+
@logger.debug("`exec` into ssh prompt")
|
83
|
+
vm.ssh.exec(opts)
|
84
|
+
end
|
47
85
|
end
|
48
86
|
end
|
49
87
|
end
|
@@ -1,28 +1,43 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
1
3
|
module Vagrant
|
2
4
|
module Command
|
3
|
-
class
|
4
|
-
class_option :host, :type => :string, :default => nil, :aliases => "-h"
|
5
|
-
register "ssh_config", "outputs .ssh/config valid syntax for connecting to this environment via ssh"
|
6
|
-
|
5
|
+
class SSHConfig < Base
|
7
6
|
def execute
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: vagrant ssh-config [vm-name] [-h name]"
|
11
|
+
|
12
|
+
opts.separator ""
|
13
|
+
|
14
|
+
opts.on("-h", "--host COMMAND", "Name the host for the config..") do |h|
|
15
|
+
options[:host] = h
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
argv = parse_options(opts)
|
20
|
+
return if !argv
|
21
|
+
|
22
|
+
with_target_vms(argv[0], true) do |vm|
|
23
|
+
raise Errors::VMNotCreatedError if !vm.created?
|
24
|
+
raise Errors::VMInaccessible if !vm.state == :inaccessible
|
25
|
+
|
26
|
+
ssh_info = vm.ssh.info
|
27
|
+
variables = {
|
28
|
+
:host_key => options[:host] || vm.name || "vagrant",
|
29
|
+
:ssh_host => ssh_info[:host],
|
30
|
+
:ssh_port => ssh_info[:port],
|
31
|
+
:ssh_user => ssh_info[:username],
|
32
|
+
:private_key_path => ssh_info[:private_key_path],
|
33
|
+
:forward_agent => ssh_info[:forward_agent],
|
34
|
+
:forward_x11 => ssh_info[:forward_x11]
|
35
|
+
}
|
36
|
+
|
37
|
+
# Render the template and output directly to STDOUT
|
38
|
+
template = "commands/ssh_config/config"
|
39
|
+
$stdout.puts(Util::TemplateRenderer.render(template, variables))
|
40
|
+
end
|
26
41
|
end
|
27
42
|
end
|
28
43
|
end
|
@@ -1,30 +1,32 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
1
3
|
module Vagrant
|
2
4
|
module Command
|
3
|
-
class
|
4
|
-
register "status", "Shows the status of the current Vagrant environment."
|
5
|
-
|
5
|
+
class Status < Base
|
6
6
|
def execute
|
7
|
-
|
8
|
-
results = target_vms.collect do |vm|
|
9
|
-
if vm.created?
|
10
|
-
if vm.vm.accessible?
|
11
|
-
state = vm.vm.state.to_s
|
12
|
-
else
|
13
|
-
state = "inaccessible"
|
14
|
-
end
|
15
|
-
else
|
16
|
-
state = "not_created"
|
17
|
-
end
|
7
|
+
options = {}
|
18
8
|
|
19
|
-
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: vagrant status [vm-name]"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Parse the options
|
14
|
+
argv = parse_options(opts)
|
15
|
+
return if !argv
|
16
|
+
|
17
|
+
state = nil
|
18
|
+
results = []
|
19
|
+
with_target_vms(argv[0]) do |vm|
|
20
|
+
state = vm.state.to_s if !state
|
21
|
+
results << "#{vm.name.to_s.ljust(25)}#{vm.state.to_s.gsub("_", " ")}"
|
20
22
|
end
|
21
23
|
|
22
|
-
state =
|
24
|
+
state = results.length == 1 ? state : "listing"
|
23
25
|
|
24
|
-
env.ui.info(I18n.t("vagrant.commands.status.output",
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
@env.ui.info(I18n.t("vagrant.commands.status.output",
|
27
|
+
:states => results.join("\n"),
|
28
|
+
:message => I18n.t("vagrant.commands.status.#{state}")),
|
29
|
+
:prefix => false)
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
@@ -1,14 +1,27 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
1
3
|
module Vagrant
|
2
4
|
module Command
|
3
|
-
class
|
4
|
-
register "suspend", "Suspend a running Vagrant environment."
|
5
|
-
|
5
|
+
class Suspend < Base
|
6
6
|
def execute
|
7
|
-
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: vagrant suspend [vm-name]"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Parse the options
|
14
|
+
argv = parse_options(opts)
|
15
|
+
return if !argv
|
16
|
+
|
17
|
+
@logger.debug("'suspend' each target VM...")
|
18
|
+
with_target_vms(argv[0]) do |vm|
|
8
19
|
if vm.created?
|
20
|
+
@logger.info("Suspending: #{vm.name}")
|
9
21
|
vm.suspend
|
10
22
|
else
|
11
|
-
|
23
|
+
@logger.info("Not created: #{vm.name}. Not suspending.")
|
24
|
+
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
|
12
25
|
end
|
13
26
|
end
|
14
27
|
end
|