vagrantup 0.8.10 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (325) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +77 -1
  3. data/Gemfile +0 -14
  4. data/LICENSE +1 -1
  5. data/bin/vagrant +47 -20
  6. data/config/default.rb +6 -14
  7. data/lib/vagrant/action/box/destroy.rb +7 -3
  8. data/lib/vagrant/action/box/download.rb +8 -8
  9. data/lib/vagrant/action/box/package.rb +2 -2
  10. data/lib/vagrant/action/box/unpackage.rb +13 -7
  11. data/lib/vagrant/action/box/verify.rb +5 -5
  12. data/lib/vagrant/action/builder.rb +23 -19
  13. data/lib/vagrant/action/builtin.rb +117 -79
  14. data/lib/vagrant/action/env/set.rb +7 -4
  15. data/lib/vagrant/action/environment.rb +3 -41
  16. data/lib/vagrant/action/general/package.rb +14 -29
  17. data/lib/vagrant/action/general/validate.rb +2 -2
  18. data/lib/vagrant/action/runner.rb +53 -0
  19. data/lib/vagrant/action/vm/boot.rb +9 -9
  20. data/lib/vagrant/action/vm/check_accessible.rb +2 -2
  21. data/lib/vagrant/action/vm/check_box.rb +10 -12
  22. data/lib/vagrant/action/vm/check_guest_additions.rb +8 -8
  23. data/lib/vagrant/action/vm/check_port_collisions.rb +85 -0
  24. data/lib/vagrant/action/vm/clean_machine_folder.rb +4 -4
  25. data/lib/vagrant/action/vm/clear_forwarded_ports.rb +3 -11
  26. data/lib/vagrant/action/vm/clear_network_interfaces.rb +31 -0
  27. data/lib/vagrant/action/vm/clear_shared_folders.rb +2 -11
  28. data/lib/vagrant/action/vm/customize.rb +19 -9
  29. data/lib/vagrant/action/vm/destroy.rb +4 -4
  30. data/lib/vagrant/action/vm/destroy_unused_network_interfaces.rb +2 -12
  31. data/lib/vagrant/action/vm/discard_state.rb +4 -4
  32. data/lib/vagrant/action/vm/export.rb +13 -8
  33. data/lib/vagrant/action/vm/forward_ports.rb +55 -102
  34. data/lib/vagrant/action/vm/halt.rb +9 -6
  35. data/lib/vagrant/action/vm/host_name.rb +4 -4
  36. data/lib/vagrant/action/vm/import.rb +19 -10
  37. data/lib/vagrant/action/vm/match_mac_address.rb +4 -9
  38. data/lib/vagrant/action/vm/network.rb +300 -94
  39. data/lib/vagrant/action/vm/nfs.rb +41 -26
  40. data/lib/vagrant/action/vm/package.rb +1 -1
  41. data/lib/vagrant/action/vm/package_vagrantfile.rb +5 -2
  42. data/lib/vagrant/action/vm/provision.rb +42 -13
  43. data/lib/vagrant/action/vm/provisioner_cleanup.rb +2 -2
  44. data/lib/vagrant/action/vm/{clear_nfs_exports.rb → prune_nfs_exports.rb} +7 -7
  45. data/lib/vagrant/action/vm/resume.rb +4 -4
  46. data/lib/vagrant/action/vm/setup_package_files.rb +54 -0
  47. data/lib/vagrant/action/vm/share_folders.rb +63 -39
  48. data/lib/vagrant/action/vm/suspend.rb +4 -4
  49. data/lib/vagrant/action/warden.rb +13 -6
  50. data/lib/vagrant/action.rb +45 -123
  51. data/lib/vagrant/box.rb +9 -55
  52. data/lib/vagrant/box_collection.rb +22 -17
  53. data/lib/vagrant/cli.rb +62 -47
  54. data/lib/vagrant/command/base.rb +135 -90
  55. data/lib/vagrant/command/box.rb +46 -21
  56. data/lib/vagrant/command/box_add.rb +33 -0
  57. data/lib/vagrant/command/box_list.rb +25 -0
  58. data/lib/vagrant/command/box_remove.rb +23 -0
  59. data/lib/vagrant/command/box_repackage.rb +23 -0
  60. data/lib/vagrant/command/destroy.rb +16 -5
  61. data/lib/vagrant/command/halt.rb +25 -7
  62. data/lib/vagrant/command/init.rb +30 -7
  63. data/lib/vagrant/command/package.rb +49 -18
  64. data/lib/vagrant/command/provision.rb +22 -9
  65. data/lib/vagrant/command/reload.rb +18 -5
  66. data/lib/vagrant/command/resume.rb +18 -5
  67. data/lib/vagrant/command/ssh.rb +69 -31
  68. data/lib/vagrant/command/ssh_config.rb +37 -22
  69. data/lib/vagrant/command/status.rb +22 -20
  70. data/lib/vagrant/command/suspend.rb +18 -5
  71. data/lib/vagrant/command/up.rb +41 -8
  72. data/lib/vagrant/command.rb +18 -20
  73. data/lib/vagrant/communication/base.rb +56 -0
  74. data/lib/vagrant/communication/ssh.rb +200 -0
  75. data/lib/vagrant/communication.rb +7 -0
  76. data/lib/vagrant/config/base.rb +18 -26
  77. data/lib/vagrant/config/container.rb +37 -0
  78. data/lib/vagrant/config/error_recorder.rb +1 -1
  79. data/lib/vagrant/config/loader.rb +125 -0
  80. data/lib/vagrant/config/nfs.rb +1 -3
  81. data/lib/vagrant/config/package.rb +1 -3
  82. data/lib/vagrant/config/ssh.rb +31 -16
  83. data/lib/vagrant/config/top.rb +36 -25
  84. data/lib/vagrant/config/vagrant.rb +2 -5
  85. data/lib/vagrant/config/vm/provisioner.rb +16 -20
  86. data/lib/vagrant/config/vm/sub_vm.rb +1 -1
  87. data/lib/vagrant/config/vm.rb +115 -56
  88. data/lib/vagrant/config.rb +29 -103
  89. data/lib/vagrant/data_store.rb +23 -15
  90. data/lib/vagrant/downloaders/base.rb +7 -5
  91. data/lib/vagrant/downloaders/file.rb +4 -4
  92. data/lib/vagrant/downloaders/http.rb +4 -5
  93. data/lib/vagrant/driver/virtualbox.rb +121 -0
  94. data/lib/vagrant/driver/virtualbox_4_0.rb +411 -0
  95. data/lib/vagrant/driver/virtualbox_4_1.rb +411 -0
  96. data/lib/vagrant/driver/virtualbox_base.rb +284 -0
  97. data/lib/vagrant/driver.rb +7 -0
  98. data/lib/vagrant/environment.rb +221 -240
  99. data/lib/vagrant/errors.rb +74 -25
  100. data/lib/vagrant/guest/arch.rb +48 -0
  101. data/lib/vagrant/{systems → guest}/base.rb +30 -18
  102. data/lib/vagrant/guest/debian.rb +61 -0
  103. data/lib/vagrant/{systems → guest}/freebsd.rb +11 -18
  104. data/lib/vagrant/guest/gentoo.rb +32 -0
  105. data/lib/vagrant/{systems → guest}/linux/config.rb +2 -4
  106. data/lib/vagrant/guest/linux/error.rb +9 -0
  107. data/lib/vagrant/guest/linux.rb +78 -0
  108. data/lib/vagrant/guest/redhat.rb +66 -0
  109. data/lib/vagrant/guest/solaris.rb +114 -0
  110. data/lib/vagrant/{systems → guest}/suse.rb +2 -2
  111. data/lib/vagrant/guest/ubuntu.rb +23 -0
  112. data/lib/vagrant/guest.rb +16 -0
  113. data/lib/vagrant/hosts/arch.rb +7 -3
  114. data/lib/vagrant/hosts/base.rb +36 -46
  115. data/lib/vagrant/hosts/bsd.rb +53 -16
  116. data/lib/vagrant/hosts/fedora.rb +14 -0
  117. data/lib/vagrant/hosts/freebsd.rb +6 -36
  118. data/lib/vagrant/hosts/linux.rb +45 -20
  119. data/lib/vagrant/hosts/windows.rb +16 -0
  120. data/lib/vagrant/hosts.rb +23 -6
  121. data/lib/vagrant/provisioners/base.rb +11 -34
  122. data/lib/vagrant/provisioners/chef.rb +30 -26
  123. data/lib/vagrant/provisioners/chef_client.rb +37 -23
  124. data/lib/vagrant/provisioners/chef_solo.rb +61 -16
  125. data/lib/vagrant/provisioners/puppet.rb +70 -38
  126. data/lib/vagrant/provisioners/puppet_server.rb +12 -13
  127. data/lib/vagrant/provisioners/shell.rb +24 -24
  128. data/lib/vagrant/provisioners.rb +10 -7
  129. data/lib/vagrant/registry.rb +49 -0
  130. data/lib/vagrant/ssh.rb +82 -153
  131. data/lib/vagrant/ui.rb +118 -50
  132. data/lib/vagrant/util/busy.rb +1 -1
  133. data/lib/vagrant/util/file_mode.rb +12 -0
  134. data/lib/vagrant/util/network_ip.rb +28 -0
  135. data/lib/vagrant/util/platform.rb +1 -0
  136. data/lib/vagrant/util/subprocess.rb +227 -0
  137. data/lib/vagrant/version.rb +1 -1
  138. data/lib/vagrant/vm.rb +111 -97
  139. data/lib/vagrant.rb +132 -5
  140. data/tasks/acceptance.rake +3 -3
  141. data/tasks/test.rake +7 -2
  142. data/templates/commands/init/Vagrantfile.erb +11 -4
  143. data/templates/{ssh_config.erb → commands/ssh_config/config.erb} +0 -0
  144. data/templates/guests/arch/network_dhcp.erb +7 -0
  145. data/templates/guests/arch/network_static.erb +7 -0
  146. data/templates/guests/debian/network_dhcp.erb +6 -0
  147. data/templates/guests/debian/network_static.erb +7 -0
  148. data/templates/guests/gentoo/network_dhcp.erb +4 -0
  149. data/templates/guests/gentoo/network_static.erb +4 -0
  150. data/templates/guests/redhat/network_dhcp.erb +6 -0
  151. data/templates/guests/redhat/network_static.erb +7 -0
  152. data/templates/locales/en.yml +241 -122
  153. data/templates/{chef_server_client.erb → provisioners/chef_client/client.erb} +0 -0
  154. data/templates/{chef_solo_solo.erb → provisioners/chef_solo/solo.erb} +0 -0
  155. data/test/acceptance/base.rb +10 -10
  156. data/test/acceptance/box_test.rb +28 -6
  157. data/test/acceptance/destroy_test.rb +1 -1
  158. data/test/acceptance/halt_test.rb +4 -4
  159. data/test/acceptance/init_test.rb +3 -3
  160. data/test/acceptance/networking/host_only_test.rb +37 -0
  161. data/test/acceptance/networking/port_forward_test.rb +125 -0
  162. data/test/acceptance/package_test.rb +46 -0
  163. data/test/acceptance/provisioning/basic_test.rb +61 -0
  164. data/test/acceptance/provisioning/chef_solo_test.rb +37 -0
  165. data/test/acceptance/provisioning/shell_test.rb +53 -0
  166. data/test/acceptance/resume_test.rb +1 -1
  167. data/test/acceptance/skeletons/chef_solo_basic/README.md +3 -0
  168. data/test/acceptance/skeletons/chef_solo_basic/cookbooks/basic/recipes/default.rb +5 -0
  169. data/test/acceptance/skeletons/chef_solo_json/README.md +3 -0
  170. data/test/acceptance/skeletons/chef_solo_json/cookbooks/basic/recipes/default.rb +6 -0
  171. data/test/acceptance/skeletons/provisioner_multi/README.md +3 -0
  172. data/test/acceptance/skeletons/provisioner_multi/cookbooks/basic/recipes/default.rb +5 -0
  173. data/test/acceptance/ssh_test.rb +7 -2
  174. data/test/acceptance/support/config.rb +1 -1
  175. data/test/acceptance/support/isolated_environment.rb +41 -150
  176. data/test/acceptance/support/matchers/match_output.rb +1 -1
  177. data/test/acceptance/support/matchers/succeed.rb +14 -0
  178. data/test/acceptance/support/network_tests.rb +29 -0
  179. data/test/acceptance/support/output.rb +9 -1
  180. data/test/acceptance/support/shared/base_context.rb +16 -9
  181. data/test/acceptance/support/shared/command_examples.rb +4 -4
  182. data/test/acceptance/suspend_test.rb +1 -1
  183. data/test/acceptance/up_basic_test.rb +26 -7
  184. data/test/acceptance/up_with_box_url.rb +1 -1
  185. data/test/acceptance/vagrant_test.rb +1 -1
  186. data/test/acceptance/version_test.rb +0 -5
  187. data/test/support/isolated_environment.rb +46 -0
  188. data/test/{acceptance/support → support}/tempdir.rb +0 -0
  189. data/test/unit/base.rb +21 -0
  190. data/test/unit/support/isolated_environment.rb +39 -0
  191. data/test/unit/support/shared/base_context.rb +30 -0
  192. data/test/unit/vagrant/action/builder_test.rb +126 -177
  193. data/test/unit/vagrant/action/environment_test.rb +10 -21
  194. data/test/unit/vagrant/action/runner_test.rb +65 -0
  195. data/test/unit/vagrant/action/warden_test.rb +64 -97
  196. data/test/unit/vagrant/box_collection_test.rb +44 -33
  197. data/test/unit/vagrant/box_test.rb +25 -65
  198. data/test/unit/vagrant/command/base_test.rb +141 -14
  199. data/test/unit/vagrant/config/base_test.rb +16 -43
  200. data/test/unit/vagrant/config/loader_test.rb +79 -0
  201. data/test/unit/vagrant/config/top_test.rb +69 -0
  202. data/test/unit/vagrant/config/vm_test.rb +62 -47
  203. data/test/unit/vagrant/config_test.rb +16 -151
  204. data/test/unit/vagrant/data_store_test.rb +43 -61
  205. data/test/unit/vagrant/downloaders/base_test.rb +12 -22
  206. data/test/unit/vagrant/downloaders/file_test.rb +58 -31
  207. data/test/unit/vagrant/downloaders/http_test.rb +12 -86
  208. data/test/unit/vagrant/environment_test.rb +107 -536
  209. data/test/unit/vagrant/hosts_test.rb +36 -0
  210. data/test/unit/vagrant/registry_test.rb +56 -0
  211. data/test/unit/vagrant/util/file_checksum_test.rb +23 -0
  212. data/test/unit/vagrant/util/hash_with_indifferent_access_test.rb +23 -24
  213. data/test/unit/vagrant/util/network_ip_test.rb +17 -0
  214. data/test/unit/vagrant/util/retryable_test.rb +90 -34
  215. data/test/unit/vagrant_test.rb +27 -0
  216. data/test/{unit → unit_legacy}/locales/en.yml +0 -0
  217. data/test/{unit → unit_legacy}/test_helper.rb +0 -0
  218. data/test/{unit → unit_legacy}/vagrant/action/box/destroy_test.rb +0 -0
  219. data/test/{unit → unit_legacy}/vagrant/action/box/download_test.rb +0 -0
  220. data/test/{unit → unit_legacy}/vagrant/action/box/package_test.rb +0 -0
  221. data/test/{unit → unit_legacy}/vagrant/action/box/unpackage_test.rb +0 -0
  222. data/test/{unit → unit_legacy}/vagrant/action/box/verify_test.rb +0 -0
  223. data/test/{unit → unit_legacy}/vagrant/action/env/set_test.rb +0 -0
  224. data/test/{unit → unit_legacy}/vagrant/action/general/package_test.rb +0 -0
  225. data/test/{unit → unit_legacy}/vagrant/action/general/validate_test.rb +0 -0
  226. data/test/{unit → unit_legacy}/vagrant/action/vm/boot_test.rb +0 -0
  227. data/test/{unit → unit_legacy}/vagrant/action/vm/check_accessible_test.rb +0 -0
  228. data/test/{unit → unit_legacy}/vagrant/action/vm/check_box_test.rb +0 -0
  229. data/test/{unit → unit_legacy}/vagrant/action/vm/check_guest_additions_test.rb +0 -0
  230. data/test/{unit → unit_legacy}/vagrant/action/vm/clean_machine_folder_test.rb +0 -0
  231. data/test/{unit → unit_legacy}/vagrant/action/vm/clear_forwarded_ports_test.rb +0 -0
  232. data/test/{unit → unit_legacy}/vagrant/action/vm/clear_nfs_exports_test.rb +0 -0
  233. data/test/{unit → unit_legacy}/vagrant/action/vm/clear_shared_folders_test.rb +0 -0
  234. data/test/{unit → unit_legacy}/vagrant/action/vm/customize_test.rb +0 -0
  235. data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_test.rb +0 -0
  236. data/test/{unit → unit_legacy}/vagrant/action/vm/destroy_unused_network_interfaces_test.rb +0 -0
  237. data/test/{unit → unit_legacy}/vagrant/action/vm/discard_state_test.rb +0 -0
  238. data/test/{unit → unit_legacy}/vagrant/action/vm/export_test.rb +0 -0
  239. data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_helpers_test.rb +0 -0
  240. data/test/{unit → unit_legacy}/vagrant/action/vm/forward_ports_test.rb +0 -0
  241. data/test/{unit → unit_legacy}/vagrant/action/vm/halt_test.rb +0 -0
  242. data/test/{unit → unit_legacy}/vagrant/action/vm/host_name_test.rb +0 -0
  243. data/test/{unit → unit_legacy}/vagrant/action/vm/import_test.rb +0 -0
  244. data/test/{unit → unit_legacy}/vagrant/action/vm/match_mac_address_test.rb +0 -0
  245. data/test/{unit → unit_legacy}/vagrant/action/vm/modify_test.rb +0 -0
  246. data/test/{unit → unit_legacy}/vagrant/action/vm/network_test.rb +0 -0
  247. data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_helpers_test.rb +0 -0
  248. data/test/{unit → unit_legacy}/vagrant/action/vm/nfs_test.rb +0 -0
  249. data/test/{unit → unit_legacy}/vagrant/action/vm/package_test.rb +0 -0
  250. data/test/{unit → unit_legacy}/vagrant/action/vm/package_vagrantfile_test.rb +0 -0
  251. data/test/{unit → unit_legacy}/vagrant/action/vm/provision_test.rb +0 -0
  252. data/test/{unit → unit_legacy}/vagrant/action/vm/provisioner_cleanup_test.rb +0 -0
  253. data/test/{unit → unit_legacy}/vagrant/action/vm/resume_test.rb +0 -0
  254. data/test/{unit → unit_legacy}/vagrant/action/vm/share_folders_test.rb +0 -0
  255. data/test/{unit → unit_legacy}/vagrant/action/vm/suspend_test.rb +0 -0
  256. data/test/{unit → unit_legacy}/vagrant/action_test.rb +0 -0
  257. data/test/unit_legacy/vagrant/box_collection_test.rb +45 -0
  258. data/test/unit_legacy/vagrant/box_test.rb +74 -0
  259. data/test/{unit → unit_legacy}/vagrant/cli_test.rb +0 -0
  260. data/test/unit_legacy/vagrant/command/base_test.rb +23 -0
  261. data/test/{unit → unit_legacy}/vagrant/command/group_base_test.rb +0 -0
  262. data/test/{unit → unit_legacy}/vagrant/command/helpers_test.rb +0 -0
  263. data/test/{unit → unit_legacy}/vagrant/command/init_test.rb +0 -0
  264. data/test/{unit → unit_legacy}/vagrant/command/package_test.rb +0 -0
  265. data/test/unit_legacy/vagrant/config/base_test.rb +52 -0
  266. data/test/{unit → unit_legacy}/vagrant/config/error_recorder_test.rb +0 -0
  267. data/test/{unit → unit_legacy}/vagrant/config/ssh_test.rb +0 -0
  268. data/test/{unit → unit_legacy}/vagrant/config/vagrant_test.rb +0 -0
  269. data/test/{unit → unit_legacy}/vagrant/config/vm/provisioner_test.rb +0 -0
  270. data/test/unit_legacy/vagrant/config/vm_test.rb +47 -0
  271. data/test/unit_legacy/vagrant/config_test.rb +148 -0
  272. data/test/unit_legacy/vagrant/downloaders/http_test.rb +93 -0
  273. data/test/unit_legacy/vagrant/environment_test.rb +539 -0
  274. data/test/{unit → unit_legacy}/vagrant/errors_test.rb +0 -0
  275. data/test/{unit → unit_legacy}/vagrant/hosts/base_test.rb +0 -0
  276. data/test/{unit → unit_legacy}/vagrant/hosts/bsd_test.rb +0 -0
  277. data/test/{unit → unit_legacy}/vagrant/hosts/linux_test.rb +0 -0
  278. data/test/{unit → unit_legacy}/vagrant/plugin_test.rb +0 -0
  279. data/test/{unit → unit_legacy}/vagrant/provisioners/base_test.rb +0 -0
  280. data/test/{unit → unit_legacy}/vagrant/provisioners/chef_client_test.rb +0 -0
  281. data/test/{unit → unit_legacy}/vagrant/provisioners/chef_solo_test.rb +0 -0
  282. data/test/{unit → unit_legacy}/vagrant/provisioners/chef_test.rb +0 -0
  283. data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_server_test.rb +0 -0
  284. data/test/{unit → unit_legacy}/vagrant/provisioners/puppet_test.rb +0 -0
  285. data/test/{unit → unit_legacy}/vagrant/provisioners/shell_test.rb +0 -0
  286. data/test/{unit → unit_legacy}/vagrant/ssh/session_test.rb +0 -0
  287. data/test/{unit → unit_legacy}/vagrant/ssh_test.rb +0 -0
  288. data/test/{unit → unit_legacy}/vagrant/systems/base_test.rb +0 -0
  289. data/test/{unit → unit_legacy}/vagrant/systems/linux_test.rb +0 -0
  290. data/test/{unit → unit_legacy}/vagrant/util/busy_test.rb +0 -0
  291. data/test/{unit → unit_legacy}/vagrant/util/counter_test.rb +0 -0
  292. data/test/{unit → unit_legacy}/vagrant/util/platform_test.rb +0 -0
  293. data/test/{unit → unit_legacy}/vagrant/util/stacked_proc_runner_test.rb +0 -0
  294. data/test/{unit → unit_legacy}/vagrant/util/template_renderer_test.rb +0 -0
  295. data/test/{unit → unit_legacy}/vagrant/vm_test.rb +0 -0
  296. data/vagrant.gemspec +7 -9
  297. metadata +183 -179
  298. data/keys/vagrant.ppk +0 -26
  299. data/lib/vagrant/action/box.rb +0 -11
  300. data/lib/vagrant/action/env.rb +0 -7
  301. data/lib/vagrant/action/general.rb +0 -8
  302. data/lib/vagrant/action/vm/forward_ports_helpers.rb +0 -28
  303. data/lib/vagrant/action/vm/modify.rb +0 -37
  304. data/lib/vagrant/action/vm/nfs_helpers.rb +0 -11
  305. data/lib/vagrant/action/vm.rb +0 -34
  306. data/lib/vagrant/command/group_base.rb +0 -107
  307. data/lib/vagrant/command/helpers.rb +0 -33
  308. data/lib/vagrant/command/named_base.rb +0 -14
  309. data/lib/vagrant/command/upgrade_to_060.rb +0 -45
  310. data/lib/vagrant/command/version.rb +0 -13
  311. data/lib/vagrant/ssh/session.rb +0 -136
  312. data/lib/vagrant/systems/arch.rb +0 -34
  313. data/lib/vagrant/systems/debian.rb +0 -36
  314. data/lib/vagrant/systems/gentoo.rb +0 -27
  315. data/lib/vagrant/systems/linux/error.rb +0 -9
  316. data/lib/vagrant/systems/linux.rb +0 -82
  317. data/lib/vagrant/systems/redhat.rb +0 -48
  318. data/lib/vagrant/systems/solaris.rb +0 -113
  319. data/lib/vagrant/systems/ubuntu.rb +0 -17
  320. data/lib/vagrant/systems.rb +0 -13
  321. data/templates/network_entry_arch.erb +0 -9
  322. data/templates/network_entry_debian.erb +0 -8
  323. data/templates/network_entry_gentoo.erb +0 -5
  324. data/templates/network_entry_redhat.erb +0 -9
  325. data/test/unit/vagrant/ui_test.rb +0 -29
