vagrant-unbundled 1.9.1.1 → 1.9.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/CHANGELOG.md +126 -0
  4. data/LICENSE +1 -1
  5. data/README.md +1 -1
  6. data/bin/vagrant +11 -0
  7. data/contrib/bash/completion.sh +9 -9
  8. data/lib/vagrant.rb +4 -2
  9. data/lib/vagrant/action/builtin/box_add.rb +13 -8
  10. data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +67 -14
  11. data/lib/vagrant/action/builtin/provision.rb +10 -5
  12. data/lib/vagrant/action/general/package_setup_files.rb +51 -0
  13. data/lib/vagrant/action/general/package_setup_folders.rb +37 -0
  14. data/lib/vagrant/batch_action.rb +4 -2
  15. data/lib/vagrant/box_collection.rb +17 -5
  16. data/lib/vagrant/bundler.rb +110 -12
  17. data/lib/vagrant/cli.rb +1 -1
  18. data/lib/vagrant/environment.rb +4 -4
  19. data/lib/vagrant/errors.rb +32 -0
  20. data/lib/vagrant/shared_helpers.rb +14 -0
  21. data/lib/vagrant/ui.rb +3 -3
  22. data/lib/vagrant/util.rb +7 -1
  23. data/lib/vagrant/util/command_deprecation.rb +56 -0
  24. data/lib/vagrant/util/credential_scrubber.rb +29 -0
  25. data/lib/vagrant/util/guest_inspection.rb +47 -0
  26. data/lib/vagrant/util/platform.rb +217 -27
  27. data/lib/vagrant/util/powershell.rb +25 -0
  28. data/lib/vagrant/util/safe_exec.rb +9 -1
  29. data/lib/vagrant/util/ssh.rb +1 -1
  30. data/lib/vagrant/util/subprocess.rb +21 -2
  31. data/lib/vagrant/util/which.rb +6 -4
  32. data/plugins/commands/box/command/list.rb +1 -1
  33. data/plugins/commands/package/command.rb +3 -2
  34. data/plugins/commands/plugin/action.rb +2 -1
  35. data/plugins/commands/plugin/action/expunge_plugins.rb +20 -5
  36. data/plugins/commands/plugin/action/install_gem.rb +0 -8
  37. data/plugins/commands/plugin/command/expunge.rb +18 -5
  38. data/plugins/commands/plugin/command/mixin_install_opts.rb +1 -4
  39. data/plugins/commands/plugin/gem_helper.rb +5 -1
  40. data/plugins/commands/up/command.rb +1 -1
  41. data/plugins/commands/validate/command.rb +31 -0
  42. data/plugins/commands/validate/plugin.rb +17 -0
  43. data/plugins/communicators/ssh/communicator.rb +50 -25
  44. data/plugins/communicators/winrm/communicator.rb +8 -54
  45. data/plugins/communicators/winrm/config.rb +3 -0
  46. data/plugins/communicators/winrm/helper.rb +1 -1
  47. data/plugins/communicators/winrm/shell.rb +38 -32
  48. data/plugins/communicators/winssh/communicator.rb +161 -0
  49. data/plugins/communicators/winssh/config.rb +30 -0
  50. data/plugins/communicators/winssh/plugin.rb +21 -0
  51. data/plugins/guests/arch/cap/change_host_name.rb +0 -3
  52. data/plugins/guests/arch/cap/configure_networks.rb +1 -1
  53. data/plugins/guests/atomic/cap/change_host_name.rb +0 -3
  54. data/plugins/guests/darwin/cap/change_host_name.rb +0 -4
  55. data/plugins/guests/debian/cap/change_host_name.rb +0 -3
  56. data/plugins/guests/debian/cap/configure_networks.rb +2 -1
  57. data/plugins/guests/elementary/guest.rb +10 -0
  58. data/plugins/guests/elementary/plugin.rb +15 -0
  59. data/plugins/guests/esxi/cap/public_key.rb +63 -0
  60. data/plugins/guests/esxi/plugin.rb +11 -0
  61. data/plugins/guests/freebsd/cap/change_host_name.rb +0 -4
  62. data/plugins/guests/gentoo/cap/change_host_name.rb +7 -5
  63. data/plugins/guests/gentoo/cap/configure_networks.rb +57 -21
  64. data/plugins/guests/linux/cap/mount_smb_shared_folder.rb +20 -53
  65. data/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +10 -58
  66. data/plugins/guests/linux/cap/network_interfaces.rb +8 -1
  67. data/plugins/guests/linux/cap/nfs.rb +5 -14
  68. data/plugins/guests/linux/guest.rb +3 -3
  69. data/plugins/guests/omnios/cap/change_host_name.rb +0 -3
  70. data/plugins/guests/openbsd/cap/change_host_name.rb +0 -4
  71. data/plugins/guests/photon/cap/change_host_name.rb +0 -3
  72. data/plugins/guests/pld/cap/change_host_name.rb +0 -3
  73. data/plugins/guests/redhat/cap/change_host_name.rb +2 -9
  74. data/plugins/guests/redhat/cap/configure_networks.rb +43 -21
  75. data/plugins/guests/slackware/cap/change_host_name.rb +0 -3
  76. data/plugins/guests/suse/cap/change_host_name.rb +0 -3
  77. data/plugins/guests/tinycore/cap/mount_nfs.rb +3 -8
  78. data/plugins/guests/windows/cap/configure_networks.rb +0 -4
  79. data/plugins/guests/windows/cap/mount_shared_folder.rb +13 -1
  80. data/plugins/guests/windows/scripts/mount_volume.ps1.erb +1 -1
  81. data/plugins/hosts/windows/cap/ps.rb +6 -1
  82. data/plugins/kernel_v2/config/vm.rb +6 -4
  83. data/plugins/providers/docker/action.rb +4 -7
  84. data/plugins/providers/docker/action/build.rb +1 -1
  85. data/plugins/providers/docker/action/create.rb +3 -0
  86. data/plugins/providers/docker/config.rb +27 -1
  87. data/plugins/providers/docker/driver.rb +15 -2
  88. data/plugins/providers/docker/driver/compose.rb +287 -0
  89. data/plugins/providers/docker/errors.rb +16 -0
  90. data/plugins/providers/docker/provider.rb +25 -10
  91. data/plugins/providers/hyperv/action.rb +33 -8
  92. data/plugins/providers/hyperv/action/export.rb +39 -0
  93. data/plugins/providers/hyperv/action/import.rb +23 -4
  94. data/plugins/providers/hyperv/action/package.rb +16 -0
  95. data/plugins/providers/hyperv/action/package_metadata_json.rb +34 -0
  96. data/plugins/providers/hyperv/action/package_setup_files.rb +16 -0
  97. data/plugins/providers/hyperv/action/package_setup_folders.rb +18 -0
  98. data/plugins/providers/hyperv/action/package_vagrantfile.rb +34 -0
  99. data/plugins/providers/hyperv/config.rb +20 -4
  100. data/plugins/providers/hyperv/driver.rb +12 -0
  101. data/plugins/providers/hyperv/scripts/export_vm.ps1 +15 -0
  102. data/plugins/providers/hyperv/scripts/get_network_mac.ps1 +28 -0
  103. data/plugins/providers/hyperv/scripts/has_vmcx_support.ps1 +11 -0
  104. data/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 +10 -4
  105. data/plugins/providers/hyperv/scripts/import_vm_xml.ps1 +9 -3
  106. data/plugins/providers/hyperv/scripts/set_vm_integration_services.ps1 +37 -0
  107. data/plugins/providers/virtualbox/action/package_setup_files.rb +7 -42
  108. data/plugins/providers/virtualbox/action/package_setup_folders.rb +6 -26
  109. data/plugins/providers/virtualbox/driver/base.rb +10 -0
  110. data/plugins/providers/virtualbox/driver/version_5_0.rb +11 -11
  111. data/plugins/providers/virtualbox/driver/version_5_1.rb +3 -721
  112. data/plugins/providers/virtualbox/provider.rb +9 -5
  113. data/plugins/providers/virtualbox/synced_folder.rb +1 -1
  114. data/plugins/providers/virtualbox/util/compile_forwarded_ports.rb +3 -1
  115. data/plugins/provisioners/ansible/cap/guest/arch/ansible_install.rb +2 -2
  116. data/plugins/provisioners/ansible/cap/guest/debian/ansible_install.rb +8 -8
  117. data/plugins/provisioners/ansible/cap/guest/fedora/ansible_install.rb +9 -5
  118. data/plugins/provisioners/ansible/cap/guest/freebsd/ansible_install.rb +1 -1
  119. data/plugins/provisioners/ansible/cap/guest/pip/pip.rb +5 -3
  120. data/plugins/provisioners/ansible/cap/guest/redhat/ansible_install.rb +7 -3
  121. data/plugins/provisioners/ansible/cap/guest/suse/ansible_install.rb +1 -1
  122. data/plugins/provisioners/ansible/cap/guest/ubuntu/ansible_install.rb +3 -3
  123. data/plugins/provisioners/ansible/config/guest.rb +7 -1
  124. data/plugins/provisioners/ansible/provisioner/guest.rb +1 -1
  125. data/plugins/provisioners/chef/cap/freebsd/chef_install.rb +18 -0
  126. data/plugins/provisioners/chef/cap/freebsd/chef_installed.rb +22 -0
  127. data/plugins/provisioners/chef/plugin.rb +10 -0
  128. data/plugins/provisioners/docker/cap/linux/docker_installed.rb +1 -0
  129. data/plugins/provisioners/salt/bootstrap-salt.ps1 +4 -4
  130. data/plugins/provisioners/shell/config.rb +2 -2
  131. data/plugins/provisioners/shell/provisioner.rb +66 -4
  132. data/plugins/pushes/atlas/push.rb +6 -0
  133. data/plugins/pushes/local-exec/config.rb +2 -2
  134. data/plugins/synced_folders/unix_mount_helpers.rb +105 -0
  135. data/templates/commands/init/Vagrantfile.erb +6 -0
  136. data/templates/commands/init/Vagrantfile.min.erb +3 -0
  137. data/templates/guests/debian/network_dhcp.erb +2 -2
  138. data/templates/guests/gentoo/network_systemd.erb +16 -0
  139. data/templates/guests/redhat/network_dhcp.erb +1 -0
  140. data/templates/guests/redhat/network_static.erb +1 -1
  141. data/templates/guests/redhat/network_static6.erb +1 -1
  142. data/templates/locales/en.yml +72 -3
  143. data/templates/locales/providers_docker.yml +15 -0
  144. data/test/acceptance/provider-virtualbox/linked_clone_spec.rb +1 -1
  145. data/test/unit/plugins/commands/init/command_test.rb +7 -0
  146. data/test/unit/plugins/commands/up/command_test.rb +65 -0
  147. data/test/unit/plugins/commands/validate/command_test.rb +52 -0
  148. data/test/unit/plugins/communicators/ssh/communicator_test.rb +58 -2
  149. data/test/unit/plugins/communicators/winrm/communicator_test.rb +14 -26
  150. data/test/unit/plugins/communicators/winrm/helper_test.rb +12 -0
  151. data/test/unit/plugins/communicators/winrm/shell_test.rb +54 -15
  152. data/test/unit/plugins/communicators/winssh/communicator_test.rb +525 -0
  153. data/test/unit/plugins/guests/arch/cap/configure_networks_test.rb +5 -0
  154. data/test/unit/plugins/guests/esxi/cap/public_key_test.rb +48 -0
  155. data/test/unit/plugins/guests/linux/cap/mount_nfs_test.rb +1 -1
  156. data/test/unit/plugins/guests/linux/cap/mount_smb_shared_folder.rb +71 -0
  157. data/test/unit/plugins/guests/linux/cap/mount_virtual_box_shared_folder_test.rb +43 -0
  158. data/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb +10 -10
  159. data/test/unit/plugins/guests/redhat/cap/configure_networks_test.rb +132 -12
  160. data/test/unit/plugins/guests/windows/cap/mount_shared_folder_test.rb +23 -0
  161. data/test/unit/plugins/providers/docker/driver_compose_test.rb +268 -0
  162. data/test/unit/plugins/provisioners/ansible/config/guest_test.rb +9 -0
  163. data/test/unit/plugins/provisioners/ansible/provisioner_test.rb +2 -2
  164. data/test/unit/plugins/pushes/atlas/push_test.rb +151 -150
  165. data/test/unit/templates/guests/debian/network_dhcp_test.rb +1 -0
  166. data/test/unit/templates/guests/gentoo/systemd_network_test.rb +73 -0
  167. data/test/unit/templates/guests/redhat/network_dhcp_test.rb +18 -0
  168. data/test/unit/vagrant/action/builtin/box_add_test.rb +27 -0
  169. data/test/unit/vagrant/action/builtin/handle_forwarded_port_collisions_test.rb +170 -0
  170. data/test/unit/vagrant/action/builtin/provision_test.rb +208 -0
  171. data/test/unit/vagrant/box_collection_test.rb +98 -0
  172. data/test/unit/vagrant/environment_test.rb +17 -0
  173. data/test/unit/vagrant/shared_helpers_test.rb +12 -0
  174. data/test/unit/vagrant/util/command_deprecation_test.rb +106 -0
  175. data/test/unit/vagrant/util/env_test.rb +43 -0
  176. data/test/unit/vagrant/util/platform_test.rb +8 -0
  177. data/test/unit/vagrant/util/subprocess_test.rb +61 -0
  178. data/test/vagrant-spec/Vagrantfile.spec +78 -0
  179. data/test/vagrant-spec/boxes/.keep +0 -0
  180. data/test/vagrant-spec/configs/vagrant-spec.config.virtualbox.rb +10 -0
  181. data/test/vagrant-spec/scripts/centos-run.virtualbox.sh +8 -0
  182. data/test/vagrant-spec/scripts/centos-setup.virtualbox.sh +14 -0
  183. data/test/vagrant-spec/scripts/ubuntu-run.virtualbox.sh +8 -0
  184. data/test/vagrant-spec/scripts/ubuntu-setup.virtualbox.sh +12 -0
  185. data/vagrant.gemspec +6 -11
  186. data/version.txt +1 -1
  187. metadata +1694 -1835
  188. data/plugins/communicators/winrm/scripts/elevated_shell.ps1.erb +0 -101
