kitchen-hyperv 0.1.10 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.cane +1 -1
- data/.gitignore +15 -15
- data/CHANGELOG.md +21 -21
- data/Gemfile +9 -9
- data/LICENSE.txt +22 -22
- data/README.md +6 -0
- data/Rakefile +52 -52
- data/kitchen-hyperv.gemspec +31 -31
- data/lib/kitchen/driver/hyperv.rb +3 -0
- data/lib/kitchen/driver/hyperv_version.rb +22 -22
- data/lib/kitchen/driver/powershell.rb +194 -184
- data/spec/kitchen/driver/hyperv_spec.rb +70 -70
- data/spec/spec_helper.rb +43 -43
- data/spec/support/hyperv.Tests.ps1 +2 -2
- data/support/hyperv.ps1 +4 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c1d4f93b043b3ffd049677de50956792b767beef
|
|
4
|
+
data.tar.gz: 16273be77c92281545407b43f51d8e47c5de8155
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: feb8ed661a0989544fe2a1e1fc5030e0fb24f614da9a19ac85812c8aa5013f5aef5eb240b4a483155088eca8bb529ec523a56773d70318941b42e350ae41d700
|
|
7
|
+
data.tar.gz: 7d01d62bb019ba9b44d830742e8809857e89b8030503e71745e875fa5526df78a00e1f5339a8ce610c373c78b9c3cbc97bfecc3ae73556e8617ab34d0a054a7f
|
data/.cane
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
--no-doc
|
|
1
|
+
--no-doc
|
|
2
2
|
--style-measure 100
|
data/.gitignore
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/.bundle/
|
|
2
|
-
/.yardoc
|
|
3
|
-
/Gemfile.lock
|
|
4
|
-
/_yardoc/
|
|
5
|
-
/coverage/
|
|
6
|
-
/doc/
|
|
7
|
-
/pkg/
|
|
8
|
-
/spec/reports/
|
|
9
|
-
/tmp/
|
|
10
|
-
*.bundle
|
|
11
|
-
*.so
|
|
12
|
-
*.o
|
|
13
|
-
*.a
|
|
14
|
-
mkmf.log
|
|
15
|
-
*.gem
|
|
1
|
+
/.bundle/
|
|
2
|
+
/.yardoc
|
|
3
|
+
/Gemfile.lock
|
|
4
|
+
/_yardoc/
|
|
5
|
+
/coverage/
|
|
6
|
+
/doc/
|
|
7
|
+
/pkg/
|
|
8
|
+
/spec/reports/
|
|
9
|
+
/tmp/
|
|
10
|
+
*.bundle
|
|
11
|
+
*.so
|
|
12
|
+
*.o
|
|
13
|
+
*.a
|
|
14
|
+
mkmf.log
|
|
15
|
+
*.gem
|
data/CHANGELOG.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
# 0.1.10 / 12-03-2015
|
|
2
|
-
|
|
3
|
-
I really need to add some tests to this project. ;)
|
|
4
|
-
|
|
5
|
-
* [PR #21](https://github.com/test-kitchen/kitchen-hyperv/pull/21) : Wrong module name
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
# 0.1.9 / 12-03-2015
|
|
9
|
-
|
|
10
|
-
Missed a merge conflict.
|
|
11
|
-
|
|
12
|
-
# 0.1.8 / 12-03-2015
|
|
13
|
-
|
|
14
|
-
* [PR #15](https://github.com/test-kitchen/kitchen-hyperv/pull/15) : Dynamic Memory support
|
|
15
|
-
* [PR #17](https://github.com/test-kitchen/kitchen-hyperv/pull/17) : File copy support
|
|
16
|
-
* [PR #19](https://github.com/test-kitchen/kitchen-hyperv/pull/19) : Explict import of hyper-v module and delay in getting ip (wait for DHCP)
|
|
17
|
-
* [PR #20](https://github.com/test-kitchen/kitchen-hyperv/pull/20) : Doc the required WinRM Settings
|
|
18
|
-
|
|
19
|
-
# 0.1.7 / 07-14-2015
|
|
20
|
-
|
|
21
|
-
* [PR #8](https://github.com/test-kitchen/kitchen-hyperv/pull/8) : Add support for 64 bit ruby
|
|
1
|
+
# 0.1.10 / 12-03-2015
|
|
2
|
+
|
|
3
|
+
I really need to add some tests to this project. ;)
|
|
4
|
+
|
|
5
|
+
* [PR #21](https://github.com/test-kitchen/kitchen-hyperv/pull/21) : Wrong module name
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# 0.1.9 / 12-03-2015
|
|
9
|
+
|
|
10
|
+
Missed a merge conflict.
|
|
11
|
+
|
|
12
|
+
# 0.1.8 / 12-03-2015
|
|
13
|
+
|
|
14
|
+
* [PR #15](https://github.com/test-kitchen/kitchen-hyperv/pull/15) : Dynamic Memory support
|
|
15
|
+
* [PR #17](https://github.com/test-kitchen/kitchen-hyperv/pull/17) : File copy support
|
|
16
|
+
* [PR #19](https://github.com/test-kitchen/kitchen-hyperv/pull/19) : Explict import of hyper-v module and delay in getting ip (wait for DHCP)
|
|
17
|
+
* [PR #20](https://github.com/test-kitchen/kitchen-hyperv/pull/20) : Doc the required WinRM Settings
|
|
18
|
+
|
|
19
|
+
# 0.1.7 / 07-14-2015
|
|
20
|
+
|
|
21
|
+
* [PR #8](https://github.com/test-kitchen/kitchen-hyperv/pull/8) : Add support for 64 bit ruby
|
data/Gemfile
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
# Specify your gem's dependencies in kitchen-hyperv.gemspec
|
|
4
|
-
gemspec
|
|
5
|
-
|
|
6
|
-
gem 'win32-process'
|
|
7
|
-
gem 'win32-api'
|
|
8
|
-
gem 'windows-pr'
|
|
9
|
-
gem 'windows-api'
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# Specify your gem's dependencies in kitchen-hyperv.gemspec
|
|
4
|
+
gemspec
|
|
5
|
+
|
|
6
|
+
gem 'win32-process'
|
|
7
|
+
gem 'win32-api'
|
|
8
|
+
gem 'windows-pr'
|
|
9
|
+
gem 'windows-api'
|
|
10
10
|
gem 'ffi'
|
data/LICENSE.txt
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
Copyright (c) 2015 Steven Murawski
|
|
2
|
-
|
|
3
|
-
MIT License
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
a copy of this software and associated documentation files (the
|
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
Copyright (c) 2015 Steven Murawski
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -39,6 +39,12 @@ driver:
|
|
|
39
39
|
* The minimum and maximum amount of memory Hyper-V will allocate to a virtual machine if dynamic_memory is enabled. Defaults to 536,870,912 and 2,147,483,648 (512MB-2GB)
|
|
40
40
|
* ip_address
|
|
41
41
|
* IP address for the virtual machine. If the VM is not on a network with DHCP, this can be used to assign an IP that can be reached from the host machine.
|
|
42
|
+
* subnet
|
|
43
|
+
* The subnet of the virtual machine. Defaults to `255.255.255.0`
|
|
44
|
+
* gateway
|
|
45
|
+
* The default gateway of the virtual machine.
|
|
46
|
+
* dns_servers
|
|
47
|
+
* A list of DNS Servers that can be reached on the virtual network.
|
|
42
48
|
* vm_switch
|
|
43
49
|
* The virtual switch to attach the guest VMs. Defaults to the first switch returned from Get-VMSwitch.
|
|
44
50
|
* iso_path
|
data/Rakefile
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
|
|
3
|
-
require "bundler/gem_tasks"
|
|
4
|
-
|
|
5
|
-
require "rake/testtask"
|
|
6
|
-
Rake::TestTask.new(:unit) do |t|
|
|
7
|
-
t.libs.push "lib"
|
|
8
|
-
t.test_files = FileList["spec/**/*_spec.rb"]
|
|
9
|
-
t.verbose = true
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
desc "Run all test suites"
|
|
13
|
-
task :test => [:unit]
|
|
14
|
-
|
|
15
|
-
desc "Display LOC stats"
|
|
16
|
-
task :stats do
|
|
17
|
-
puts "\n## Production Code Stats"
|
|
18
|
-
sh "countloc -r lib"
|
|
19
|
-
puts "\n## Test Code Stats"
|
|
20
|
-
sh "countloc -r spec"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
require "finstyle"
|
|
24
|
-
require "rubocop/rake_task"
|
|
25
|
-
RuboCop::RakeTask.new(:style) do |task|
|
|
26
|
-
task.options << "--display-cop-names"
|
|
27
|
-
task.options << "--lint"
|
|
28
|
-
task.options << '--config' << '.rubocop.yml'
|
|
29
|
-
task.patterns = ['lib/**/*.rb']
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
require "cane/rake_task"
|
|
33
|
-
desc "Run cane to check quality metrics"
|
|
34
|
-
Cane::RakeTask.new do |cane|
|
|
35
|
-
cane.canefile = "./.cane"
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
desc "Run all quality tasks"
|
|
39
|
-
task :quality => [:cane, :style, :stats]
|
|
40
|
-
|
|
41
|
-
require "yard"
|
|
42
|
-
YARD::Rake::YardocTask.new
|
|
43
|
-
|
|
44
|
-
desc "Generate gem dependency graph"
|
|
45
|
-
task :viz do
|
|
46
|
-
Bundler.with_clean_env do
|
|
47
|
-
sh "bundle viz --without test development guard " \
|
|
48
|
-
"--requirements --version"
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
task :default => [:test, :quality]
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
|
|
5
|
+
require "rake/testtask"
|
|
6
|
+
Rake::TestTask.new(:unit) do |t|
|
|
7
|
+
t.libs.push "lib"
|
|
8
|
+
t.test_files = FileList["spec/**/*_spec.rb"]
|
|
9
|
+
t.verbose = true
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
desc "Run all test suites"
|
|
13
|
+
task :test => [:unit]
|
|
14
|
+
|
|
15
|
+
desc "Display LOC stats"
|
|
16
|
+
task :stats do
|
|
17
|
+
puts "\n## Production Code Stats"
|
|
18
|
+
sh "countloc -r lib"
|
|
19
|
+
puts "\n## Test Code Stats"
|
|
20
|
+
sh "countloc -r spec"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
require "finstyle"
|
|
24
|
+
require "rubocop/rake_task"
|
|
25
|
+
RuboCop::RakeTask.new(:style) do |task|
|
|
26
|
+
task.options << "--display-cop-names"
|
|
27
|
+
task.options << "--lint"
|
|
28
|
+
task.options << '--config' << '.rubocop.yml'
|
|
29
|
+
task.patterns = ['lib/**/*.rb']
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
require "cane/rake_task"
|
|
33
|
+
desc "Run cane to check quality metrics"
|
|
34
|
+
Cane::RakeTask.new do |cane|
|
|
35
|
+
cane.canefile = "./.cane"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
desc "Run all quality tasks"
|
|
39
|
+
task :quality => [:cane, :style, :stats]
|
|
40
|
+
|
|
41
|
+
require "yard"
|
|
42
|
+
YARD::Rake::YardocTask.new
|
|
43
|
+
|
|
44
|
+
desc "Generate gem dependency graph"
|
|
45
|
+
task :viz do
|
|
46
|
+
Bundler.with_clean_env do
|
|
47
|
+
sh "bundle viz --without test development guard " \
|
|
48
|
+
"--requirements --version"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
task :default => [:test, :quality]
|
data/kitchen-hyperv.gemspec
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
|
|
5
|
-
require 'kitchen/driver/hyperv_version'
|
|
6
|
-
|
|
7
|
-
Gem::Specification.new do |spec|
|
|
8
|
-
spec.name = "kitchen-hyperv"
|
|
9
|
-
spec.version = Kitchen::Driver::HYPERV_VERSION
|
|
10
|
-
spec.authors = ["Steven Murawski"]
|
|
11
|
-
spec.email = ["steven.murawski@gmail.com"]
|
|
12
|
-
spec.summary = 'Hyper-V Driver for Test-Kitchen'
|
|
13
|
-
spec.description = 'Hyper-V Driver for Test-Kitchen'
|
|
14
|
-
spec.homepage = "https://github.com/test-kitchen/kitchen-hyperv"
|
|
15
|
-
spec.license = "Apache 2"
|
|
16
|
-
|
|
17
|
-
spec.files = `git ls-files -z`.split("\x0")
|
|
18
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
19
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
20
|
-
spec.require_paths = ["lib"]
|
|
21
|
-
|
|
22
|
-
spec.add_development_dependency "bundler", "~> 1.7"
|
|
23
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
|
24
|
-
spec.add_development_dependency "pry", "~> 0.10"
|
|
25
|
-
spec.add_development_dependency "cane"
|
|
26
|
-
spec.add_development_dependency "finstyle"
|
|
27
|
-
spec.add_development_dependency "rubocop"
|
|
28
|
-
spec.add_development_dependency "yard"
|
|
29
|
-
|
|
30
|
-
spec.add_dependency "test-kitchen", "~> 1.4"
|
|
31
|
-
end
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
|
|
5
|
+
require 'kitchen/driver/hyperv_version'
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = "kitchen-hyperv"
|
|
9
|
+
spec.version = Kitchen::Driver::HYPERV_VERSION
|
|
10
|
+
spec.authors = ["Steven Murawski"]
|
|
11
|
+
spec.email = ["steven.murawski@gmail.com"]
|
|
12
|
+
spec.summary = 'Hyper-V Driver for Test-Kitchen'
|
|
13
|
+
spec.description = 'Hyper-V Driver for Test-Kitchen'
|
|
14
|
+
spec.homepage = "https://github.com/test-kitchen/kitchen-hyperv"
|
|
15
|
+
spec.license = "Apache 2"
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
20
|
+
spec.require_paths = ["lib"]
|
|
21
|
+
|
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
24
|
+
spec.add_development_dependency "pry", "~> 0.10"
|
|
25
|
+
spec.add_development_dependency "cane"
|
|
26
|
+
spec.add_development_dependency "finstyle"
|
|
27
|
+
spec.add_development_dependency "rubocop"
|
|
28
|
+
spec.add_development_dependency "yard"
|
|
29
|
+
|
|
30
|
+
spec.add_dependency "test-kitchen", "~> 1.4"
|
|
31
|
+
end
|
|
@@ -42,6 +42,9 @@ module Kitchen
|
|
|
42
42
|
default_config :dynamic_memory, false
|
|
43
43
|
default_config :processor_count, 2
|
|
44
44
|
default_config :ip_address
|
|
45
|
+
default_config :gateway
|
|
46
|
+
default_config :dns_servers
|
|
47
|
+
default_config :subnet, '255.255.255.0'
|
|
45
48
|
default_config :vm_switch
|
|
46
49
|
default_config :iso_path
|
|
47
50
|
default_config :vm_generation, 1
|
|
@@ -1,22 +1,22 @@
|
|
|
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
|
-
module Kitchen
|
|
19
|
-
module Driver
|
|
20
|
-
HYPERV_VERSION = '0.1.
|
|
21
|
-
end
|
|
22
|
-
end
|
|
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
|
+
module Kitchen
|
|
19
|
+
module Driver
|
|
20
|
+
HYPERV_VERSION = '0.1.20'
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -1,184 +1,194 @@
|
|
|
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 PowerShellScripts
|
|
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
|
-
os_arch == 'AMD64'
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def powershell_64_bit
|
|
36
|
-
if is_64bit?
|
|
37
|
-
'c:\windows\system32\windowspowershell\v1.0\powershell.exe'
|
|
38
|
-
else
|
|
39
|
-
'c:\windows\sysnative\windowspowershell\v1.0\powershell.exe'
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def wrap_command(script)
|
|
44
|
-
base_script_path = File.join(File.dirname(__FILE__), '/../../../support/hyperv.ps1')
|
|
45
|
-
debug("Loading functions from #{base_script_path}")
|
|
46
|
-
new_script = ". #{base_script_path}; " << script
|
|
47
|
-
debug("Wrapped script: #{new_script}")
|
|
48
|
-
"#{powershell_64_bit} -encodedcommand #{encode_command new_script} -outputformat Text"
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# Convenience method to run a powershell command locally.
|
|
52
|
-
#
|
|
53
|
-
# @param cmd [String] command to run locally
|
|
54
|
-
# @param options [Hash] options hash
|
|
55
|
-
# @see Kitchen::ShellOut.run_command
|
|
56
|
-
# @api private
|
|
57
|
-
def run_ps(cmd, options = {})
|
|
58
|
-
cmd = "echo #{cmd}" if config[:dry_run]
|
|
59
|
-
debug('Preparing to run: ')
|
|
60
|
-
debug(" #{cmd}")
|
|
61
|
-
wrapped_command = wrap_command cmd
|
|
62
|
-
execute_command wrapped_command, options
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# rubocop:disable Metrics/AbcSize
|
|
66
|
-
def execute_command(cmd, options = {})
|
|
67
|
-
debug("#Local Command BEGIN (#{cmd})")
|
|
68
|
-
sh = Mixlib::ShellOut.new(cmd, options)
|
|
69
|
-
sh.run_command
|
|
70
|
-
debug("Local Command END #{Util.duration(sh.execution_time)}")
|
|
71
|
-
fail "Failed: #{sh.stderr}" if sh.error?
|
|
72
|
-
JSON.parse(sh.stdout) if sh.stdout.length > 2
|
|
73
|
-
end
|
|
74
|
-
# rubocop:enable Metrics/AbcSize
|
|
75
|
-
|
|
76
|
-
def new_differencing_disk_ps
|
|
77
|
-
<<-DIFF
|
|
78
|
-
|
|
79
|
-
New-DifferencingDisk -Path "#{differencing_disk_path}" -ParentPath "#{parent_vhd_path}"
|
|
80
|
-
DIFF
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def ensure_vm_running_ps
|
|
84
|
-
<<-RUNNING
|
|
85
|
-
|
|
86
|
-
Assert-VmRunning -ID "#{@state[:id]}" | ConvertTo-Json
|
|
87
|
-
RUNNING
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
# rubocop:disable Metrics/MethodLength
|
|
91
|
-
def new_vm_ps
|
|
92
|
-
<<-NEWVM
|
|
93
|
-
|
|
94
|
-
$NewVMParams = @{
|
|
95
|
-
Generation = #{config[:vm_generation]}
|
|
96
|
-
MemoryStartupBytes = #{config[:memory_startup_bytes]}
|
|
97
|
-
Name = "#{instance.name}"
|
|
98
|
-
Path = "#{kitchen_vm_path}"
|
|
99
|
-
VHDPath = "#{differencing_disk_path}"
|
|
100
|
-
SwitchName = "#{config[:vm_switch]}"
|
|
101
|
-
ProcessorCount = #{config[:processor_count]}
|
|
102
|
-
UseDynamicMemory = "#{config[:dynamic_memory]}"
|
|
103
|
-
DynamicMemoryMinBytes = #{config[:dynamic_memory_min_bytes]}
|
|
104
|
-
DynamicMemoryMaxBytes = #{config[:dynamic_memory_max_bytes]}
|
|
105
|
-
}
|
|
106
|
-
New-KitchenVM @NewVMParams | ConvertTo-Json
|
|
107
|
-
NEWVM
|
|
108
|
-
end
|
|
109
|
-
# rubocop:enable Metrics/MethodLength
|
|
110
|
-
|
|
111
|
-
def vm_details_ps
|
|
112
|
-
<<-DETAILS
|
|
113
|
-
|
|
114
|
-
Get-VmDetail -id "#{@state[:id]}" | ConvertTo-Json
|
|
115
|
-
DETAILS
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def delete_vm_ps
|
|
119
|
-
<<-REMOVE
|
|
120
|
-
|
|
121
|
-
$null = Get-VM -ID "#{@state[:id]}" |
|
|
122
|
-
Stop-VM -Force -TurnOff -PassThru |
|
|
123
|
-
Remove-VM -Force
|
|
124
|
-
REMOVE
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
def set_vm_ipaddress_ps
|
|
128
|
-
<<-VMIP
|
|
129
|
-
|
|
130
|
-
(Get-VM -id "#{@state[:id]}").NetworkAdapters |
|
|
131
|
-
Set-VMNetworkConfiguration -ipaddress "#{config[:ip_address]}"
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
end
|
|
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 PowerShellScripts
|
|
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
|
+
os_arch == 'AMD64'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def powershell_64_bit
|
|
36
|
+
if is_64bit?
|
|
37
|
+
'c:\windows\system32\windowspowershell\v1.0\powershell.exe'
|
|
38
|
+
else
|
|
39
|
+
'c:\windows\sysnative\windowspowershell\v1.0\powershell.exe'
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def wrap_command(script)
|
|
44
|
+
base_script_path = File.join(File.dirname(__FILE__), '/../../../support/hyperv.ps1')
|
|
45
|
+
debug("Loading functions from #{base_script_path}")
|
|
46
|
+
new_script = ". #{base_script_path}; " << script
|
|
47
|
+
debug("Wrapped script: #{new_script}")
|
|
48
|
+
"#{powershell_64_bit} -noprofile -encodedcommand #{encode_command new_script} -outputformat Text"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Convenience method to run a powershell command locally.
|
|
52
|
+
#
|
|
53
|
+
# @param cmd [String] command to run locally
|
|
54
|
+
# @param options [Hash] options hash
|
|
55
|
+
# @see Kitchen::ShellOut.run_command
|
|
56
|
+
# @api private
|
|
57
|
+
def run_ps(cmd, options = {})
|
|
58
|
+
cmd = "echo #{cmd}" if config[:dry_run]
|
|
59
|
+
debug('Preparing to run: ')
|
|
60
|
+
debug(" #{cmd}")
|
|
61
|
+
wrapped_command = wrap_command cmd
|
|
62
|
+
execute_command wrapped_command, options
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# rubocop:disable Metrics/AbcSize
|
|
66
|
+
def execute_command(cmd, options = {})
|
|
67
|
+
debug("#Local Command BEGIN (#{cmd})")
|
|
68
|
+
sh = Mixlib::ShellOut.new(cmd, options)
|
|
69
|
+
sh.run_command
|
|
70
|
+
debug("Local Command END #{Util.duration(sh.execution_time)}")
|
|
71
|
+
fail "Failed: #{sh.stderr}" if sh.error?
|
|
72
|
+
JSON.parse(sh.stdout) if sh.stdout.length > 2
|
|
73
|
+
end
|
|
74
|
+
# rubocop:enable Metrics/AbcSize
|
|
75
|
+
|
|
76
|
+
def new_differencing_disk_ps
|
|
77
|
+
<<-DIFF
|
|
78
|
+
|
|
79
|
+
New-DifferencingDisk -Path "#{differencing_disk_path}" -ParentPath "#{parent_vhd_path}"
|
|
80
|
+
DIFF
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def ensure_vm_running_ps
|
|
84
|
+
<<-RUNNING
|
|
85
|
+
|
|
86
|
+
Assert-VmRunning -ID "#{@state[:id]}" | ConvertTo-Json
|
|
87
|
+
RUNNING
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# rubocop:disable Metrics/MethodLength
|
|
91
|
+
def new_vm_ps
|
|
92
|
+
<<-NEWVM
|
|
93
|
+
|
|
94
|
+
$NewVMParams = @{
|
|
95
|
+
Generation = #{config[:vm_generation]}
|
|
96
|
+
MemoryStartupBytes = #{config[:memory_startup_bytes]}
|
|
97
|
+
Name = "#{instance.name}"
|
|
98
|
+
Path = "#{kitchen_vm_path}"
|
|
99
|
+
VHDPath = "#{differencing_disk_path}"
|
|
100
|
+
SwitchName = "#{config[:vm_switch]}"
|
|
101
|
+
ProcessorCount = #{config[:processor_count]}
|
|
102
|
+
UseDynamicMemory = "#{config[:dynamic_memory]}"
|
|
103
|
+
DynamicMemoryMinBytes = #{config[:dynamic_memory_min_bytes]}
|
|
104
|
+
DynamicMemoryMaxBytes = #{config[:dynamic_memory_max_bytes]}
|
|
105
|
+
}
|
|
106
|
+
New-KitchenVM @NewVMParams | ConvertTo-Json
|
|
107
|
+
NEWVM
|
|
108
|
+
end
|
|
109
|
+
# rubocop:enable Metrics/MethodLength
|
|
110
|
+
|
|
111
|
+
def vm_details_ps
|
|
112
|
+
<<-DETAILS
|
|
113
|
+
|
|
114
|
+
Get-VmDetail -id "#{@state[:id]}" | ConvertTo-Json
|
|
115
|
+
DETAILS
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def delete_vm_ps
|
|
119
|
+
<<-REMOVE
|
|
120
|
+
|
|
121
|
+
$null = Get-VM -ID "#{@state[:id]}" |
|
|
122
|
+
Stop-VM -Force -TurnOff -PassThru |
|
|
123
|
+
Remove-VM -Force
|
|
124
|
+
REMOVE
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def set_vm_ipaddress_ps
|
|
128
|
+
<<-VMIP
|
|
129
|
+
|
|
130
|
+
(Get-VM -id "#{@state[:id]}").NetworkAdapters |
|
|
131
|
+
Set-VMNetworkConfiguration -ipaddress "#{config[:ip_address]}" `
|
|
132
|
+
-subnet "#{config[:subnet]}" `
|
|
133
|
+
-gateway "#{config[:gateway]}" `
|
|
134
|
+
-dnsservers #{ruby_array_to_ps_array(config[:dns_servers])} |
|
|
135
|
+
ConvertTo-Json
|
|
136
|
+
VMIP
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def vm_default_switch_ps
|
|
140
|
+
<<-VMSWITCH
|
|
141
|
+
Get-DefaultVMSwitch | ConvertTo-Json
|
|
142
|
+
VMSWITCH
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def mount_vm_iso
|
|
146
|
+
<<-MOUNTISO
|
|
147
|
+
mount-vmiso -id "#{@state[:id]}" -Path #{config[:iso_path]}
|
|
148
|
+
MOUNTISO
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def copy_vm_file_ps(source, dest)
|
|
152
|
+
<<-FILECOPY
|
|
153
|
+
Function CopyFile ($VM, [string]$SourcePath, [string]$DestPath) {
|
|
154
|
+
#Write-Host "Copying file to VM - Source: $SourcePath Destination $DestPath"
|
|
155
|
+
$VM | Copy-VMFile -SourcePath $SourcePath -DestinationPath $DestPath -CreateFullPath -FileSource Host -Force
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
$sourceLocation = '#{source}'
|
|
159
|
+
$destinationLocation = '#{dest}'
|
|
160
|
+
$vmId = '#{@state[:id]}'
|
|
161
|
+
If (Test-Path $sourceLocation) {
|
|
162
|
+
$vm = Get-VM -ID $vmId
|
|
163
|
+
$service = 'Guest Service Interface'
|
|
164
|
+
|
|
165
|
+
If ((Get-VMIntegrationService -Name $service -VM $vm).Enabled -ne $true) {
|
|
166
|
+
Enable-VMIntegrationService -Name $service -VM $vm
|
|
167
|
+
Start-Sleep -Seconds 3
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
If ((Get-Item $sourceLocation) -is [System.IO.DirectoryInfo]) {
|
|
171
|
+
ForEach ($item in (Get-ChildItem -Path $sourceLocation -File)) {
|
|
172
|
+
$destFullPath = (Join-Path $destinationLocation $item.Name)
|
|
173
|
+
CopyFile $vm $item.FullName $destFullPath
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
Else {
|
|
177
|
+
CopyFile $vm $sourceLocation $destinationLocation
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
Write-Error "Source file path does not exist: $sourceLocation"
|
|
182
|
+
}
|
|
183
|
+
FILECOPY
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
private
|
|
187
|
+
|
|
188
|
+
def ruby_array_to_ps_array(list)
|
|
189
|
+
return "@()" if list.nil? || list.empty?
|
|
190
|
+
list.to_s.tr('[]','()').prepend('@')
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Author:: Fletcher (<fnichol@nichol.ca>)
|
|
4
|
-
#
|
|
5
|
-
# Copyright (C) 2015, Fletcher Nichol
|
|
6
|
-
#
|
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
# you may not use this file except in compliance with the License.
|
|
9
|
-
# You may obtain a copy of the License at
|
|
10
|
-
#
|
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
#
|
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
# See the License for the specific language governing permissions and
|
|
17
|
-
# limitations under the License.
|
|
18
|
-
|
|
19
|
-
require_relative "../../spec_helper"
|
|
20
|
-
|
|
21
|
-
require "logger"
|
|
22
|
-
require "stringio"
|
|
23
|
-
require "kitchen"
|
|
24
|
-
require 'kitchen/driver/hyperv_version'
|
|
25
|
-
require "kitchen/driver/hyperv"
|
|
26
|
-
require "kitchen/provisioner/dummy"
|
|
27
|
-
require "kitchen/transport/dummy"
|
|
28
|
-
require "kitchen/verifier/dummy"
|
|
29
|
-
|
|
30
|
-
describe Kitchen::Driver::Hyperv do
|
|
31
|
-
|
|
32
|
-
let(:logged_output) { StringIO.new }
|
|
33
|
-
let(:logger) { Logger.new(logged_output) }
|
|
34
|
-
let(:config) { { :kitchen_root => "c:/test_root" } }
|
|
35
|
-
let(:platform) { Kitchen::Platform.new(:name => "fooos-99") }
|
|
36
|
-
let(:suite) { Kitchen::Suite.new(:name => "suitey") }
|
|
37
|
-
let(:verifier) { Kitchen::Verifier::Dummy.new }
|
|
38
|
-
let(:provisioner) { Kitchen::Provisioner::Dummy.new }
|
|
39
|
-
let(:transport) { Kitchen::Transport::Dummy.new }
|
|
40
|
-
let(:state_file) { stub("state_file") }
|
|
41
|
-
let(:state) { Hash.new }
|
|
42
|
-
let(:env) { Hash.new }
|
|
43
|
-
|
|
44
|
-
let(:driver_object) { Kitchen::Driver::Hyperv.new(config) }
|
|
45
|
-
|
|
46
|
-
let(:driver) do
|
|
47
|
-
d = driver_object
|
|
48
|
-
instance
|
|
49
|
-
d
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
let(:instance) do
|
|
53
|
-
Kitchen::Instance.new(
|
|
54
|
-
:verifier => verifier,
|
|
55
|
-
:driver => driver_object,
|
|
56
|
-
:logger => logger,
|
|
57
|
-
:suite => suite,
|
|
58
|
-
:platform => platform,
|
|
59
|
-
:provisioner => provisioner,
|
|
60
|
-
:transport => transport,
|
|
61
|
-
:state_file => state_file
|
|
62
|
-
)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
#before { stub_const("ENV", env) }
|
|
66
|
-
|
|
67
|
-
it 'driver api_version is 2' do
|
|
68
|
-
driver.diagnose_plugin[:api_version].must_equal(2)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Author:: Fletcher (<fnichol@nichol.ca>)
|
|
4
|
+
#
|
|
5
|
+
# Copyright (C) 2015, Fletcher Nichol
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
|
|
19
|
+
require_relative "../../spec_helper"
|
|
20
|
+
|
|
21
|
+
require "logger"
|
|
22
|
+
require "stringio"
|
|
23
|
+
require "kitchen"
|
|
24
|
+
require 'kitchen/driver/hyperv_version'
|
|
25
|
+
require "kitchen/driver/hyperv"
|
|
26
|
+
require "kitchen/provisioner/dummy"
|
|
27
|
+
require "kitchen/transport/dummy"
|
|
28
|
+
require "kitchen/verifier/dummy"
|
|
29
|
+
|
|
30
|
+
describe Kitchen::Driver::Hyperv do
|
|
31
|
+
|
|
32
|
+
let(:logged_output) { StringIO.new }
|
|
33
|
+
let(:logger) { Logger.new(logged_output) }
|
|
34
|
+
let(:config) { { :kitchen_root => "c:/test_root" } }
|
|
35
|
+
let(:platform) { Kitchen::Platform.new(:name => "fooos-99") }
|
|
36
|
+
let(:suite) { Kitchen::Suite.new(:name => "suitey") }
|
|
37
|
+
let(:verifier) { Kitchen::Verifier::Dummy.new }
|
|
38
|
+
let(:provisioner) { Kitchen::Provisioner::Dummy.new }
|
|
39
|
+
let(:transport) { Kitchen::Transport::Dummy.new }
|
|
40
|
+
let(:state_file) { stub("state_file") }
|
|
41
|
+
let(:state) { Hash.new }
|
|
42
|
+
let(:env) { Hash.new }
|
|
43
|
+
|
|
44
|
+
let(:driver_object) { Kitchen::Driver::Hyperv.new(config) }
|
|
45
|
+
|
|
46
|
+
let(:driver) do
|
|
47
|
+
d = driver_object
|
|
48
|
+
instance
|
|
49
|
+
d
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
let(:instance) do
|
|
53
|
+
Kitchen::Instance.new(
|
|
54
|
+
:verifier => verifier,
|
|
55
|
+
:driver => driver_object,
|
|
56
|
+
:logger => logger,
|
|
57
|
+
:suite => suite,
|
|
58
|
+
:platform => platform,
|
|
59
|
+
:provisioner => provisioner,
|
|
60
|
+
:transport => transport,
|
|
61
|
+
:state_file => state_file
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
#before { stub_const("ENV", env) }
|
|
66
|
+
|
|
67
|
+
it 'driver api_version is 2' do
|
|
68
|
+
driver.diagnose_plugin[:api_version].must_equal(2)
|
|
69
|
+
end
|
|
70
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
|
4
|
-
#
|
|
5
|
-
# Copyright (C) 2012, Fletcher Nichol
|
|
6
|
-
#
|
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
# you may not use this file except in compliance with the License.
|
|
9
|
-
# You may obtain a copy of the License at
|
|
10
|
-
#
|
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
#
|
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
# See the License for the specific language governing permissions and
|
|
17
|
-
# limitations under the License.
|
|
18
|
-
|
|
19
|
-
gem "minitest"
|
|
20
|
-
gem "minitest-stub-const"
|
|
21
|
-
|
|
22
|
-
if ENV["CODECLIMATE_REPO_TOKEN"]
|
|
23
|
-
require "codeclimate-test-reporter"
|
|
24
|
-
CodeClimate::TestReporter.start
|
|
25
|
-
elsif ENV["COVERAGE"]
|
|
26
|
-
require "simplecov"
|
|
27
|
-
SimpleCov.profiles.define "gem" do
|
|
28
|
-
command_name "Specs"
|
|
29
|
-
|
|
30
|
-
add_filter ".gem/"
|
|
31
|
-
add_filter "/spec/"
|
|
32
|
-
add_filter "/lib/vendor/"
|
|
33
|
-
|
|
34
|
-
add_group "Libraries", "/lib/"
|
|
35
|
-
end
|
|
36
|
-
SimpleCov.start "gem"
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
require 'minitest'
|
|
40
|
-
require 'minitest/stub_const'
|
|
41
|
-
require "minitest/autorun"
|
|
42
|
-
require "mocha/setup"
|
|
43
|
-
require "tempfile"
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
|
4
|
+
#
|
|
5
|
+
# Copyright (C) 2012, Fletcher Nichol
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
|
|
19
|
+
gem "minitest"
|
|
20
|
+
gem "minitest-stub-const"
|
|
21
|
+
|
|
22
|
+
if ENV["CODECLIMATE_REPO_TOKEN"]
|
|
23
|
+
require "codeclimate-test-reporter"
|
|
24
|
+
CodeClimate::TestReporter.start
|
|
25
|
+
elsif ENV["COVERAGE"]
|
|
26
|
+
require "simplecov"
|
|
27
|
+
SimpleCov.profiles.define "gem" do
|
|
28
|
+
command_name "Specs"
|
|
29
|
+
|
|
30
|
+
add_filter ".gem/"
|
|
31
|
+
add_filter "/spec/"
|
|
32
|
+
add_filter "/lib/vendor/"
|
|
33
|
+
|
|
34
|
+
add_group "Libraries", "/lib/"
|
|
35
|
+
end
|
|
36
|
+
SimpleCov.start "gem"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
require 'minitest'
|
|
40
|
+
require 'minitest/stub_const'
|
|
41
|
+
require "minitest/autorun"
|
|
42
|
+
require "mocha/setup"
|
|
43
|
+
require "tempfile"
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
. $PSScriptRoot\..\..\support\hyperv.ps1
|
|
2
|
-
|
|
1
|
+
. $PSScriptRoot\..\..\support\hyperv.ps1
|
|
2
|
+
|
data/support/hyperv.ps1
CHANGED
|
@@ -113,6 +113,8 @@ Function Set-VMNetworkConfiguration
|
|
|
113
113
|
[parameter(valuefrompipeline)]
|
|
114
114
|
[object]$NetworkAdapter,
|
|
115
115
|
[String[]]$IPAddress = @(),
|
|
116
|
+
[String[]]$Gateway = @(),
|
|
117
|
+
[String[]]$DNSServers = @(),
|
|
116
118
|
[String[]]$Subnet = @()
|
|
117
119
|
)
|
|
118
120
|
|
|
@@ -134,6 +136,8 @@ Function Set-VMNetworkConfiguration
|
|
|
134
136
|
}
|
|
135
137
|
|
|
136
138
|
$NetworkSettings[0].IPAddresses = $IPAddress
|
|
139
|
+
$NetworkSettings[0].DefaultGateways = $Gateway
|
|
140
|
+
$NetworkSettings[0].DNSServers = $DNSServers
|
|
137
141
|
$NetworkSettings[0].Subnets = $Subnet
|
|
138
142
|
$NetworkSettings[0].ProtocolIFType = 4096
|
|
139
143
|
$NetworkSettings[0].DHCPEnabled = $false
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kitchen-hyperv
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.20
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Steven Murawski
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-05-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
165
165
|
version: '0'
|
|
166
166
|
requirements: []
|
|
167
167
|
rubyforge_project:
|
|
168
|
-
rubygems_version: 2.
|
|
168
|
+
rubygems_version: 2.6.3
|
|
169
169
|
signing_key:
|
|
170
170
|
specification_version: 4
|
|
171
171
|
summary: Hyper-V Driver for Test-Kitchen
|