@@ -118,14 +118,19 @@ module Vagrant
118
118
  error_key(:does_not_exist, "vagrant.actions.vm.check_box")
119
119
  end
120
120
 
121
+ class BoxUnpackageFailure < VagrantError
122
+ status_code(57)
123
+ error_key(:untar_failure, "vagrant.actions.box.unpackage")
124
+ end
125
+
121
126
  class BoxVerificationFailed < VagrantError
122
127
  status_code(15)
123
128
  error_key(:failed, "vagrant.actions.box.verify")
124
129
  end
125
130
 
126
- class CLIMissingEnvironment < VagrantError
131
+ class CLIInvalidOptions < VagrantError
127
132
  status_code(1)
128
- error_key(:cli_missing_env)
133
+ error_key(:cli_invalid_options)
129
134
  end
130
135
 
131
136
  class ConfigValidationFailed < VagrantError
@@ -133,6 +138,11 @@ module Vagrant
133
138
  error_key(:config_validation)
134
139
  end
135
140
 
141
+ class DeprecationError < VagrantError
142
+ status_code(60)
143
+ error_key(:deprecation)
144
+ end
145
+
136
146
  class DotfileIsDirectory < VagrantError
137
147
  status_code(46)
138
148
  error_key(:dotfile_is_directory)