@@ -9,6 +9,22 @@ module VagrantPlugins
9
9
  error_key(:communicator_non_docker)
10
10
  end
11
11
 
12
+ class ComposeLockTimeoutError < DockerError
13
+ error_key(:compose_lock_timeout)
14
+ end
15
+
16
+ class ContainerNotRunningError < DockerError
17
+ error_key(:not_running)
18
+ end
19
+
20
+ class ContainerNotCreatedError < DockerError
21
+ error_key(:not_created)
22
+ end
23
+
24
+ class DockerComposeNotInstalledError < DockerError
25
+ error_key(:docker_compose_not_installed)
26
+ end
27
+
12
28
  class ExecuteError < DockerError
13
29
  error_key(:execute_error)
14
30
  end
@@ -31,11 +31,13 @@ module VagrantPlugins
31
31
 
32
32
  # Returns the driver instance for this provider.
33
33
  def driver
34
- return @driver if @driver
35
- @driver = Driver.new
36
-
37
- # If we are running on a host machine, then we set the executor
38
- # to execute remotely.
34
+ if !@driver
35
+ if @machine.provider_config.compose
36
+ @driver = Driver::Compose.new(@machine)
37
+ else
38
+ @driver = Driver.new
39
+ end
40
+ end
39
41
  if host_vm?
