fixed-vagrant 0.7.4.dev
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +15 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +272 -0
- data/Gemfile +21 -0
- data/LICENSE +21 -0
- data/README.md +75 -0
- data/Rakefile +22 -0
- data/bin/vagrant +22 -0
- data/config/default.rb +39 -0
- data/contrib/README.md +12 -0
- data/contrib/emacs/vagrant.el +8 -0
- data/contrib/vim/vagrantfile.vim +9 -0
- data/keys/README.md +17 -0
- data/keys/vagrant +27 -0
- data/keys/vagrant.ppk +26 -0
- data/keys/vagrant.pub +1 -0
- data/lib/vagrant.rb +42 -0
- data/lib/vagrant/action.rb +134 -0
- data/lib/vagrant/action/box.rb +11 -0
- data/lib/vagrant/action/box/destroy.rb +21 -0
- data/lib/vagrant/action/box/download.rb +72 -0
- data/lib/vagrant/action/box/package.rb +19 -0
- data/lib/vagrant/action/box/unpackage.rb +55 -0
- data/lib/vagrant/action/box/verify.rb +23 -0
- data/lib/vagrant/action/builder.rb +124 -0
- data/lib/vagrant/action/builtin.rb +104 -0
- data/lib/vagrant/action/env.rb +7 -0
- data/lib/vagrant/action/env/set.rb +18 -0
- data/lib/vagrant/action/environment.rb +50 -0
- data/lib/vagrant/action/general.rb +8 -0
- data/lib/vagrant/action/general/package.rb +109 -0
- data/lib/vagrant/action/general/validate.rb +19 -0
- data/lib/vagrant/action/vm.rb +31 -0
- data/lib/vagrant/action/vm/boot.rb +48 -0
- data/lib/vagrant/action/vm/check_box.rb +28 -0
- data/lib/vagrant/action/vm/check_guest_additions.rb +30 -0
- data/lib/vagrant/action/vm/clean_machine_folder.rb +43 -0
- data/lib/vagrant/action/vm/clear_forwarded_ports.rb +39 -0
- data/lib/vagrant/action/vm/clear_nfs_exports.rb +20 -0
- data/lib/vagrant/action/vm/clear_shared_folders.rb +32 -0
- data/lib/vagrant/action/vm/customize.rb +21 -0
- data/lib/vagrant/action/vm/destroy.rb +19 -0
- data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +30 -0
- data/lib/vagrant/action/vm/discard_state.rb +22 -0
- data/lib/vagrant/action/vm/export.rb +52 -0
- data/lib/vagrant/action/vm/forward_ports.rb +134 -0
- data/lib/vagrant/action/vm/forward_ports_helpers.rb +28 -0
- data/lib/vagrant/action/vm/halt.rb +29 -0
- data/lib/vagrant/action/vm/host_name.rb +21 -0
- data/lib/vagrant/action/vm/import.rb +35 -0
- data/lib/vagrant/action/vm/match_mac_address.rb +21 -0
- data/lib/vagrant/action/vm/network.rb +139 -0
- data/lib/vagrant/action/vm/nfs.rb +159 -0
- data/lib/vagrant/action/vm/nfs_helpers.rb +11 -0
- data/lib/vagrant/action/vm/package.rb +23 -0
- data/lib/vagrant/action/vm/package_vagrantfile.rb +33 -0
- data/lib/vagrant/action/vm/provision.rb +41 -0
- data/lib/vagrant/action/vm/resume.rb +20 -0
- data/lib/vagrant/action/vm/share_folders.rb +70 -0
- data/lib/vagrant/action/vm/suspend.rb +20 -0
- data/lib/vagrant/action/warden.rb +79 -0
- data/lib/vagrant/box.rb +90 -0
- data/lib/vagrant/box_collection.rb +53 -0
- data/lib/vagrant/cli.rb +55 -0
- data/lib/vagrant/command.rb +25 -0
- data/lib/vagrant/command/base.rb +106 -0
- data/lib/vagrant/command/box.rb +33 -0
- data/lib/vagrant/command/destroy.rb +17 -0
- data/lib/vagrant/command/group_base.rb +107 -0
- data/lib/vagrant/command/halt.rb +18 -0
- data/lib/vagrant/command/helpers.rb +33 -0
- data/lib/vagrant/command/init.rb +14 -0
- data/lib/vagrant/command/named_base.rb +14 -0
- data/lib/vagrant/command/package.rb +41 -0
- data/lib/vagrant/command/provision.rb +17 -0
- data/lib/vagrant/command/reload.rb +17 -0
- data/lib/vagrant/command/resume.rb +17 -0
- data/lib/vagrant/command/ssh.rb +42 -0
- data/lib/vagrant/command/ssh_config.rb +26 -0
- data/lib/vagrant/command/status.rb +22 -0
- data/lib/vagrant/command/suspend.rb +17 -0
- data/lib/vagrant/command/up.rb +19 -0
- data/lib/vagrant/command/upgrade_to_060.rb +45 -0
- data/lib/vagrant/command/version.rb +13 -0
- data/lib/vagrant/config.rb +123 -0
- data/lib/vagrant/config/base.rb +85 -0
- data/lib/vagrant/config/error_recorder.rb +19 -0
- data/lib/vagrant/config/nfs.rb +10 -0
- data/lib/vagrant/config/package.rb +9 -0
- data/lib/vagrant/config/ssh.rb +33 -0
- data/lib/vagrant/config/top.rb +61 -0
- data/lib/vagrant/config/vagrant.rb +16 -0
- data/lib/vagrant/config/vm.rb +137 -0
- data/lib/vagrant/config/vm/provisioner.rb +56 -0
- data/lib/vagrant/config/vm/sub_vm.rb +17 -0
- data/lib/vagrant/data_store.rb +70 -0
- data/lib/vagrant/downloaders.rb +7 -0
- data/lib/vagrant/downloaders/base.rb +23 -0
- data/lib/vagrant/downloaders/file.rb +22 -0
- data/lib/vagrant/downloaders/http.rb +64 -0
- data/lib/vagrant/environment.rb +392 -0
- data/lib/vagrant/errors.rb +332 -0
- data/lib/vagrant/hosts.rb +8 -0
- data/lib/vagrant/hosts/arch.rb +27 -0
- data/lib/vagrant/hosts/base.rb +78 -0
- data/lib/vagrant/hosts/bsd.rb +52 -0
- data/lib/vagrant/hosts/linux.rb +47 -0
- data/lib/vagrant/plugin.rb +57 -0
- data/lib/vagrant/provisioners.rb +9 -0
- data/lib/vagrant/provisioners/base.rb +63 -0
- data/lib/vagrant/provisioners/chef.rb +130 -0
- data/lib/vagrant/provisioners/chef_server.rb +103 -0
- data/lib/vagrant/provisioners/chef_solo.rb +142 -0
- data/lib/vagrant/provisioners/puppet.rb +137 -0
- data/lib/vagrant/provisioners/puppet_server.rb +55 -0
- data/lib/vagrant/provisioners/shell.rb +52 -0
- data/lib/vagrant/ssh.rb +173 -0
- data/lib/vagrant/ssh/session.rb +125 -0
- data/lib/vagrant/systems.rb +11 -0
- data/lib/vagrant/systems/base.rb +87 -0
- data/lib/vagrant/systems/debian.rb +36 -0
- data/lib/vagrant/systems/freebsd.rb +84 -0
- data/lib/vagrant/systems/gentoo.rb +27 -0
- data/lib/vagrant/systems/linux.rb +83 -0
- data/lib/vagrant/systems/linux/config.rb +21 -0
- data/lib/vagrant/systems/linux/error.rb +9 -0
- data/lib/vagrant/systems/redhat.rb +39 -0
- data/lib/vagrant/systems/solaris.rb +62 -0
- data/lib/vagrant/systems/ubuntu.rb +17 -0
- data/lib/vagrant/test_helpers.rb +128 -0
- data/lib/vagrant/ui.rb +69 -0
- data/lib/vagrant/util.rb +13 -0
- data/lib/vagrant/util/busy.rb +59 -0
- data/lib/vagrant/util/hash_with_indifferent_access.rb +63 -0
- data/lib/vagrant/util/plain_logger.rb +25 -0
- data/lib/vagrant/util/platform.rb +65 -0
- data/lib/vagrant/util/resource_logger.rb +63 -0
- data/lib/vagrant/util/retryable.rb +25 -0
- data/lib/vagrant/util/stacked_proc_runner.rb +35 -0
- data/lib/vagrant/util/template_renderer.rb +83 -0
- data/lib/vagrant/version.rb +6 -0
- data/lib/vagrant/vm.rb +177 -0
- data/templates/chef_server_client.erb +18 -0
- data/templates/chef_solo_solo.erb +19 -0
- data/templates/commands/init/Vagrantfile.erb +82 -0
- data/templates/config/validation_failed.erb +7 -0
- data/templates/locales/en.yml +535 -0
- data/templates/network_entry_debian.erb +8 -0
- data/templates/network_entry_gentoo.erb +5 -0
- data/templates/network_entry_redhat.erb +8 -0
- data/templates/nfs/exports.erb +5 -0
- data/templates/nfs/exports_linux.erb +5 -0
- data/templates/package_Vagrantfile.erb +11 -0
- data/templates/ssh_config.erb +9 -0
- data/test/locales/en.yml +8 -0
- data/test/test_helper.rb +26 -0
- data/test/vagrant/action/box/destroy_test.rb +18 -0
- data/test/vagrant/action/box/download_test.rb +125 -0
- data/test/vagrant/action/box/package_test.rb +25 -0
- data/test/vagrant/action/box/unpackage_test.rb +84 -0
- data/test/vagrant/action/box/verify_test.rb +30 -0
- data/test/vagrant/action/builder_test.rb +203 -0
- data/test/vagrant/action/env/set_test.rb +24 -0
- data/test/vagrant/action/environment_test.rb +27 -0
- data/test/vagrant/action/general/package_test.rb +268 -0
- data/test/vagrant/action/general/validate_test.rb +31 -0
- data/test/vagrant/action/vm/boot_test.rb +66 -0
- data/test/vagrant/action/vm/check_box_test.rb +56 -0
- data/test/vagrant/action/vm/check_guest_additions_test.rb +9 -0
- data/test/vagrant/action/vm/clean_machine_folder_test.rb +84 -0
- data/test/vagrant/action/vm/clear_forwarded_ports_test.rb +72 -0
- data/test/vagrant/action/vm/clear_nfs_exports_test.rb +22 -0
- data/test/vagrant/action/vm/clear_shared_folders_test.rb +49 -0
- data/test/vagrant/action/vm/customize_test.rb +30 -0
- data/test/vagrant/action/vm/destroy_test.rb +25 -0
- data/test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +49 -0
- data/test/vagrant/action/vm/discard_state_test.rb +45 -0
- data/test/vagrant/action/vm/export_test.rb +107 -0
- data/test/vagrant/action/vm/forward_ports_helpers_test.rb +70 -0
- data/test/vagrant/action/vm/forward_ports_test.rb +194 -0
- data/test/vagrant/action/vm/halt_test.rb +79 -0
- data/test/vagrant/action/vm/host_name_test.rb +36 -0
- data/test/vagrant/action/vm/import_test.rb +66 -0
- data/test/vagrant/action/vm/match_mac_address_test.rb +36 -0
- data/test/vagrant/action/vm/network_test.rb +286 -0
- data/test/vagrant/action/vm/nfs_helpers_test.rb +26 -0
- data/test/vagrant/action/vm/nfs_test.rb +260 -0
- data/test/vagrant/action/vm/package_test.rb +25 -0
- data/test/vagrant/action/vm/package_vagrantfile_test.rb +46 -0
- data/test/vagrant/action/vm/provision_test.rb +90 -0
- data/test/vagrant/action/vm/resume_test.rb +35 -0
- data/test/vagrant/action/vm/share_folders_test.rb +139 -0
- data/test/vagrant/action/vm/suspend_test.rb +35 -0
- data/test/vagrant/action/warden_test.rb +119 -0
- data/test/vagrant/action_test.rb +89 -0
- data/test/vagrant/box_collection_test.rb +45 -0
- data/test/vagrant/box_test.rb +74 -0
- data/test/vagrant/cli_test.rb +35 -0
- data/test/vagrant/command/base_test.rb +23 -0
- data/test/vagrant/command/group_base_test.rb +15 -0
- data/test/vagrant/command/helpers_test.rb +88 -0
- data/test/vagrant/command/package_test.rb +27 -0
- data/test/vagrant/config/base_test.rb +52 -0
- data/test/vagrant/config/error_recorder_test.rb +18 -0
- data/test/vagrant/config/ssh_test.rb +12 -0
- data/test/vagrant/config/vagrant_test.rb +35 -0
- data/test/vagrant/config/vm/provisioner_test.rb +92 -0
- data/test/vagrant/config/vm_test.rb +86 -0
- data/test/vagrant/config_test.rb +162 -0
- data/test/vagrant/data_store_test.rb +77 -0
- data/test/vagrant/downloaders/base_test.rb +28 -0
- data/test/vagrant/downloaders/file_test.rb +48 -0
- data/test/vagrant/downloaders/http_test.rb +80 -0
- data/test/vagrant/environment_test.rb +508 -0
- data/test/vagrant/errors_test.rb +42 -0
- data/test/vagrant/hosts/base_test.rb +46 -0
- data/test/vagrant/hosts/bsd_test.rb +53 -0
- data/test/vagrant/hosts/linux_test.rb +54 -0
- data/test/vagrant/plugin_test.rb +9 -0
- data/test/vagrant/provisioners/base_test.rb +63 -0
- data/test/vagrant/provisioners/chef_server_test.rb +188 -0
- data/test/vagrant/provisioners/chef_solo_test.rb +219 -0
- data/test/vagrant/provisioners/chef_test.rb +179 -0
- data/test/vagrant/provisioners/puppet_server_test.rb +68 -0
- data/test/vagrant/provisioners/puppet_test.rb +182 -0
- data/test/vagrant/provisioners/shell_test.rb +68 -0
- data/test/vagrant/ssh/session_test.rb +40 -0
- data/test/vagrant/ssh_test.rb +342 -0
- data/test/vagrant/systems/base_test.rb +18 -0
- data/test/vagrant/systems/linux_test.rb +114 -0
- data/test/vagrant/ui_test.rb +29 -0
- data/test/vagrant/util/busy_test.rb +106 -0
- data/test/vagrant/util/hash_with_indifferent_access_test.rb +39 -0
- data/test/vagrant/util/plain_logger_test.rb +17 -0
- data/test/vagrant/util/platform_test.rb +18 -0
- data/test/vagrant/util/resource_logger_test.rb +78 -0
- data/test/vagrant/util/retryable_test.rb +50 -0
- data/test/vagrant/util/stacked_proc_runner_test.rb +43 -0
- data/test/vagrant/util/template_renderer_test.rb +145 -0
- data/test/vagrant/vm_test.rb +291 -0
- data/vagrant.gemspec +36 -0
- metadata +514 -0
@@ -0,0 +1,332 @@
|
|
1
|
+
# This file contains all of the internal errors in Vagrant's core
|
2
|
+
# commands, actions, etc.
|
3
|
+
|
4
|
+
module Vagrant
|
5
|
+
# This module contains all of the internal errors in Vagrant's core.
|
6
|
+
# These errors are _expected_ errors and as such don't typically represent
|
7
|
+
# bugs in Vagrant itself. These are meant as a way to detect errors and
|
8
|
+
# display them in a user-friendly way.
|
9
|
+
#
|
10
|
+
# # Defining a new Error
|
11
|
+
#
|
12
|
+
# To define a new error, inherit from {VagrantError}, which lets Vagrant
|
13
|
+
# know that this is an expected error, and also gives you some helpers for
|
14
|
+
# providing exit codes and error messages. An example is shown below, then
|
15
|
+
# it is explained:
|
16
|
+
#
|
17
|
+
# class MyError < Vagrant::Errors::VagrantError
|
18
|
+
# error_key "my_error"
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# This creates an error with an I18n error key of "my_error." {VagrantError}
|
22
|
+
# uses I18n to look up error messages, in the "vagrant.errors" namespace. So
|
23
|
+
# in the above, the error message would be the translation of "vagrant.errors.my_error"
|
24
|
+
#
|
25
|
+
# If you don't want to use I18n, you can override the {#initialize} method and
|
26
|
+
# set your own error message.
|
27
|
+
#
|
28
|
+
# # Raising an Error
|
29
|
+
#
|
30
|
+
# To raise an error, it is nothing special, just raise it like any normal
|
31
|
+
# exception:
|
32
|
+
#
|
33
|
+
# raise MyError.new
|
34
|
+
#
|
35
|
+
# Eventually this exception will bubble out to the `vagrant` binary which
|
36
|
+
# will show a nice error message. And if it is raised in the middle of a
|
37
|
+
# middleware sequence, then {Action::Warden} will catch it and begin the
|
38
|
+
# recovery process prior to exiting.
|
39
|
+
module Errors
|
40
|
+
# Main superclass of any errors in Vagrant. This provides some
|
41
|
+
# convenience methods for setting the status code and error key.
|
42
|
+
# The status code is used by the `vagrant` executable as the
|
43
|
+
# error code, and the error key is used as a default message from
|
44
|
+
# I18n.
|
45
|
+
class VagrantError < StandardError
|
46
|
+
@@used_codes = []
|
47
|
+
|
48
|
+
def self.status_code(code = nil)
|
49
|
+
if code
|
50
|
+
raise "Status code already in use: #{code}" if @@used_codes.include?(code)
|
51
|
+
@@used_codes << code
|
52
|
+
end
|
53
|
+
|
54
|
+
define_method(:status_code) { code }
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.error_key(key=nil, namespace=nil)
|
58
|
+
define_method(:error_key) { key }
|
59
|
+
error_namespace(namespace) if namespace
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.error_namespace(namespace)
|
63
|
+
define_method(:error_namespace) { namespace }
|
64
|
+
end
|
65
|
+
|
66
|
+
def initialize(message=nil, *args)
|
67
|
+
message = { :_key => message } if message && !message.is_a?(Hash)
|
68
|
+
message = { :_key => error_key, :_namespace => error_namespace }.merge(message || {})
|
69
|
+
message = translate_error(message)
|
70
|
+
|
71
|
+
super
|
72
|
+
end
|
73
|
+
|
74
|
+
# The default error namespace which is used for the error key.
|
75
|
+
# This can be overridden here or by calling the "error_namespace"
|
76
|
+
# class method.
|
77
|
+
def error_namespace; "vagrant.errors"; end
|
78
|
+
|
79
|
+
# The key for the error message. This should be set using the
|
80
|
+
# {error_key} method but can be overridden here if needed.
|
81
|
+
def error_key; nil; end
|
82
|
+
|
83
|
+
protected
|
84
|
+
|
85
|
+
def translate_error(opts)
|
86
|
+
return nil if !opts[:_key]
|
87
|
+
I18n.t("#{opts[:_namespace]}.#{opts[:_key]}", opts)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
class BaseVMNotFound < VagrantError
|
92
|
+
status_code(18)
|
93
|
+
error_key(:base_vm_not_found)
|
94
|
+
end
|
95
|
+
|
96
|
+
class BoxAlreadyExists < VagrantError
|
97
|
+
status_code(14)
|
98
|
+
error_key(:already_exists, "vagrant.actions.box.unpackage")
|
99
|
+
end
|
100
|
+
|
101
|
+
class BoxDownloadUnknownType < VagrantError
|
102
|
+
status_code(13)
|
103
|
+
error_key(:unknown_type, "vagrant.actions.box.download")
|
104
|
+
end
|
105
|
+
|
106
|
+
class BoxNotFound < VagrantError
|
107
|
+
status_code(2)
|
108
|
+
error_key(:box_not_found)
|
109
|
+
end
|
110
|
+
|
111
|
+
class BoxNotSpecified < VagrantError
|
112
|
+
status_code(22)
|
113
|
+
error_key(:not_specified, "vagrant.actions.vm.check_box")
|
114
|
+
end
|
115
|
+
|
116
|
+
class BoxSpecifiedDoesntExist < VagrantError
|
117
|
+
status_code(23)
|
118
|
+
error_key(:does_not_exist, "vagrant.actions.vm.check_box")
|
119
|
+
end
|
120
|
+
|
121
|
+
class BoxVerificationFailed < VagrantError
|
122
|
+
status_code(15)
|
123
|
+
error_key(:failed, "vagrant.actions.box.verify")
|
124
|
+
end
|
125
|
+
|
126
|
+
class CLIMissingEnvironment < VagrantError
|
127
|
+
status_code(1)
|
128
|
+
error_key(:cli_missing_env)
|
129
|
+
end
|
130
|
+
|
131
|
+
class ConfigValidationFailed < VagrantError
|
132
|
+
status_code(42)
|
133
|
+
error_key(:config_validation)
|
134
|
+
end
|
135
|
+
|
136
|
+
class DotfileIsDirectory < VagrantError
|
137
|
+
status_code(46)
|
138
|
+
error_key(:dotfile_is_directory)
|
139
|
+
end
|
140
|
+
|
141
|
+
class DownloaderFileDoesntExist < VagrantError
|
142
|
+
status_code(37)
|
143
|
+
error_key(:file_missing, "vagrant.downloaders.file")
|
144
|
+
end
|
145
|
+
|
146
|
+
class DownloaderHTTPSocketError < VagrantError
|
147
|
+
status_code(38)
|
148
|
+
error_key(:socket_error, "vagrant.downloaders.http")
|
149
|
+
end
|
150
|
+
|
151
|
+
class ForwardPortAutolistEmpty < VagrantError
|
152
|
+
status_code(27)
|
153
|
+
error_key(:auto_empty, "vagrant.actions.vm.forward_ports")
|
154
|
+
end
|
155
|
+
|
156
|
+
class ForwardPortBelowThreshold < VagrantError
|
157
|
+
status_code(25)
|
158
|
+
error_key(:below_threshold_error, "vagrant.actions.vm.forward_ports")
|
159
|
+
end
|
160
|
+
|
161
|
+
class ForwardPortCollision < VagrantError
|
162
|
+
status_code(26)
|
163
|
+
error_key(:collision_error, "vagrant.actions.vm.forward_ports")
|
164
|
+
end
|
165
|
+
|
166
|
+
class MultiVMEnvironmentRequired < VagrantError
|
167
|
+
status_code(5)
|
168
|
+
error_key(:multi_vm_required)
|
169
|
+
end
|
170
|
+
|
171
|
+
class MultiVMTargetRequired < VagrantError
|
172
|
+
status_code(7)
|
173
|
+
error_key(:multi_vm_target_required)
|
174
|
+
end
|
175
|
+
|
176
|
+
class NetworkCollision < VagrantError
|
177
|
+
status_code(29)
|
178
|
+
error_key(:collides, "vagrant.actions.vm.network")
|
179
|
+
end
|
180
|
+
|
181
|
+
class NetworkNotFound < VagrantError
|
182
|
+
status_code(30)
|
183
|
+
error_key(:not_found, "vagrant.actions.vm.network")
|
184
|
+
end
|
185
|
+
|
186
|
+
# Note: This is a temporary error for Windows users while host-only
|
187
|
+
# networking doesn't quite work.
|
188
|
+
class NetworkNotImplemented < VagrantError
|
189
|
+
status_code(49)
|
190
|
+
error_key(:windows_not_implemented, "vagrant.actions.vm.network")
|
191
|
+
end
|
192
|
+
|
193
|
+
class NFSHostRequired < VagrantError
|
194
|
+
status_code(31)
|
195
|
+
error_key(:host_required, "vagrant.actions.vm.nfs")
|
196
|
+
end
|
197
|
+
|
198
|
+
class NFSNotSupported < VagrantError
|
199
|
+
status_code(32)
|
200
|
+
error_key(:not_supported, "vagrant.actions.vm.nfs")
|
201
|
+
end
|
202
|
+
|
203
|
+
class NFSNoHostNetwork < VagrantError
|
204
|
+
status_code(33)
|
205
|
+
error_key(:no_host_network, "vagrant.actions.vm.nfs")
|
206
|
+
end
|
207
|
+
|
208
|
+
class NoEnvironmentError < VagrantError
|
209
|
+
status_code(3)
|
210
|
+
error_key(:no_env)
|
211
|
+
end
|
212
|
+
|
213
|
+
class PackageIncludeMissing < VagrantError
|
214
|
+
status_code(20)
|
215
|
+
error_key(:include_file_missing, "vagrant.actions.general.package")
|
216
|
+
end
|
217
|
+
|
218
|
+
class PackageOutputExists < VagrantError
|
219
|
+
status_code(16)
|
220
|
+
error_key(:output_exists, "vagrant.actions.general.package")
|
221
|
+
end
|
222
|
+
|
223
|
+
class PackageRequiresDirectory < VagrantError
|
224
|
+
status_code(19)
|
225
|
+
error_key(:requires_directory, "vagrant.actions.general.package")
|
226
|
+
end
|
227
|
+
|
228
|
+
class PersistDotfileExists < VagrantError
|
229
|
+
status_code(34)
|
230
|
+
error_key(:dotfile_error, "vagrant.actions.vm.persist")
|
231
|
+
end
|
232
|
+
|
233
|
+
class SSHAuthenticationFailed < VagrantError
|
234
|
+
status_code(11)
|
235
|
+
error_key(:ssh_authentication_failed)
|
236
|
+
end
|
237
|
+
|
238
|
+
class SSHConnectionRefused < VagrantError
|
239
|
+
status_code(43)
|
240
|
+
error_key(:ssh_connection_refused)
|
241
|
+
end
|
242
|
+
|
243
|
+
class SSHKeyBadPermissions < VagrantError
|
244
|
+
status_code(12)
|
245
|
+
error_key(:ssh_key_bad_permissions)
|
246
|
+
end
|
247
|
+
|
248
|
+
class SSHPortNotDetected < VagrantError
|
249
|
+
status_code(50)
|
250
|
+
error_key(:ssh_port_not_detected)
|
251
|
+
end
|
252
|
+
|
253
|
+
class SSHUnavailable < VagrantError
|
254
|
+
status_code(45)
|
255
|
+
error_key(:ssh_unavailable)
|
256
|
+
end
|
257
|
+
|
258
|
+
class SSHUnavailableWindows < VagrantError
|
259
|
+
status_code(10)
|
260
|
+
error_key(:ssh_unavailable_windows)
|
261
|
+
end
|
262
|
+
|
263
|
+
class VagrantInterrupt < VagrantError
|
264
|
+
status_code(40)
|
265
|
+
error_key(:interrupted)
|
266
|
+
end
|
267
|
+
|
268
|
+
class VagrantfileSyntaxError < VagrantError
|
269
|
+
status_code(41)
|
270
|
+
error_key(:vagrantfile_syntax_error)
|
271
|
+
end
|
272
|
+
|
273
|
+
class VirtualBoxInvalidVersion < VagrantError
|
274
|
+
status_code(17)
|
275
|
+
error_key(:virtualbox_invalid_version)
|
276
|
+
end
|
277
|
+
|
278
|
+
class VirtualBoxNotDetected < VagrantError
|
279
|
+
status_code(8)
|
280
|
+
error_key(:virtualbox_not_detected)
|
281
|
+
end
|
282
|
+
|
283
|
+
# Note that this is a subclass of VirtualBoxNotDetected, so developers
|
284
|
+
# who script Vagrant or use it as a library in any way can rescue from
|
285
|
+
# "VirtualBoxNotDetected" and catch both errors, which represent the
|
286
|
+
# same thing. This subclass simply has a specialized error message.
|
287
|
+
class VirtualBoxNotDetected_Win64 < VirtualBoxNotDetected
|
288
|
+
status_code(48)
|
289
|
+
error_key(:virtualbox_not_detected_win64)
|
290
|
+
end
|
291
|
+
|
292
|
+
class VMBaseMacNotSpecified < VagrantError
|
293
|
+
status_code(47)
|
294
|
+
error_key(:no_base_mac, "vagrant.actions.vm.match_mac")
|
295
|
+
end
|
296
|
+
|
297
|
+
class VMFailedToBoot < VagrantError
|
298
|
+
status_code(21)
|
299
|
+
error_key(:failed_to_boot, "vagrant.actions.vm.boot")
|
300
|
+
end
|
301
|
+
|
302
|
+
class VMImportFailure < VagrantError
|
303
|
+
status_code(28)
|
304
|
+
error_key(:failure, "vagrant.actions.vm.import")
|
305
|
+
end
|
306
|
+
|
307
|
+
class VMNotCreatedError < VagrantError
|
308
|
+
status_code(6)
|
309
|
+
error_key(:vm_creation_required)
|
310
|
+
end
|
311
|
+
|
312
|
+
class VMNotFoundError < VagrantError
|
313
|
+
status_code(4)
|
314
|
+
error_key(:vm_not_found)
|
315
|
+
end
|
316
|
+
|
317
|
+
class VMNotRunningError < VagrantError
|
318
|
+
status_code(44)
|
319
|
+
error_key(:vm_not_running)
|
320
|
+
end
|
321
|
+
|
322
|
+
class VMPowerOffToPackage < VagrantError
|
323
|
+
status_code(24)
|
324
|
+
error_key(:power_off, "vagrant.actions.vm.export")
|
325
|
+
end
|
326
|
+
|
327
|
+
class VMSystemError < VagrantError
|
328
|
+
status_code(39)
|
329
|
+
error_namespace("vagrant.errors.system")
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Hosts
|
3
|
+
class Arch < Linux
|
4
|
+
def nfs_export(ip, folders)
|
5
|
+
output = TemplateRenderer.render('nfs/exports_linux',
|
6
|
+
:uuid => env.vm.uuid,
|
7
|
+
:ip => ip,
|
8
|
+
:folders => folders)
|
9
|
+
|
10
|
+
env.ui.info I18n.t("vagrant.hosts.arch.nfs_export.prepare")
|
11
|
+
sleep 0.5
|
12
|
+
|
13
|
+
output.split("\n").each do |line|
|
14
|
+
# This should only ask for administrative permission once, even
|
15
|
+
# though its executed in multiple subshells.
|
16
|
+
system(%Q[sudo su root -c "echo '#{line}' >> /etc/exports"])
|
17
|
+
end
|
18
|
+
|
19
|
+
# We run restart here instead of "update" just in case nfsd
|
20
|
+
# is not starting
|
21
|
+
system("sudo /etc/rc.d/rpcbind restart")
|
22
|
+
system("sudo /etc/rc.d/nfs-common restart")
|
23
|
+
system("sudo /etc/rc.d/nfs-server restart")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Hosts
|
3
|
+
# Base class representing a host machine. These classes
|
4
|
+
# define methods which may have host-specific (Mac OS X, Windows,
|
5
|
+
# Linux, etc) behavior. The class is automatically determined by
|
6
|
+
# default but may be explicitly set via `config.vagrant.host`.
|
7
|
+
class Base
|
8
|
+
# The {Environment} which this host belongs to.
|
9
|
+
attr_reader :env
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# Loads the proper host for the given value. If the value is nil
|
13
|
+
# or is the symbol `:detect`, then the host class will be detected
|
14
|
+
# using the `RUBY_PLATFORM` constant.
|
15
|
+
#
|
16
|
+
# @param [Environment] env
|
17
|
+
# @param [String] klass
|
18
|
+
# @return [Base]
|
19
|
+
def load(env, klass)
|
20
|
+
klass = detect if klass.nil? || klass == :detect
|
21
|
+
return nil if !klass
|
22
|
+
return klass.new(env)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Detects the proper host class for current platform and returns
|
26
|
+
# the class.
|
27
|
+
#
|
28
|
+
# @return [Class]
|
29
|
+
def detect
|
30
|
+
# More coming soon
|
31
|
+
classes = {
|
32
|
+
:darwin => BSD,
|
33
|
+
:bsd => BSD,
|
34
|
+
:arch => Arch,
|
35
|
+
:linux => Linux
|
36
|
+
}
|
37
|
+
|
38
|
+
classes.each do |type, klass|
|
39
|
+
return klass if Util::Platform.send("#{type}?")
|
40
|
+
end
|
41
|
+
|
42
|
+
nil
|
43
|
+
rescue Exception
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Initialzes a new host. This method shouldn't be called directly,
|
49
|
+
# typically, since it will be called by {Environment#load!}.
|
50
|
+
#
|
51
|
+
# @param [Environment] env
|
52
|
+
def initialize(env)
|
53
|
+
@env = env
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns true of false denoting whether or not this host supports
|
57
|
+
# NFS shared folder setup. This method ideally should verify that
|
58
|
+
# NFS is installed.
|
59
|
+
#
|
60
|
+
# @return [Boolean]
|
61
|
+
def nfs?
|
62
|
+
false
|
63
|
+
end
|
64
|
+
|
65
|
+
# Exports the given hash of folders via NFS. This method will raise
|
66
|
+
# an {Vagrant::Action::ActionException} if anything goes wrong.
|
67
|
+
#
|
68
|
+
# @param [String] ip IP of the guest machine.
|
69
|
+
# @param [Hash] folders Shared folders to sync.
|
70
|
+
def nfs_export(ip, folders)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Cleans up the exports for the current VM.
|
74
|
+
def nfs_cleanup
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Hosts
|
3
|
+
# Represents a BSD host, such as FreeBSD and Darwin (Mac OS X).
|
4
|
+
class BSD < Base
|
5
|
+
include Util
|
6
|
+
include Util::Retryable
|
7
|
+
|
8
|
+
def nfs?
|
9
|
+
retryable(:tries => 10, :on => TypeError) do
|
10
|
+
system("which nfsd > /dev/null 2>&1")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def nfs_export(ip, folders)
|
15
|
+
output = TemplateRenderer.render('nfs/exports',
|
16
|
+
:uuid => env.vm.uuid,
|
17
|
+
:ip => ip,
|
18
|
+
:folders => folders)
|
19
|
+
|
20
|
+
# The sleep ensures that the output is truly flushed before any `sudo`
|
21
|
+
# commands are issued.
|
22
|
+
env.ui.info I18n.t("vagrant.hosts.bsd.nfs_export.prepare")
|
23
|
+
sleep 0.5
|
24
|
+
|
25
|
+
output.split("\n").each do |line|
|
26
|
+
# This should only ask for administrative permission once, even
|
27
|
+
# though its executed in multiple subshells.
|
28
|
+
line = line.gsub('"', '\"')
|
29
|
+
system(%Q[sudo su root -c "echo '#{line}' >> /etc/exports"])
|
30
|
+
end
|
31
|
+
|
32
|
+
# We run restart here instead of "update" just in case nfsd
|
33
|
+
# is not starting
|
34
|
+
system("sudo nfsd restart")
|
35
|
+
end
|
36
|
+
|
37
|
+
def nfs_cleanup
|
38
|
+
return if !File.exist?("/etc/exports")
|
39
|
+
|
40
|
+
retryable(:tries => 10, :on => TypeError) do
|
41
|
+
system("cat /etc/exports | grep 'VAGRANT-BEGIN: #{env.vm.uuid}' > /dev/null 2>&1")
|
42
|
+
|
43
|
+
if $?.to_i == 0
|
44
|
+
# Use sed to just strip out the block of code which was inserted
|
45
|
+
# by Vagrant
|
46
|
+
system("sudo sed -e '/^# VAGRANT-BEGIN: #{env.vm.uuid}/,/^# VAGRANT-END: #{env.vm.uuid}/ d' -ibak /etc/exports")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|