@@ -163,6 +173,11 @@ module Vagrant
163
173
  error_key(:home_dir_migration_failed)
164
174
  end
165
175
 
176
+ class HomeDirectoryNotAccessible < VagrantError
177
+ status_code(55)
178
+ error_key(:home_dir_not_accessible)
179
+ end
180
+
166
181
  class ForwardPortAutolistEmpty < VagrantError
167
182
  status_code(27)
168
183
  error_key(:auto_empty, "vagrant.actions.vm.forward_ports")
@@ -173,6 +188,11 @@ module Vagrant
173
188
  error_key(:collision_error, "vagrant.actions.vm.forward_ports")
174
189
  end
175
190
 
191
+ class ForwardPortCollisionResume < VagrantError
192
+ status_code(62)
193
+ error_key(:port_collision_resume)
194
+ end
195
+
176
196
  class MultiVMEnvironmentRequired < VagrantError
177
197
  status_code(5)
178
198
  error_key(:multi_vm_required)
@@ -183,21 +203,29 @@ module Vagrant
183
203
  error_key(:multi_vm_target_required)
184
204
  end
185
205
 
206
+ class NetworkAdapterCollision < VagrantError
207
+ status_code(65)
208
+ error_key(:adapter_collision, "vagrant.actions.vm.network")
209
+ end
210
+
186
211
  class NetworkCollision < VagrantError