40
42
  @driver.executor = Executor::Vagrant.new(host_vm)
41
43
  end
@@ -136,16 +138,29 @@ module VagrantPlugins
136
138
  # If the container isn't running, we can't SSH into it
137
139
  return nil if state.id != :running
138
140
 
139
- network = driver.inspect_container(@machine.id)['NetworkSettings']
140
- ip = network['IPAddress']
141
+ port_name = "#{@machine.config.ssh.guest_port}/tcp"
142
+ network = driver.inspect_container(@machine.id)['NetworkSettings']
143
+
144
+ if network["Ports"][port_name].respond_to?(:first)
145
+ port_info = network["Ports"][port_name].first
146
+ else
147
+ ip = network["IpAddress"]
148
+ port = @machine.config.ssh.guest_port
149
+ if !ip.to_s.empty?
150
+ port_info = {
151
+ "HostIp" => ip,
152
+ "HostPort" => port
153
+ }
154
+ end
155
+ end
141
156
 
142
157
  # If we were not able to identify the container's IP, we return nil
143
158
  # here and we let Vagrant core deal with it ;)
144
- return nil if !ip
159
+ return nil if port_info.nil? || port_info.empty?
145
160
 
146
161
  {
147
- host: ip,
148
- port: @machine.config.ssh.guest_port
162
+ host: port_info['HostIp'],
163
+ port: port_info['HostPort']
149
164
  }
