kitchen-vagrant 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/.travis.yml +0 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +0 -0
- data/Guardfile +0 -0
- data/LICENSE +0 -0
- data/README.md +64 -62
- data/Rakefile +0 -0
- data/kitchen-vagrant.gemspec +0 -0
- data/lib/kitchen/driver/helpers.rb +111 -0
- data/lib/kitchen/driver/vagrant.rb +18 -1
- data/lib/kitchen/driver/vagrant_version.rb +1 -1
- data/spec/kitchen/driver/vagrant_spec.rb +42 -0
- data/spec/spec_helper.rb +0 -0
- data/support/hyperv.ps1 +29 -0
- data/templates/Vagrantfile.erb +12 -8
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29f29923c8d4eeae2f0e8b01bf0fd097548bcfa8
|
4
|
+
data.tar.gz: 9d86529013c13dee68293b5f4e363bdca635f879
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20aeaa321f602d5a93e2923ac07bea6381d58fc1417cae5d9531301ac9b2637bae06054b6815eb3a64df3893646696255a303183ccb146a878e3dbe06947c1a0
|
7
|
+
data.tar.gz: d9c49dbd3b95086bad52de43eb322579ed8d13951094bdb487f20786e66a80fb1ad8886c6e3d3662bc657787c1533cd173accda25d410067458d427a23672e62
|
data/.gitignore
CHANGED
File without changes
|
data/.rspec
CHANGED
File without changes
|
data/.travis.yml
CHANGED
File without changes
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [1.3.0](https://github.com/test-kitchen/kitchen-vagrant/tree/1.3.0) (2018-01-17)
|
4
|
+
[Full Changelog](https://github.com/test-kitchen/kitchen-vagrant/compare/v1.2.2...1.3.0)
|
5
|
+
|
6
|
+
- Improve Hyper-V defaults and support [\#338](https://github.com/test-kitchen/kitchen-vagrant/pull/338)
|
7
|
+
|
8
|
+
## [1.2.2](https://github.com/test-kitchen/kitchen-vagrant/tree/1.2.2) (2017-11-07)
|
9
|
+
[Full Changelog](https://github.com/test-kitchen/kitchen-vagrant/compare/v1.2.1...1.2.2)
|
10
|
+
|
11
|
+
- For WinRM options, only treat strings as strings. [\#330](https://github.com/test-kitchen/kitchen-vagrant/pull/330)
|
12
|
+
|
3
13
|
## [1.2.1](https://github.com/test-kitchen/kitchen-vagrant/tree/1.2.1) (2017-08-22)
|
4
14
|
[Full Changelog](https://github.com/test-kitchen/kitchen-vagrant/compare/v1.2.0...1.2.1)
|
5
15
|
|
data/Gemfile
CHANGED
File without changes
|
data/Guardfile
CHANGED
File without changes
|
data/LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -20,73 +20,41 @@ A Vagrant version of 1.1.0 or higher is required for this driver which means
|
|
20
20
|
that a [native package][vagrant_dl] must be installed on the system running
|
21
21
|
Test Kitchen.
|
22
22
|
|
23
|
-
**Note:** If you have previously installed Vagrant as a gem (a version prior
|
24
|
-
to 1.1.0), this version may be resolved first in your `PATH`. If you receive an
|
25
|
-
error message that Vagrant is too old despite having installed Vagrant as a
|
26
|
-
package, you may be required to uninstall the gem version or modify your `PATH`
|
27
|
-
environment. If you require the vagrant gem for older projects you should
|
28
|
-
consider the [vagrant-wrapper][vagrant_wrapper] gem which helps manage both
|
29
|
-
styles of Vagrant installations
|
30
|
-
([background details][vagrant_wrapper_background]).
|
31
|
-
|
32
23
|
If you are creating Windows VMs over a WinRM Transport, then the
|
33
24
|
[vagrant-winrm][vagrant_winrm] Vagrant plugin must be installed. As a
|
34
25
|
consequence, the minimum version of Vagrant required is 1.6 or higher.
|
35
26
|
|
36
|
-
### <a name="dependencies-virtualization"></a> Virtualization
|
37
|
-
|
38
|
-
Currently this driver supports Parallels, VirtualBox, and VMware Fusion/Workstation
|
39
|
-
hypervisors. VirtualBox is free and is the default provider for Vagrant.
|
40
|
-
|
41
|
-
[VirtualBox package][virtualbox_dl]
|
42
|
-
|
43
|
-
If you would like to use VMware Fusion/Workstation you must purchase the
|
44
|
-
software from VMware and then must also purchase the Vagrant VMware plugin.
|
45
|
-
|
46
|
-
[Vagrant VMware Plugin][vmware_plugin]
|
47
|
-
|
48
|
-
[VMware Fusion][fusion_dl]
|
49
|
-
|
50
|
-
[VMware Workstation][workstation_dl]
|
51
|
-
|
52
|
-
If you would like to use Parallels Desktop you must also purchase the software but the
|
53
|
-
`vagrant-parallels` plugin is freely available.
|
54
|
-
|
55
|
-
[Parallels Desktop for Mac][parallels_dl]
|
56
|
-
|
57
|
-
[Vagrant Parallels Provider][vagrant_parallels]
|
58
|
-
|
59
|
-
#### <a name="unmaintained-virtualization"></a> Unmaintained Virtualization Hypervisors
|
60
|
-
|
61
|
-
Some additional hypervisors may be used with this driver but are not officially supported:
|
62
|
-
|
63
|
-
[CloudStack][cloudstack] using the unofficial [vagrant-cloudstack][vagrant_cloudstack] plugin for Vagrant.
|
64
|
-
|
65
|
-
[KVM][kvm]/[Libvirt][libvirt] using the unofficial [vagrant-libvirt][vagrant_libvirt] plugin for Vagrant.
|
66
|
-
|
67
|
-
[LXC][lxc] using the unofficial [vagrant-lxc][vagrant_lxc] plugin for Vagrant.
|
27
|
+
### <a name="dependencies-virtualization"></a> Supported Virtualization Hypervisors
|
68
28
|
|
69
|
-
|
29
|
+
| Provider | vagrant plugin | Paid
|
30
|
+
| --------- | --------- | ---------
|
31
|
+
| [VirtualBox][virtualbox_dl] | built-in | N
|
32
|
+
| [VMware Fusion][fusion_dl] | vagrant-vmware-fusion | Y
|
33
|
+
| [VMware Workstation][ws_dl] | vagrant-vmware-workstation | Y
|
34
|
+
| [Parallels Desktop][parallels_dl] | vagrant-parallels | Y (plugin free)
|
35
|
+
| Hyper-V | n/a | N
|
70
36
|
|
71
|
-
|
37
|
+
If you would like to use VMware Fusion or Workstation you must purchase the
|
38
|
+
software from VMware and also purchase the corresponding [Vagrant VMware Plugin][vmware_plugin].
|
72
39
|
|
73
|
-
|
40
|
+
## <a name="installation"></a> Installation
|
74
41
|
|
75
|
-
|
42
|
+
If using the ChefDK, kitchen-vagrant is already installed. If using an existing Ruby install:
|
76
43
|
|
77
|
-
|
44
|
+
```
|
45
|
+
gem install kitchen-vagrant
|
46
|
+
```
|
78
47
|
|
79
48
|
## <a name="default-config"></a> Default Configuration
|
80
49
|
|
81
|
-
For a
|
82
|
-
|
83
|
-
on [Atlas][atlas] such as:
|
50
|
+
For a set of platforms and hypervisors, boxes are published under the [Bento organization][bento_org]
|
51
|
+
on [Vagrant Cloud][vagrant_cloud] which serve as the default boxes for common platforms:
|
84
52
|
|
85
53
|
```yaml
|
86
54
|
---
|
87
55
|
platforms:
|
88
56
|
- name: ubuntu-16.04
|
89
|
-
- name: centos-7
|
57
|
+
- name: centos-7
|
90
58
|
- name: freebsd-11
|
91
59
|
```
|
92
60
|
|
@@ -98,12 +66,12 @@ platforms:
|
|
98
66
|
- name: ubuntu-16.04
|
99
67
|
driver:
|
100
68
|
box: bento/ubuntu-16.04
|
101
|
-
- name: centos-7
|
69
|
+
- name: centos-7
|
102
70
|
driver:
|
103
|
-
box: bento/centos-7
|
104
|
-
- name: freebsd-11
|
71
|
+
box: bento/centos-7
|
72
|
+
- name: freebsd-11
|
105
73
|
driver:
|
106
|
-
box: bento/freebsd-11
|
74
|
+
box: bento/freebsd-11
|
107
75
|
# ...
|
108
76
|
```
|
109
77
|
|
@@ -132,8 +100,23 @@ platforms:
|
|
132
100
|
driver:
|
133
101
|
box: windows-2012r2
|
134
102
|
```
|
103
|
+
### Hyper-V
|
104
|
+
|
105
|
+
As Hyper-V is an exclusive hypervisor, it is recomended that the environment variable `VAGRANT_DEFAULT_PROVIDER` be set to `hyperv`. Vagrant currently requires user input to choose a virtual switch so we try to detect this automatically and use a workaround. If no network configuration is provided, we check:
|
135
106
|
|
136
|
-
|
107
|
+
1) environment variable `KITCHEN_HYPERV_SWITCH`
|
108
|
+
2) If on Windows 10 Fall Creators Update, use the built-in 'Default Switch'
|
109
|
+
3) the first switch returned
|
110
|
+
|
111
|
+
If `VAGRANT_DEFAULT_PROVIDER` is set and the above logic has a valid virtual switch, no additional configuration is needed. This will effectively generate a configuration similar to:
|
112
|
+
|
113
|
+
```yaml
|
114
|
+
driver:
|
115
|
+
name: vagrant
|
116
|
+
provider: hyperv
|
117
|
+
network:
|
118
|
+
- ["public_network", bridge: "Default Switch"]
|
119
|
+
```
|
137
120
|
|
138
121
|
## <a name="config"></a> Configuration
|
139
122
|
|
@@ -167,7 +150,7 @@ page.
|
|
167
150
|
|
168
151
|
The default will be computed from the platform name of the instance. However,
|
169
152
|
for a number of common platforms in the [Bento][bento] project, the default will
|
170
|
-
prefix the name with `bento/` in accordance with
|
153
|
+
prefix the name with `bento/` in accordance with Vagrant Cloud naming standards.
|
171
154
|
|
172
155
|
For example, a platform with name `ubuntu-16.04` will produce a
|
173
156
|
default `box` value of `bento/ubuntu-16.04`. Alternatively, a box called
|
@@ -179,7 +162,7 @@ Whether to check for box updates (enabled by default).
|
|
179
162
|
|
180
163
|
### <a name="config-box-url"></a> box\_url
|
181
164
|
|
182
|
-
A box_url is not required when using the
|
165
|
+
A box_url is not required when using the Vagrant Cloud format of
|
183
166
|
`bento/ubuntu-16.04` assuming the organization and box referenced
|
184
167
|
exist. If using a custom box this can be an `https://` or `file://`
|
185
168
|
URL.
|
@@ -206,7 +189,7 @@ The [version][vagrant_versioning] of the configured box.
|
|
206
189
|
|
207
190
|
The default is `nil`, indicating unset.
|
208
191
|
|
209
|
-
This option is only relevant when used with
|
192
|
+
This option is only relevant when used with Vagrant Cloud boxes which support versioning.
|
210
193
|
|
211
194
|
### <a name="config-communicator"></a> communicator
|
212
195
|
|
@@ -271,6 +254,9 @@ and [VMware][vagrant_config_vmware] for more details.
|
|
271
254
|
Adding the `createhd` and `storageattach` keys in `customize` allows for creation
|
272
255
|
of additional disks in VirtualBox. Full paths must be used as required by VirtualBox.
|
273
256
|
|
257
|
+
Adding the `storagectl` key in `customize` allows for creation or customization of
|
258
|
+
disks controller in Virtualbox.
|
259
|
+
|
274
260
|
*NOTE*: IDE Controller based drives always show up in the boot order first, regardless of if they
|
275
261
|
are [bootable][vbox_ide_boot].
|
276
262
|
|
@@ -282,6 +268,9 @@ driver:
|
|
282
268
|
size: 1024
|
283
269
|
- filename: /tmp/disk2.vmdk
|
284
270
|
size: 2048
|
271
|
+
storagectl:
|
272
|
+
- name: IDE Controller
|
273
|
+
portcount: 4
|
285
274
|
storageattach:
|
286
275
|
- storagectl: IDE Controller
|
287
276
|
port: 1
|
@@ -303,13 +292,15 @@ Vagrant.configure("2") do |config|
|
|
303
292
|
|
304
293
|
config.vm.provider :virtualbox do |virtualbox|
|
305
294
|
virtualbox.customize ["createhd", "--filename", "./tmp/disk1.vmdk", "--size", 1024]
|
295
|
+
virtualbox.customize ["storagectl", :id, "--name", "IDE Controller", "--portcount", 4]
|
306
296
|
virtualbox.customize ["storageattach", :id, "--storagectl", "IDE Controller", "--port", "1", "--device", 0, "--type", "hdd", "--medium", "./tmp/disk1.vmdk"]
|
307
297
|
end
|
308
298
|
end
|
309
299
|
```
|
310
300
|
|
311
301
|
Please read [createhd](https://www.virtualbox.org/manual/ch08.html#vboxmanage-createvdi)
|
312
|
-
|
302
|
+
, [storageattach](https://www.virtualbox.org/manual/ch08.html#vboxmanage-storageattach)
|
303
|
+
and [storagectl](https://www.virtualbox.org/manual/ch08.html#vboxmanage-storagectl)
|
313
304
|
for additional information on these options.
|
314
305
|
|
315
306
|
### <a name="config-guest"></a> guest
|
@@ -567,6 +558,17 @@ instance was called "default-fuzz-9" will produce a default `vm_hostname` value
|
|
567
558
|
of `"default-fuzz-9"`. For Windows-based platforms, a default of `nil` is used
|
568
559
|
to save on boot time and potential rebooting.
|
569
560
|
|
561
|
+
## <a name="unsupported"></a> Unsupported Hypervisors
|
562
|
+
|
563
|
+
The following providers are reported to work but are unsupported:
|
564
|
+
|
565
|
+
- [CloudStack][cloudstack] via [vagrant-cloudstack][vagrant_cloudstack]
|
566
|
+
- [KVM][kvm]/[Libvirt][libvirt] via [vagrant-libvirt][vagrant_libvirt]
|
567
|
+
- [LXC][lxc] via [vagrant-lxc][vagrant_lxc]
|
568
|
+
- [OpenStack][openstack]
|
569
|
+
- [RackSpace][rackspace] via [vagrant-rackspace][vagrant_rackspace]
|
570
|
+
- [SoftLayer][softlayer] via [vagrant-softlayer][vagrant_softlayer]
|
571
|
+
|
570
572
|
## <a name="development"></a> Development
|
571
573
|
|
572
574
|
* Source hosted at [GitHub][repo]
|
@@ -613,9 +615,9 @@ Apache 2.0 (see [LICENSE][license])
|
|
613
615
|
[vagrant_wrapper_background]: https://github.com/org-binbab/gem-vagrant-wrapper#background---aka-the-vagrant-gem-enigma
|
614
616
|
[vmware_plugin]: http://www.vagrantup.com/vmware
|
615
617
|
[fusion_dl]: http://www.vmware.com/products/fusion/overview.html
|
616
|
-
[
|
617
|
-
[bento_org]: https://
|
618
|
-
[
|
618
|
+
[ws_dl]: http://www.vmware.com/products/workstation/
|
619
|
+
[bento_org]: https://app.vagrantup.com/bento
|
620
|
+
[vagrant_cloud]: https://app.vagrantup.com/boxes/search
|
619
621
|
[parallels_dl]: http://www.parallels.com/products/desktop/download/
|
620
622
|
[vagrant_parallels]: https://github.com/Parallels/vagrant-parallels
|
621
623
|
[vagrant_cachier]: https://github.com/fgrehm/vagrant-cachier
|
data/Rakefile
CHANGED
File without changes
|
data/kitchen-vagrant.gemspec
CHANGED
File without changes
|
@@ -0,0 +1,111 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Steven Murawski <smurawski@chef.io>
|
3
|
+
# Copyright:: Copyright (c) 2015 Chef Software, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
require "mixlib/shellout"
|
19
|
+
require "fileutils"
|
20
|
+
require "json"
|
21
|
+
|
22
|
+
module Kitchen
|
23
|
+
module Driver
|
24
|
+
module HypervHelpers
|
25
|
+
def encode_command(script)
|
26
|
+
encoded_script = script.encode("UTF-16LE", "UTF-8")
|
27
|
+
Base64.strict_encode64(encoded_script)
|
28
|
+
end
|
29
|
+
|
30
|
+
def is_64bit?
|
31
|
+
os_arch = ENV["PROCESSOR_ARCHITEW6432"] || ENV["PROCESSOR_ARCHITECTURE"]
|
32
|
+
ruby_arch = ["foo"].pack("p").size == 4 ? 32 : 64
|
33
|
+
os_arch == "AMD64" && ruby_arch == 64
|
34
|
+
end
|
35
|
+
|
36
|
+
def is_32bit?
|
37
|
+
os_arch = ENV["PROCESSOR_ARCHITEW6432"] || ENV["PROCESSOR_ARCHITECTURE"]
|
38
|
+
ruby_arch = ["foo"].pack("p").size == 4 ? 32 : 64
|
39
|
+
os_arch != "AMD64" && ruby_arch == 32
|
40
|
+
end
|
41
|
+
|
42
|
+
def powershell_64_bit
|
43
|
+
if is_64bit? || is_32bit?
|
44
|
+
'c:\windows\system32\windowspowershell\v1.0\powershell.exe'
|
45
|
+
else
|
46
|
+
'c:\windows\sysnative\windowspowershell\v1.0\powershell.exe'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def wrap_command(script)
|
51
|
+
base_script_path = File.join(File.dirname(__FILE__), "/../../../support/hyperv.ps1")
|
52
|
+
debug("Loading functions from #{base_script_path}")
|
53
|
+
new_script = [ ". #{base_script_path}", "#{script}" ].join(";\n")
|
54
|
+
debug("Wrapped script: #{new_script}")
|
55
|
+
"#{powershell_64_bit} -noprofile -executionpolicy bypass" \
|
56
|
+
" -encodedcommand #{encode_command new_script} -outputformat Text"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Convenience method to run a powershell command locally.
|
60
|
+
#
|
61
|
+
# @param cmd [String] command to run locally
|
62
|
+
# @param options [Hash] options hash
|
63
|
+
# @see Kitchen::ShellOut.run_command
|
64
|
+
# @api private
|
65
|
+
def run_ps(cmd, options = {})
|
66
|
+
cmd = "echo #{cmd}" if config[:dry_run]
|
67
|
+
debug("Preparing to run: ")
|
68
|
+
debug(" #{cmd}")
|
69
|
+
wrapped_command = wrap_command cmd
|
70
|
+
execute_command wrapped_command, options
|
71
|
+
end
|
72
|
+
|
73
|
+
def execute_command(cmd, options = {})
|
74
|
+
debug("#Local Command BEGIN (#{cmd})")
|
75
|
+
sh = Mixlib::ShellOut.new(cmd, options)
|
76
|
+
sh.run_command
|
77
|
+
debug("Local Command END #{Util.duration(sh.execution_time)}")
|
78
|
+
raise "Failed: #{sh.stderr}" if sh.error?
|
79
|
+
stdout = sanitize_stdout(sh.stdout)
|
80
|
+
JSON.parse(stdout) if stdout.length > 2
|
81
|
+
end
|
82
|
+
|
83
|
+
def sanitize_stdout(stdout)
|
84
|
+
stdout.split("\n").select { |s| !s.start_with?("PS") }.join("\n")
|
85
|
+
end
|
86
|
+
|
87
|
+
def hyperv_switch
|
88
|
+
default_switch_object = run_ps hyperv_default_switch_ps
|
89
|
+
if default_switch_object.nil? ||
|
90
|
+
!default_switch_object.key?("Name") ||
|
91
|
+
default_switch_object["Name"].empty?
|
92
|
+
raise "Failed to find a default VM Switch."
|
93
|
+
end
|
94
|
+
default_switch_object["Name"]
|
95
|
+
end
|
96
|
+
|
97
|
+
def hyperv_default_switch_ps
|
98
|
+
<<-VMSWITCH
|
99
|
+
Get-DefaultVMSwitch #{ENV['KITCHEN_HYPERV_SWITCH']} | ConvertTo-Json
|
100
|
+
VMSWITCH
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
def ruby_array_to_ps_array(list)
|
106
|
+
return "@()" if list.nil? || list.empty?
|
107
|
+
list.to_s.tr("[]", "()").prepend("@")
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -22,6 +22,7 @@ require "rubygems/version"
|
|
22
22
|
|
23
23
|
require "kitchen"
|
24
24
|
require "kitchen/driver/vagrant_version"
|
25
|
+
require "kitchen/driver/helpers"
|
25
26
|
|
26
27
|
module Kitchen
|
27
28
|
|
@@ -33,6 +34,7 @@ module Kitchen
|
|
33
34
|
class Vagrant < Kitchen::Driver::Base
|
34
35
|
|
35
36
|
include ShellOut
|
37
|
+
include Kitchen::Driver::HypervHelpers
|
36
38
|
|
37
39
|
kitchen_driver_api_version 2
|
38
40
|
|
@@ -169,6 +171,7 @@ module Kitchen
|
|
169
171
|
finalize_pre_create_command!
|
170
172
|
finalize_synced_folders!
|
171
173
|
finalize_ca_cert!
|
174
|
+
finalize_network!
|
172
175
|
self
|
173
176
|
end
|
174
177
|
|
@@ -208,7 +211,7 @@ module Kitchen
|
|
208
211
|
|
209
212
|
protected
|
210
213
|
|
211
|
-
WEBSITE = "
|
214
|
+
WEBSITE = "https://www.vagrantup.com/downloads.html".freeze
|
212
215
|
MIN_VER = "1.1.0".freeze
|
213
216
|
|
214
217
|
class << self
|
@@ -240,6 +243,7 @@ module Kitchen
|
|
240
243
|
# shared folders
|
241
244
|
# @api private
|
242
245
|
def safe_share?(box)
|
246
|
+
return false if config[:provider] =~ /(hyperv|libvirt)/
|
243
247
|
box =~ /^bento\/(centos|debian|fedora|opensuse|ubuntu|oracle)-/
|
244
248
|
end
|
245
249
|
|
@@ -342,6 +346,19 @@ module Kitchen
|
|
342
346
|
end
|
343
347
|
end
|
344
348
|
|
349
|
+
# If Hyper-V and no network configuration
|
350
|
+
# check KITCHEN_HYPERV_SWITCH and fallback to helper method
|
351
|
+
# to select the best switch
|
352
|
+
# @api private
|
353
|
+
def finalize_network!
|
354
|
+
if config[:provider] == "hyperv" && config[:network].empty?
|
355
|
+
config[:network].push([
|
356
|
+
"public_network",
|
357
|
+
"bridge: #{hyperv_switch}",
|
358
|
+
])
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
345
362
|
# Loads any required third party Ruby libraries or runs any shell out
|
346
363
|
# commands to prepare the plugin. This method will be called in the
|
347
364
|
# context of the main thread of execution and so does not necessarily
|
@@ -1377,6 +1377,48 @@ describe Kitchen::Driver::Vagrant do
|
|
1377
1377
|
RUBY
|
1378
1378
|
end
|
1379
1379
|
|
1380
|
+
it "adds lines for single storagectl in :customize" do
|
1381
|
+
config[:customize] = {
|
1382
|
+
:storagectl => {
|
1383
|
+
:name => "Custom SATA Controller",
|
1384
|
+
:add => "sata",
|
1385
|
+
:controller => "IntelAHCI",
|
1386
|
+
:portcount => 4,
|
1387
|
+
},
|
1388
|
+
}
|
1389
|
+
cmd
|
1390
|
+
|
1391
|
+
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1392
|
+
c.vm.provider :virtualbox do |p|
|
1393
|
+
p.customize ["storagectl", :id, "--name", "Custom SATA Controller", "--add", "sata", "--controller", "IntelAHCI", "--portcount", 4]
|
1394
|
+
end
|
1395
|
+
RUBY
|
1396
|
+
end
|
1397
|
+
|
1398
|
+
it "adds lines for multiple storagectl in :customize" do
|
1399
|
+
config[:customize] = {
|
1400
|
+
:storagectl => [
|
1401
|
+
{
|
1402
|
+
:name => "Custom SATA Controller",
|
1403
|
+
:add => "sata",
|
1404
|
+
:controller => "IntelAHCI",
|
1405
|
+
},
|
1406
|
+
{
|
1407
|
+
:name => "Custom SATA Controller",
|
1408
|
+
:portcount => 4,
|
1409
|
+
},
|
1410
|
+
],
|
1411
|
+
}
|
1412
|
+
cmd
|
1413
|
+
|
1414
|
+
expect(vagrantfile).to match(regexify(<<-RUBY.gsub(/^ {8}/, "").chomp))
|
1415
|
+
c.vm.provider :virtualbox do |p|
|
1416
|
+
p.customize ["storagectl", :id, "--name", "Custom SATA Controller", "--add", "sata", "--controller", "IntelAHCI"]
|
1417
|
+
p.customize ["storagectl", :id, "--name", "Custom SATA Controller", "--portcount", 4]
|
1418
|
+
end
|
1419
|
+
RUBY
|
1420
|
+
end
|
1421
|
+
|
1380
1422
|
it "adds lines for single storageattach in :customize" do
|
1381
1423
|
config[:customize] = {
|
1382
1424
|
:storageattach => {
|
data/spec/spec_helper.rb
CHANGED
File without changes
|
data/support/hyperv.ps1
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#requires -Version 2 -Modules Hyper-V
|
2
|
+
|
3
|
+
#implicitly import hyperv module to avoid powercli cmdlets
|
4
|
+
if ((Get-Module -Name 'hyper-v') -ne $null) {
|
5
|
+
Remove-Module -Name hyper-v
|
6
|
+
Import-Module -Name hyper-v
|
7
|
+
}
|
8
|
+
else {
|
9
|
+
Import-Module -Name hyper-v
|
10
|
+
}
|
11
|
+
|
12
|
+
$ProgressPreference = 'SilentlyContinue'
|
13
|
+
|
14
|
+
function Get-DefaultVMSwitch {
|
15
|
+
[CmdletBinding()]
|
16
|
+
param ($Name)
|
17
|
+
|
18
|
+
$switches = Get-VMSwitch @PSBoundParameters
|
19
|
+
|
20
|
+
if (-not $PSBoundParameters.ContainsKey('Name') -and (($switches.Name) -contains 'Default Switch') ) {
|
21
|
+
# Looking for 'Default Switch' on Fall Creators Update or newer
|
22
|
+
$switches = $switches |
|
23
|
+
Where-Object {$_.Name -like 'Default Switch'}
|
24
|
+
}
|
25
|
+
|
26
|
+
$switches |
|
27
|
+
Select-Object -first 1 |
|
28
|
+
Select-Object Name, ID
|
29
|
+
}
|
data/templates/Vagrantfile.erb
CHANGED
@@ -68,7 +68,11 @@ Vagrant.configure("2") do |c|
|
|
68
68
|
<% end %>
|
69
69
|
<% if config[:winrm] %>
|
70
70
|
<% config[:winrm].each do |key, value| %>
|
71
|
-
|
71
|
+
<% if value.is_a? String %>
|
72
|
+
c.winrm.<%= key %> = "<%= value%>"
|
73
|
+
<% else %>
|
74
|
+
c.winrm.<%= key %> = <%= value%>
|
75
|
+
<% end %>
|
72
76
|
<% end %>
|
73
77
|
<% end %>
|
74
78
|
|
@@ -156,19 +160,19 @@ Vagrant.configure("2") do |c|
|
|
156
160
|
<% value.each do |item| %>
|
157
161
|
p.customize ["createhd", "--filename", "<%= item[:filename] %>", "--size", <%= item[:size] %>]
|
158
162
|
<% end %>
|
159
|
-
<% elsif key == :storageattach %>
|
163
|
+
<% elsif key == :storageattach || key == :storagectl %>
|
160
164
|
<% value = [value] unless value.instance_of?(Array) %>
|
161
165
|
<% value.each do |item| %>
|
162
166
|
<% options = [] %>
|
163
|
-
<% item.each do |
|
164
|
-
options << "\"--#{
|
165
|
-
if
|
166
|
-
options <<
|
167
|
+
<% item.each do |storage_option_key, storage_option_value|
|
168
|
+
options << "\"--#{storage_option_key}\""
|
169
|
+
if storage_option_value.instance_of? Fixnum
|
170
|
+
options << storage_option_value
|
167
171
|
else
|
168
|
-
options << "\"#{
|
172
|
+
options << "\"#{storage_option_value}\""
|
169
173
|
end
|
170
174
|
end %>
|
171
|
-
p.customize ["
|
175
|
+
p.customize ["<%= key.to_s %>", :id, <%= options.join(', ') %>]
|
172
176
|
<% end %>
|
173
177
|
<% elsif key == :cpuidset %>
|
174
178
|
<% ids = [] %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-vagrant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fletcher Nichol
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|
@@ -125,10 +125,12 @@ files:
|
|
125
125
|
- README.md
|
126
126
|
- Rakefile
|
127
127
|
- kitchen-vagrant.gemspec
|
128
|
+
- lib/kitchen/driver/helpers.rb
|
128
129
|
- lib/kitchen/driver/vagrant.rb
|
129
130
|
- lib/kitchen/driver/vagrant_version.rb
|
130
131
|
- spec/kitchen/driver/vagrant_spec.rb
|
131
132
|
- spec/spec_helper.rb
|
133
|
+
- support/hyperv.ps1
|
132
134
|
- templates/Vagrantfile.erb
|
133
135
|
homepage: https://github.com/test-kitchen/kitchen-vagrant/
|
134
136
|
licenses:
|
@@ -150,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
152
|
version: '0'
|
151
153
|
requirements: []
|
152
154
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.6.
|
155
|
+
rubygems_version: 2.6.13
|
154
156
|
signing_key:
|
155
157
|
specification_version: 4
|
156
158
|
summary: Kitchen::Driver::Vagrant - A Vagrant Driver for Test Kitchen.
|