187
212
  status_code(29)
188
- error_key(:collides, "vagrant.actions.vm.network")
213
+ error_key(:collides, "vagrant.actions.vm.host_only_network")
189
214
  end
190
215
 
191
- class NetworkNotFound < VagrantError
192
- status_code(30)
193
- error_key(:not_found, "vagrant.actions.vm.network")
216
+ class NetworkNoAdapters < VagrantError
217
+ status_code(64)
218
+ error_key(:no_adapters, "vagrant.actions.vm.network")
194
219
  end
195
220
 
196
- # Note: This is a temporary error for Windows users while host-only
197
- # networking doesn't quite work.
198
- class NetworkNotImplemented < VagrantError
199
- status_code(49)
200
- error_key(:windows_not_implemented, "vagrant.actions.vm.network")
221
+ class NetworkDHCPAlreadyAttached < VagrantError
222
+ status_code(68)
223
+ error_key(:dhcp_already_attached, "vagrant.actions.vm.network")
224
+ end
225
+
226
+ class NetworkNotFound < VagrantError
227
+ status_code(30)
228
+ error_key(:not_found, "vagrant.actions.vm.host_only_network")
201
229
  end
202
230
 
203
231
  class NFSHostRequired < VagrantError
@@ -240,6 +268,16 @@ module Vagrant
240
268
  error_key(:dotfile_error, "vagrant.actions.vm.persist")