150
165
  end
151
166
 
@@ -64,6 +64,28 @@ module VagrantPlugins
64
64
  end
65
65
  end
66
66
 
67
+ # This action packages the virtual machine into a single box file.
68
+ def self.action_package
69
+ Vagrant::Action::Builder.new.tap do |b|
70
+ b.use CheckEnabled
71
+ b.use Call, IsState, :not_created do |env1, b2|
72
+ if env1[:result]
73
+ b2.use Message, I18n.t("vagrant_hyperv.message_not_created")
74
+ next
75
+ end
76
+
77
+ b2.use PackageSetupFolders
78
+ b2.use PackageSetupFiles
79
+ b2.use action_halt
80
+ b2.use SyncedFolderCleanup
81
+ b2.use Package
82
+ b2.use PackageVagrantfile
83
+ b2.use PackageMetadataJson
84
+ b2.use Export
85
+ end
86
+ end
87
+ end
88
+
67
89
  def self.action_provision
68
90
  Vagrant::Action::Builder.new.tap do |b|
69
91
  b.use ConfigValidate
@@ -156,14 +178,12 @@ module VagrantPlugins
156
178
  b.use ConfigValidate
157
179
  b.use Call, IsState, :not_created do |env, b2|
158
180
  if env[:result]
159
- b2.use Message, I18n.t("vagrant_hyperv.message_not_created")
160
- next
181
+ raise Vagrant::Errors::VMNotCreatedError
161
182
  end
162
183
 
163
184
  b2.use Call, IsState, :running do |env1, b3|
164
185
  if !env1[:result]
165
- b3.use Message, I18n.t("vagrant_hyperv.message_not_running")
166
- next
186
+ raise Vagrant::Errors::VMNotRunningError
167
187
  end
168
188
 
169
189
  b3.use SSHExec
@@ -177,14 +197,12 @@ module VagrantPlugins
177
197
  b.use ConfigValidate
178
198
  b.use Call, IsState, :not_created do |env, b2|
179
199
  if env[:result]
180
- b2.use Message, I18n.t("vagrant_hyperv.message_not_created")
181
- next
200
+ raise Vagrant::Errors::VMNotCreatedError
182
201
  end
183
202
 
184
203
  b2.use Call, IsState, :running do |env1, b3|
185
204
  if !env1[:result]
186
- b3.use Message, I18n.t("vagrant_hyperv.message_not_running")
187
- next
205
+ raise Vagrant::Errors::VMNotRunningError
188
206
  end
189
207
 
190
208
  b3.use SSHRun
@@ -261,9 +279,16 @@ module VagrantPlugins
261
279
 
262
280
  # The autoload farm
263
281
  action_root = Pathname.new(File.expand_path("../action", __FILE__))
282
+ autoload :PackageSetupFolders, action_root.join("package_setup_folders")
283
+ autoload :PackageSetupFiles, action_root.join("package_setup_files")
284
+ autoload :PackageVagrantfile, action_root.join("package_vagrantfile")
285
+ autoload :PackageMetadataJson, action_root.join("package_metadata_json")
286
+ autoload :Export, action_root.join("export")
287
+
264
288
  autoload :CheckEnabled, action_root.join("check_enabled")