241
269
  end
242
270
 
271
+ class SCPUnavailable < VagrantError
272
+ status_code(56)
273
+ error_key(:scp_unavailable)
274
+ end
275
+
276
+ class SharedFolderCreateFailed < VagrantError
277
+ status_code(66)
278
+ error_key(:shared_folder_create_failed)
279
+ end
280
+
243
281
  class SSHAuthenticationFailed < VagrantError
244
282
  status_code(11)
245
283
  error_key(:ssh_authentication_failed)
@@ -275,11 +313,21 @@ module Vagrant
275
313
  error_key(:interrupted)
276
314
  end
277
315
 
316
+ class VagrantfileExistsError < VagrantError
317
+ status_code(58)
318
+ error_key(:vagrantfile_exists)
319
+ end
320
+
278
321
  class VagrantfileSyntaxError < VagrantError
279
322
  status_code(41)
280
323
  error_key(:vagrantfile_syntax_error)
281
324
  end
282
325
 
326
+ class VBoxManageError < VagrantError
327
+ status_code(59)
328
+ error_key(:vboxmanage_error)
329
+ end
330
+
283
331
  class VirtualBoxInvalidVersion < VagrantError
284
332
  status_code(17)
285
333
  error_key(:virtualbox_invalid_version)
@@ -290,25 +338,26 @@ module Vagrant
290
338
  error_key(:virtualbox_not_detected)
291
339
  end
292
340
 
293
- # Note that this is a subclass of VirtualBoxNotDetected, so developers
294
- # who script Vagrant or use it as a library in any way can rescue from
295
- # "VirtualBoxNotDetected" and catch both errors, which represent the
296
- # same thing. This subclass simply has a specialized error message.
297
- class VirtualBoxNotDetected_Win64 < VirtualBoxNotDetected
298
- status_code(48)
299
- error_key(:virtualbox_not_detected_win64)
300
- end
301
-
302
341
  class VMBaseMacNotSpecified < VagrantError
303
342
  status_code(47)
304
343
  error_key(:no_base_mac, "vagrant.actions.vm.match_mac")
305
344
  end
306
345
 
346
+ class VMCustomizationFailed < VagrantError
347
+ status_code(61)
348
+ error_key(:failure, "vagrant.actions.vm.customize")
349
+ end
350
+
307
351
  class VMFailedToBoot < VagrantError
308
352
  status_code(21)
309
353
  error_key(:failed_to_boot, "vagrant.actions.vm.boot")
310
354
  end
311
355
 
356
+ class VMGuestError < VagrantError
357
+ status_code(39)
358
+ error_namespace("vagrant.errors.guest")
359
+ end
360
+
312
361
  class VMImportFailure < VagrantError
313
362
  status_code(28)
314
363
  error_key(:failure, "vagrant.actions.vm.import")
@@ -319,6 +368,11 @@ module Vagrant
319
368
  error_key(:vm_inaccessible)
320
369
  end
321
370
 
371
+ class VMNoMatchError < VagrantError
372
+ status_code(63)
373
+ error_key(:vm_no_match)
374
+ end
375
+
322
376
  class VMNotCreatedError < VagrantError
323
377
  status_code(6)
324
378
  error_key(:vm_creation_required)
@@ -338,10 +392,5 @@ module Vagrant
338
392
  status_code(24)
339
393
  error_key(:power_off, "vagrant.actions.vm.export")
340
394
  end
341
-
342
- class VMSystemError < VagrantError
343
- status_code(39)
344
- error_namespace("vagrant.errors.system")
345
- end
346
395
  end
347
396
  end
@@ -0,0 +1,48 @@
1
+ require 'set'
2
+ require 'tempfile'
3
+
4
+ module Vagrant
5
+ module Guest
6
+ class Arch < Linux
7
+ def change_host_name(name)
8
+ # Only do this if the hostname is not already set
9
+ if !vm.channel.test("sudo hostname | grep '#{name}'")
10
+ vm.channel.sudo("sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/rc.conf")
11
+ vm.channel.sudo("hostname #{name}")
12
+ vm.channel.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} @' /etc/hosts")
13
+ end
14
+ end
15
+
16
+ def configure_networks(networks)
17
+ # Remove previous Vagrant-managed network interfaces
18
+ vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf > /tmp/vagrant-network-interfaces")
19
+ vm.channel.sudo("cat /tmp/vagrant-network-interfaces > /etc/rc.conf")
20
+
21
+ # Configure the network interfaces
22
+ interfaces = Set.new
23
+ entries = []
24
+ networks.each do |network|
25
+ interfaces.add(network[:interface])
26
+ entries << TemplateRenderer.render("guests/arch/network_#{network[:type]}",
27
+ :options => network)
28
+ end
29
+
30
+ # Perform the careful dance necessary to reconfigure
31
+ # the network interfaces
32
+ temp = Tempfile.new("vagrant")
33
+ temp.write(entries.join("\n"))
34
+ temp.close
35
+
36
+ vm.channel.upload(temp.path, "/tmp/vagrant-network-entry")
37
+
38
+ # Reconfigure the network interfaces
39
+ vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/rc.conf")
40
+ vm.channel.sudo("/etc/rc.d/network restart")
41
+
42
+ interfaces.each do |interface|
43
+ vm.channel.sudo("dhcpcd -k eth#{interface} && dhcpcd eth#{interface} && sleep 3")
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
- module Systems
2
+ module Guest
3
3
  # The base class for a "system." A system represents an installed
4
4
  # operating system on a given box. There are some portions of
5
5
  # Vagrant which are fairly OS-specific (such as mounting shared
@@ -16,7 +16,7 @@ module Vagrant
16
16
  # changes will be noted on release notes.**
17
17
  class Base
18
18
  class BaseError < Errors::VagrantError
19
- error_namespace("vagrant.systems.base")
19
+ error_namespace("vagrant.guest.base")
20
20
  end
21
21
 
22
22
  include Vagrant::Util
@@ -47,38 +47,50 @@ module Vagrant
47
47
  #
48
48
  # If when this method returns, the machine's state isn't "powered_off,"
49
49
  # Vagrant will proceed to forcefully shut the machine down.
50
- def halt; end
50
+ def halt
51
+ raise BaseError, :_key => :unsupported_halt
52
+ end
51
53
 
52
- # Mounts a shared folder. This method is called by the shared
53
- # folder action with an open SSH session (passed in as `ssh`).
54
+ # Mounts a shared folder.
55
+ #
54
56
  # This method should create, mount, and properly set permissions
55
57
  # on the shared folder. This method should also properly
56
58
  # adhere to any configuration values such as `shared_folder_uid`
57
59
  # on `config.vm`.
58
60
  #
59
- # @param [Object] ssh The Net::SSH session.
60
61
  # @param [String] name The name of the shared folder.
61
62
  # @param [String] guestpath The path on the machine which the user
62
63
  # wants the folder mounted.
63
- def mount_shared_folder(ssh, name, guestpath, owner, group); end
64
+ # @param [Hash] options Additional options for the shared folder
65
+ # which can be honored.
66
+ def mount_shared_folder(name, guestpath, options)
67
+ raise BaseError, :_key => :unsupported_shared_folder
68
+ end
64
69
 
65
70
  # Mounts a shared folder via NFS. This assumes that the exports
66
71
  # via the host are already done.
67
- def mount_nfs(ip, folders); end
68
-
69
- # Prepares the system for host only networks. This is called
70
- # once prior to any `enable_host_only_network` calls.
71
- def prepare_host_only_network(net_options=nil)
72
- raise BaseError, :_key => :unsupported_host_only
72
+ def mount_nfs(ip, folders)
73
+ raise BaseError, :_key => :unsupported_nfs
73
74
  end
74
75
 
75
- # Setup the system by adding a new host only network. This
76
- # method should configure and bring up the interface for the
77
- # given options.
76
+ # Configures the given list of networks on the virtual machine.
78
77
  #
79
- # @param [Hash] net_options The options for the network.
80
- def enable_host_only_network(net_options); end
78
+ # The networks parameter will be an array of hashes where the hashes
79
+ # represent the configuration of a network interface. The structure
80
+ # of the hash will be roughly the following:
81
+ #
82
+ # {
83
+ # :type => :static,
84
+ # :ip => "33.33.33.10",
85
+ # :netmask => "255.255.255.0",
86
+ # :interface => 1
87
+ # }
88
+ #
89
+ def configure_networks(networks)
90
+ raise BaseError, :_key => :unsupported_configure_networks
91
+ end
81
92
 
93
+ # Called to change the hostname of the virtual machine.
82
94
  def change_host_name(name)
83
95
  raise BaseError, :_key => :unsupported_host_name
84
96
  end
@@ -0,0 +1,61 @@
1
+ require 'set'
2
+ require 'tempfile'
3
+
4
+ require 'vagrant/util/template_renderer'
5
+
6
+ module Vagrant
7
+ module Guest
8
+ class Debian < Linux
9
+ # Make the TemplateRenderer top-level
10
+ include Vagrant::Util
11
+
12
+ def configure_networks(networks)
13
+ # First, remove any previous network modifications
14
+ # from the interface file.
15
+ vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces")
16
+ vm.channel.sudo("su -c 'cat /tmp/vagrant-network-interfaces > /etc/network/interfaces'")
17
+
18
+ # Accumulate the configurations to add to the interfaces file as
19
+ # well as what interfaces we're actually configuring since we use that
20
+ # later.
21
+ interfaces = Set.new
22
+ entries = []
23
+ networks.each do |network|
24
+ interfaces.add(network[:interface])
25
+ entries << TemplateRenderer.render("guests/debian/network_#{network[:type]}",
26
+ :options => network)
27
+ end
28
+
29
+ # Perform the careful dance necessary to reconfigure
30
+ # the network interfaces
31
+ temp = Tempfile.new("vagrant")
32
+ temp.write(entries.join("\n"))
33
+ temp.close
34
+
35
+ vm.channel.upload(temp.path, "/tmp/vagrant-network-entry")
36
+
37
+ # Bring down all the interfaces we're reconfiguring. By bringing down
38
+ # each specifically, we avoid reconfiguring eth0 (the NAT interface) so
39
+ # SSH never dies.
40
+ interfaces.each do |interface|
41
+ vm.channel.sudo("/sbin/ifdown eth#{interface} 2> /dev/null")
42
+ end
43
+
44
+ vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/network/interfaces")
45
+
46
+ # Bring back up each network interface, reconfigured
47
+ interfaces.each do |interface|
48
+ vm.channel.sudo("/sbin/ifup eth#{interface}")
49
+ end
50
+ end
51
+
52
+ def change_host_name(name)
53
+ if !vm.channel.test?("hostname --fqdn | grep '^#{name}$' || hostname --short | grep '^#{name}$'")
54
+ vm.channel.sudo("sed -r -i 's/^(127[.]0[.]1[.]1[[:space:]]+).*$/\\1#{name} #{name.split('.')[0]}/' /etc/hosts")
55
+ vm.channel.sudo("sed -i 's/.*$/#{name.split('.')[0]}/' /etc/hostname")
56
+ vm.channel.sudo("hostname -F /etc/hostname")
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
- module Systems
2
+ module Guest
3
3
  # A general Vagrant system implementation for "freebsd".