265
289
  autoload :DeleteVM, action_root.join("delete_vm")
266
290
  autoload :Import, action_root.join("import")
291
+ autoload :Package, action_root.join("package")
267
292
  autoload :IsWindows, action_root.join("is_windows")
268
293
  autoload :ReadState, action_root.join("read_state")
269
294
  autoload :ResumeVM, action_root.join("resume_vm")
@@ -0,0 +1,39 @@
1
+ require "fileutils"
2
+
3
+ module VagrantPlugins
4
+ module HyperV
5
+ module Action
6
+ class Export
7
+ def initialize(app, env)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ @env = env
13
+
14
+ @env[:ui].info @env[:machine].state.id.to_s
15
+
16
+ raise Vagrant::Errors::VMPowerOffToPackage if
17
+ @env[:machine].state.id != :off
18
+
19
+ export
20
+
21
+ @app.call(env)
22
+ end
23
+
24
+ def export
25
+ @env[:ui].info I18n.t("vagrant.actions.vm.export.exporting")
26
+ @env[:machine].provider.driver.export(@env["export.temp_dir"]) do |progress|
27
+ @env[:ui].clear_line
28
+ @env[:ui].report_progress(progress.percent, 100, false)
29
+ end
30
+
31
+ # Clear the line a final time so the next data can appear
32
+ # alone on the line.
33
+ @env[:ui].clear_line
34
+ end
35
+
36
+ end
37
+ end
38
+ end
39
+ end
@@ -21,10 +21,13 @@ module VagrantPlugins
21
21
  differencing_disk = env[:machine].provider_config.differencing_disk
22
22
  auto_start_action = env[:machine].provider_config.auto_start_action
23
23
  auto_stop_action = env[:machine].provider_config.auto_stop_action
24
+ enable_virtualization_extensions = env[:machine].provider_config.enable_virtualization_extensions
25
+ vm_integration_services = env[:machine].provider_config.vm_integration_services
24
26
 
25
27
  env[:ui].output("Configured Dynamic memory allocation, maxmemory is #{maxmemory}") if maxmemory
26
28
  env[:ui].output("Configured startup memory is #{memory}") if memory
27
29
  env[:ui].output("Configured cpus number is #{cpus}") if cpus
30
+ env[:ui].output("Configured enable virtualization extensions is #{enable_virtualization_extensions}") if enable_virtualization_extensions
28
31
  env[:ui].output("Configured vmname is #{vmname}") if vmname
29
32
  env[:ui].output("Configured differencing disk instead of cloning") if differencing_disk
30
33
  env[:ui].output("Configured automatic start action is #{auto_start_action}") if auto_start_action
@@ -38,18 +41,18 @@ module VagrantPlugins
38
41
  config_type = nil
39
42
  vm_dir.each_child do |f|
40
43
  if f.extname.downcase == '.xml'
44
+ @logger.debug("Found XML config...")
41
45
  config_path = f
42
46
  config_type = 'xml'
43
47
  break
44
48
  end
45
49
  end
46
50
 
47
- # Only check for .vmcx if there is no XML found to not
48
- # risk breaking older vagrant boxes that added an XML
49
- # file manually
50
- if config_type == nil
51
+ vmcx_support = env[:machine].provider.driver.execute("has_vmcx_support.ps1", {})
52
+ if vmcx_support
51
53
  vm_dir.each_child do |f|
52
54
  if f.extname.downcase == '.vmcx'