4
4
  #
5
5
  # Contributed by Kenneth Vestergaard <kvs@binarysolutions.dk>
@@ -9,8 +9,6 @@ module Vagrant
9
9
  # generally, Vagrant tries to make almost every aspect of its execution
10
10
  # configurable, and this assists that goal.
11
11
  class FreeBSDConfig < Vagrant::Config::Base
12
- configures :freebsd
13
-
14
12
  attr_accessor :halt_timeout
15
13
  attr_accessor :halt_check_interval
16
14
 
@@ -22,24 +20,21 @@ module Vagrant
22
20
 
23
21
  # Here for whenever it may be used.
24
22
  class FreeBSDError < Errors::VagrantError
25
- error_namespace("vagrant.systems.freebsd")
23
+ error_namespace("vagrant.guest.freebsd")
26
24
  end
27
25
 
28
26
  def halt
29
- vm.env.ui.info I18n.t("vagrant.systems.freebsd.attempting_halt")
30
- vm.ssh.execute do |ssh|
31
- ssh.exec!("sudo shutdown -p now")
32
- end
27
+ vm.channel.sudo("shutdown -p now")
33
28
 
34
29
  # Wait until the VM's state is actually powered off. If this doesn't
35
30
  # occur within a reasonable amount of time (15 seconds by default),
36
31
  # then simply return and allow Vagrant to kill the machine.
37
32
  count = 0
38
- while vm.vm.state != :powered_off
33
+ while vm.state != :poweroff
39
34
  count += 1
40
35
 
41
- return if count >= vm.env.config.freebsd.halt_timeout
42
- sleep vm.env.config.freebsd.halt_check_interval
36
+ return if count >= vm.config.freebsd.halt_timeout
37
+ sleep vm.config.freebsd.halt_check_interval
43
38
  end
44
39
  end
45
40
 
@@ -48,15 +43,13 @@ module Vagrant
48
43
  # ssh.exec!("sudo mkdir -p #{guestpath}")
49
44
  # # Using a custom mount method here; could use improvement.
50
45
  # ssh.exec!("sudo mount -t vboxfs v-root #{guestpath}")
51
- # ssh.exec!("sudo chown #{vm.env.config.ssh.username} #{guestpath}")
46
+ # ssh.exec!("sudo chown #{vm.config.ssh.username} #{guestpath}")
52
47
  # end
53
48
 
54
49
  def mount_nfs(ip, folders)
55
50
  folders.each do |name, opts|
56
- vm.ssh.execute do |ssh|
57
- ssh.exec!("sudo mkdir -p #{opts[:guestpath]}")
58
- ssh.exec!("sudo mount #{ip}:#{opts[:hostpath]} #{opts[:guestpath]}")
59
- end
51
+ vm.channel.sudo("mkdir -p #{opts[:guestpath]}")
52
+ vm.channel.sudo("mount #{ip}:#{opts[:hostpath]} #{opts[:guestpath]}")
60
53
  end
61
54
  end
62
55
 
@@ -65,13 +58,13 @@ module Vagrant
65
58
  # interface file.
66
59
  vm.ssh.execute do |ssh|
67
60
  # Clear out any previous entries
68
- ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf > /tmp/rc.conf")
61
+ ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN-HOSTONLY/,/^#VAGRANT-END-HOSTONLY/ d' /etc/rc.conf > /tmp/rc.conf")
69
62
  ssh.exec!("sudo mv /tmp/rc.conf /etc/rc.conf")
70
63
  end
71
64
  end
72
65
 
73
66
  def enable_host_only_network(net_options)
74
- entry = "#VAGRANT-BEGIN\nifconfig_em#{net_options[:adapter]}=\"inet #{net_options[:ip]} netmask #{net_options[:netmask]}\"\n#VAGRANT-END\n"
67
+ entry = "#VAGRANT-BEGIN-HOSTONLY\nifconfig_em#{net_options[:adapter]}=\"inet #{net_options[:ip]} netmask #{net_options[:netmask]}\"\n#VAGRANT-END-HOSTONLY\n"
75
68
  vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
76
69
 
77
70
  vm.ssh.execute do |ssh|
@@ -0,0 +1,32 @@
1
+ require 'tempfile'
2
+
3
+ module Vagrant
4
+ module Guest
5
+ class Gentoo < Linux
6
+ def configure_networks(networks)
7
+ # Remove any previous host only network additions to the interface file
8
+ vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
9
+ vm.channel.sudo("cat /tmp/vagrant-network-interfaces > /etc/conf.d/net")
10
+
11
+ # Configure each network interface
12
+ networks.each do |network|
13
+ entry = TemplateRenderer.render("guests/gentoo/network_#{network[:type]}",
14
+ :options => network)
15
+
16
+ # Upload the entry to a temporary location
17
+ temp = Tempfile.new("vagrant")
18
+ temp.write(entry)
19
+ temp.close
20
+
21
+ vm.channel.upload(temp.path, "/tmp/vagrant-network-entry")
22
+
23
+ # Configure the interface
24
+ vm.channel.sudo("ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{network[:interface]}")
25
+ vm.channel.sudo("/etc/init.d/net.eth#{network[:interface]} stop 2> /dev/null")
26
+ vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/conf.d/net")
27
+ vm.channel.sudo("/etc/init.d/net.eth#{network[:interface]} start")
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,13 +1,11 @@
1
1
  module Vagrant
2
- module Systems
3
- class Linux < Vagrant::Systems::Base
2
+ module Guest
3
+ class Linux < Vagrant::Guest::Base
4
4
  # A custom config class which will be made accessible via `config.linux`
5
5
  # This is not necessary for all system implementers, of course. However,
6
6
  # generally, Vagrant tries to make almost every aspect of its execution
7
7
  # configurable, and this assists that goal.
8
8
  class LinuxConfig < Vagrant::Config::Base
9
- configures :linux
10
-
11
9
  attr_accessor :halt_timeout
12
10
  attr_accessor :halt_check_interval
13
11
 
@@ -0,0 +1,9 @@
1
+ module Vagrant
2
+ module Guest
3
+ class Linux < Vagrant::Guest::Base
4
+ class LinuxError < Errors::VagrantError
5
+ error_namespace("vagrant.guest.linux")
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,78 @@
1
+ require 'vagrant/guest/linux/error'
2
+ require 'vagrant/guest/linux/config'
3
+
4
+ module Vagrant
5
+ module Guest
6
+ class Linux < Base
7
+ def distro_dispatch
8
+ if @vm.channel.test("cat /etc/debian_version")
9
+ return :debian if @vm.channel.test("cat /proc/version | grep 'Debian'")
10
+ return :ubuntu if @vm.channel.test("cat /proc/version | grep 'Ubuntu'")
11
+ end
12
+
13
+ return :gentoo if @vm.channel.test("cat /etc/gentoo-release")
14
+ return :redhat if @vm.channel.test("cat /etc/redhat-release")
15
+ return :suse if @vm.channel.test("cat /etc/SuSE-release")
16
+ return :arch if @vm.channel.test("cat /etc/arch-release")
17
+
18
+ # Can't detect the distro, assume vanilla linux
19
+ nil
20
+ end
21
+
22
+ def halt
23
+ vm.channel.sudo("shutdown -h now")
24
+
25
+ # Wait until the VM's state is actually powered off. If this doesn't
26
+ # occur within a reasonable amount of time (15 seconds by default),
27
+ # then simply return and allow Vagrant to kill the machine.
28
+ count = 0
29
+ while vm.state != :poweroff
30
+ count += 1
31
+
32
+ return if count >= vm.config.linux.halt_timeout
33
+ sleep vm.config.linux.halt_check_interval
34
+ end
35
+ end
36
+
37
+ def mount_shared_folder(name, guestpath, options)
38
+ @vm.channel.sudo("mkdir -p #{guestpath}")
39
+ mount_folder(name, guestpath, options)
40
+ @vm.channel.sudo("chown `id -u #{options[:owner]}`:`id -g #{options[:group]}` #{guestpath}")
41
+ end
42
+
43
+ def mount_nfs(ip, folders)
44
+ # TODO: Maybe check for nfs support on the guest, since its often
45
+ # not installed by default
46
+ folders.each do |name, opts|
47
+ vm.channel.sudo("mkdir -p #{opts[:guestpath]}")
48
+ vm.channel.sudo("mount #{ip}:'#{opts[:hostpath]}' #{opts[:guestpath]}",
49
+ :error_class => LinuxError,
50
+ :error_key => :mount_nfs_fail)
51
+ end
52
+ end
53
+
54
+ #-------------------------------------------------------------------
55
+ # "Private" methods which assist above methods
56
+ #-------------------------------------------------------------------
57
+ def mount_folder(name, guestpath, options)
58
+ # Determine the permission string to attach to the mount command
59
+ mount_options = "-o uid=`id -u #{options[:owner]}`,gid=`id -g #{options[:group]}`"
60
+ mount_options += ",#{options[:extra]}" if options[:extra]
61
+
62
+ attempts = 0
63
+ while true
64
+ success = true
65
+ @vm.channel.sudo("mount -t vboxsf #{mount_options} #{name} #{guestpath}") do |type, data|
66
+ success = false if type == :stderr && data =~ /No such device/i
67
+ end
68
+
69
+ break if success
70
+
71
+ attempts += 1
72
+ raise LinuxError, :mount_fail if attempts >= 10
73
+ sleep 5
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,66 @@
1
+ require 'set'
2
+ require 'tempfile'
3
+
4
+ require 'vagrant/util/template_renderer'
5
+
6
+ module Vagrant
7
+ module Guest
8
+ class Redhat < Linux
9
+ # Make the TemplateRenderer top-level
10
+ include Vagrant::Util
11
+
12
+ def configure_networks(networks)
13
+ # Accumulate the configurations to add to the interfaces file as
14
+ # well as what interfaces we're actually configuring since we use that
15
+ # later.
16
+ interfaces = Set.new
17
+ networks.each do |network|
18
+ interfaces.add(network[:interface])
19
+
20
+ # Remove any previous vagrant configuration in this network interface's
21
+ # configuration files.
22
+ vm.channel.sudo("touch #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
23
+ vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-eth#{network[:interface]} > /tmp/vagrant-ifcfg-eth#{network[:interface]}")
24
+ vm.channel.sudo("cat /tmp/vagrant-ifcfg-eth#{network[:interface]} > #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
25
+
26
+ # Render and upload the network entry file to a deterministic
27
+ # temporary location.
28
+ entry = TemplateRenderer.render("guests/redhat/network_#{network[:type]}",
29
+ :options => network)
30
+
31
+ temp = Tempfile.new("vagrant")
32
+ temp.write(entry)
33
+ temp.close
34
+
35
+ vm.channel.upload(temp.path, "/tmp/vagrant-network-entry_#{network[:interface]}")
36
+ end
37
+
38
+ # Bring down all the interfaces we're reconfiguring. By bringing down
39
+ # each specifically, we avoid reconfiguring eth0 (the NAT interface) so
40
+ # SSH never dies.
41
+ interfaces.each do |interface|
42
+ vm.channel.sudo("/sbin/ifdown eth#{interface} 2> /dev/null")
43
+ vm.channel.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-eth#{interface}")
44
+ vm.channel.sudo("/sbin/ifup eth#{interface}")
45
+ end
46
+ end
47
+
48
+ # The path to the directory with the network configuration scripts.
49
+ # This is pulled out into its own directory since there are other
50
+ # operating systems (SuSE) which behave similarly but with a different
51
+ # path to the network scripts.
52
+ def network_scripts_dir
53
+ '/etc/sysconfig/network-scripts'
54
+ end
55
+
56
+ def change_host_name(name)
57
+ # Only do this if the hostname is not already set
58
+ if !vm.channel.test("sudo hostname | grep '#{name}'")
59
+ vm.channel.sudo("sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/sysconfig/network")
60
+ vm.channel.sudo("hostname #{name}")
61
+ vm.channel.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end