55
+ @logger.debug("Found VMCX config and support...")
53
56
  config_path = f
54
57
  config_type = 'vmcx'
55
58
  break
@@ -145,9 +148,25 @@ module VagrantPlugins
145
148
  options[:auto_start_action] = auto_start_action if auto_start_action
146
149
  options[:auto_stop_action] = auto_stop_action if auto_stop_action
147
150
  options[:differencing_disk] = differencing_disk if differencing_disk
151
+ options[:enable_virtualization_extensions] = "$True" if enable_virtualization_extensions and enable_virtualization_extensions == true
148
152
 
149
153
  env[:ui].detail("Creating and registering the VM...")
150
154
  server = env[:machine].provider.driver.import(options)
155
+
156
+ env[:ui].detail("Setting VM Integration Services")
157
+ vm_integration_services.each do |key, value|
158
+ state = false
159
+ if value === true
160
+ state = "enabled"
161
+ elsif value === false
162
+ state = "disabled"
163
+ end
164
+ env[:ui].output("#{key} is #{state}") if state
165
+ end
166
+
167
+ vm_integration_services[:VmId] = server["id"]
168
+ env[:machine].provider.driver.set_vm_integration_services(vm_integration_services)
169
+
151
170
  env[:ui].detail("Successfully imported a VM with name: #{server['name']}")
152
171
  env[:machine].id = server["id"]
153
172
  @app.call(env)
@@ -0,0 +1,16 @@
1
+ require_relative "../../../../lib/vagrant/action/general/package"
2
+
3
+ module VagrantPlugins
4
+ module HyperV
5
+ module Action
6
+ class Package < Vagrant::Action::General::Package
7
+ # Doing this so that we can test that the parent is properly
8
+ # called in the unit tests.
9
+ alias_method :general_call, :call
10
+ def call(env)
11
+ general_call(env)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,34 @@
1
+ require "json"
2
+
3
+ #require 'vagrant/util/template_renderer'
4
+
5
+ module VagrantPlugins
6
+ module HyperV
7
+ module Action
8
+ class PackageMetadataJson
9
+ # For TemplateRenderer
10
+ include Vagrant::Util
11
+
12
+ def initialize(app, env)
13
+ @app = app
14
+ end
15
+
16
+ def call(env)
17
+ @env = env
18
+ create_metadata
19
+ @app.call(env)
20
+ end
21
+
22
+ # This method creates a metadata.json file to tell vagrant this is a
23
+ # Hyper V box
24
+ def create_metadata
25
+ File.open(File.join(@env["export.temp_dir"], "metadata.json"), "w") do |f|
26
+ f.write(JSON.generate({
27
+ provider: "hyperv"
28
+ }))
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,16 @@
1
+ require_relative "../../../../lib/vagrant/action/general/package_setup_files"
2
+
3
+ module VagrantPlugins
4
+ module HyperV
5
+ module Action
6
+ class PackageSetupFiles < Vagrant::Action::General::PackageSetupFiles
7
+ # Doing this so that we can test that the parent is properly
8
+ # called in the unit tests.
9
+ alias_method :general_call, :call
10
+ def call(env)
11
+ general_call(env)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ require "fileutils"
2
+
3
+ require_relative "../../../../lib/vagrant/action/general/package_setup_folders"
4
+
5
+ module VagrantPlugins
6
+ module HyperV
7
+ module Action
8
+ class PackageSetupFolders < Vagrant::Action::General::PackageSetupFolders
9
+ # Doing this so that we can test that the parent is properly
10
+ # called in the unit tests.
11
+ alias_method :general_call, :call
12
+ def call(env)
13
+ general_call(env)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,34 @@
1
+ require 'vagrant/util/template_renderer'
2
+
3
+ module VagrantPlugins
4
+ module HyperV
5
+ module Action
6
+ class PackageVagrantfile
7
+ # For TemplateRenderer
8
+ include Vagrant::Util
9
+
10
+ def initialize(app, env)
11
+ @app = app
12
+ end
13
+
14
+ def call(env)
15
+ @env = env
16
+ create_vagrantfile
17
+ @app.call(env)
18
+ end
19
+
20
+ # This method creates the auto-generated Vagrantfile at the root of the
21
+ # box. This Vagrantfile contains the MAC address so that the user doesn't
22
+ # have to worry about it.
23
+ def create_vagrantfile
24
+ File.open(File.join(@env["export.temp_dir"], "Vagrantfile"), "w") do |f|
25
+ mac_address = @env[:machine].provider.driver.read_mac_address
26
+ f.write(TemplateRenderer.render("package_Vagrantfile", {
27
+ base_mac: mac_address["mac"]
28
+ }))
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -3,7 +3,6 @@ require "vagrant"
3
3
  module VagrantPlugins
4
4
  module HyperV
5
5
  class Config < Vagrant.plugin("2", :config)
6
-
7
6
  attr_accessor :ip_address_timeout # Time to wait for an IP address when booting, in seconds @return [Integer]
8
7
  attr_accessor :memory # Memory size in mb @return [Integer]
9
8
  attr_accessor :maxmemory # Maximal memory size in mb enables dynamical memory allocation @return [Integer]
@@ -14,6 +13,8 @@ module VagrantPlugins
14
13
  attr_accessor :differencing_disk # Create differencing disk instead of cloning whole VHD [Boolean]
15
14
  attr_accessor :auto_start_action #action on automatic start of VM. Values: Nothing, StartIfRunning, Start
16
15
  attr_accessor :auto_stop_action #action on automatic stop of VM. Values: ShutDown, TurnOff, Save
16
+ attr_accessor :enable_virtualization_extensions # Enable virtualization extensions (nested virtualization). Values: true, false
17
+ attr_accessor :vm_integration_services # Options for VMServiceIntegration [Hash]
17
18
 
18
19
  def initialize
19
20
  @ip_address_timeout = UNSET_VALUE
@@ -21,11 +22,20 @@ module VagrantPlugins
21
22
  @maxmemory = UNSET_VALUE
22
23
  @cpus = UNSET_VALUE
23
24
  @vmname = UNSET_VALUE
24
- @vlan_id = UNSET_VALUE
25
- @mac = UNSET_VALUE
25
+ @vlan_id = UNSET_VALUE
26
+ @mac = UNSET_VALUE
26
27
  @differencing_disk = UNSET_VALUE
27
28
  @auto_start_action = UNSET_VALUE
28
29
  @auto_stop_action = UNSET_VALUE
30
+ @enable_virtualization_extensions = UNSET_VALUE
31
+ @vm_integration_services = {
32
+ guest_service_interface: UNSET_VALUE,
33
+ heartbeat: UNSET_VALUE,
34
+ key_value_pair_exchange: UNSET_VALUE,
35
+ shutdown: UNSET_VALUE,
36
+ time_synchronization: UNSET_VALUE,
37
+ vss: UNSET_VALUE
38
+ }
29
39
  end
30
40
 
31
41
  def finalize!
@@ -41,12 +51,18 @@ module VagrantPlugins
41
51
  @differencing_disk = false if @differencing_disk == UNSET_VALUE
42
52
  @auto_start_action = nil if @auto_start_action == UNSET_VALUE
43
53
  @auto_stop_action = nil if @auto_stop_action == UNSET_VALUE
54
+ @enable_virtualization_extensions = false if @enable_virtualization_extensions == UNSET_VALUE # TODO will this work?
55
+
56
+ @vm_integration_services.each { |key, value|
57
+ @vm_integration_services[key] = nil if value == UNSET_VALUE
58
+ }
59
+ @vm_integration_services = nil if @vm_integration_services.length == 0
44
60
  end
45
61
 
46
62
  def validate(machine)
47
63
  errors = _detected_errors
48
64
 
49
- { "Hyper-V" => errors }
65
+ {"Hyper-V" => errors}
50
66
  end
51
67
  end
52
68
  end