Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kitchen Create fails with Undefined method [] for nil:NilClass #18

Closed
jbruettcva opened this issue Dec 1, 2015 · 7 comments
Closed

Comments

@jbruettcva
Copy link
Contributor

Chef Development Kit Version: 0.10.0
chef-client version: 12.5.1
berks version: 4.0.1
kitchen version: 1.4.2
Kitchen-Hyperv: 0.1.7 (donwloaded and installed manually from here)

.kitchen.yml


driver:
name: hyperv
parent_vhd_folder: C:/jbtemp/VMs/VHDs
memory_startup_bytes: 1073741824
vm_switch: external_wired
vm_generation: 2
processor_count: 2

transport:
username: Administrator
password: ***************

provisioner:
name: chef_zero

verifier:
name: pester

platforms:

  • name: win2012r2-chef12
    driver_config:
    parent_vhd_name: 'w12r2_gold.vhdx'
    provisioner:
    require_chef_omnibus: 12.1

suites:

  • name: default
    run_list:
    • recipe[cva-dynamicmap::default]

[6|8:26 AM|+343ms] [...\cookbooks\cva-dynamicmap] [master|+13]

kitchen create
-----> Starting Kitchen (v1.4.2)
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/httpclient-2.6.0.1/lib/httpclient/webagent-cookie.rb:458: warning: a
lready initialized constant HTTPClient::CookieManager
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/httpclient-2.6.0.1/lib/httpclient/cookie.rb:8: warning: previous def
inition of CookieManager was here
-----> Creating ...
Checking for existing virtual machine.
Creating virtual machine for default-win2012r2-chef12.

------Exception-------
Class: Kitchen::ActionFailed

Message: Failed to complete #create action: [undefined method `[]' for nil:NilClass]

Please see .kitchen/logs/kitchen.log for more details
Also try running kitchen diagnose --all for configuration

@jbruettcva
Copy link
Contributor Author

kitchen diagnose --all is clean and kitchen.log is empty

@smurawski
Copy link
Contributor

It is likely an error with the PowerShell running behind the scenes. To see what that is run

kitchen create -l debug

and you'll get the debug output. If you can paste that here or in a gist, I can show you what powershell is running and we can run it interactively to see what error powershell is giving us.

I need to surface that better in the driver. :)

@jbruettcva
Copy link
Contributor Author

[2|11:59 AM|+15ms] [...\cookbooks\cva-dynamicmap] [master|+13]

kitchen create -l debug
-----> Starting Kitchen (v1.4.2)
D Berksfile found at C:/jbtemp/repos/chef-repo/cookbooks/cva-dynamicmap/Berksfile, loading Berkshelf
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/httpclient-2.6.0.1/lib/httpclient/webagent-cookie.rb:458: warning: a
lready initialized constant HTTPClient::CookieManager
C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/httpclient-2.6.0.1/lib/httpclient/cookie.rb:8: warning: previous def
inition of CookieManager was here
D Berkshelf 4.0.1 library loaded
D Winrm Transport requested, loading WinRM::Transport gem (~> 1.0)
D WinRM::Transport 1.0.2 library loaded
-----> Creating ...
Checking for existing virtual machine.
Creating virtual machine for default-win2012r2-chef12.
D Preparing to run:
D
$NewVMParams = @{
Generation = 2
MemoryStartupBytes = 1073741824
Name = "default-win2012r2-chef12"
Path = "C:/jbtemp/repos/chef-repo/cookbooks/cva-dynamicmap/.kitchen/default-win2012r2-chef12"
VHDPath = "C:/jbtemp/repos/chef-repo/cookbooks/cva-dynamicmap/.kitchen/default-win2012r2-chef12/diff.vhdx"
SwitchName = "external_wired"
ProcessorCount = 2
}
New-KitchenVM @NewVMParams | ConvertTo-Json

D Loading functions from C:/Users/jbruett/AppData/Local/chefdk/gem/ruby/2.1.0/gems/kitchen-hyperv-0.1.7/lib/kitchen
/driver/../../../support/hyperv.ps1
D Wrapped script: . C:/Users/jbruett/AppData/Local/chefdk/gem/ruby/2.1.0/gems/kitchen-hyperv-0.1.7/lib/kitchen/driv
er/../../../support/hyperv.ps1;
$NewVMParams = @{
Generation = 2
MemoryStartupBytes = 1073741824
Name = "default-win2012r2-chef12"
Path = "C:/jbtemp/repos/chef-repo/cookbooks/cva-dynamicmap/.kitchen/default-win2012r2-chef12"
VHDPath = "C:/jbtemp/repos/chef-repo/cookbooks/cva-dynamicmap/.kitchen/default-win2012r2-chef12/diff.vhdx"
SwitchName = "external_wired"
ProcessorCount = 2
}
New-KitchenVM @NewVMParams | ConvertTo-Json

D #Local Command BEGIN (c:\windows\system32\windowspowershell\v1.0\powershell.exe -encodedcommand LgAgAEMAOgAvAFUAc
wBlAHIAcwAvAGoAYgByAHUAZQB0AHQALwBBAHAAcABEAGEAdABhAC8ATABvAGMAYQBsAC8AYwBoAGUAZgBkAGsALwBnAGUAbQAvAHIAdQBiAHkALwAyAC4AM
QAuADAALwBnAGUAbQBzAC8AawBpAHQAYwBoAGUAbgAtAGgAeQBwAGUAcgB2AC0AMAAuADEALgA3AC8AbABpAGIALwBrAGkAdABjAGgAZQBuAC8AZAByAGkAd
gBlAHIALwAuAC4ALwAuAC4ALwAuAC4ALwBzAHUAcABwAG8AcgB0AC8AaAB5AHAAZQByAHYALgBwAHMAMQA7ACAACgAgACAAIAAgACAAIAAgACAAIAAgACQAT
gBlAHcAVgBNAFAAYQByAGEAbQBzACAAPQAgAEAAewAKACAAIAAgACAAIAAgACAAIAAgACAAIAAgAEcAZQBuAGUAcgBhAHQAaQBvAG4AIAA9ACAAMgAKACAAI
AAgACAAIAAgACAAIAAgACAAIAAgAE0AZQBtAG8AcgB5AFMAdABhAHIAdAB1AHAAQgB5AHQAZQBzACAAPQAgADEAMAA3ADMANwA0ADEAOAAyADQACgAgACAAI
AAgACAAIAAgACAAIAAgACAAIABOAGEAbQBlACAAPQAgACIAZABlAGYAYQB1AGwAdAAtAHcAaQBuADIAMAAxADIAcgAyAC0AYwBoAGUAZgAxADIAIgAKACAAI
AAgACAAIAAgACAAIAAgACAAIAAgAFAAYQB0AGgAIAA9ACAAIgBDADoALwBqAGIAdABlAG0AcAAvAHIAZQBwAG8AcwAvAGMAaABlAGYALQByAGUAcABvAC8AY
wBvAG8AawBiAG8AbwBrAHMALwBjAHYAYQAtAGQAeQBuAGEAbQBpAGMAbQBhAHAALwAuAGsAaQB0AGMAaABlAG4ALwBkAGUAZgBhAHUAbAB0AC0AdwBpAG4AM
gAwADEAMgByADIALQBjAGgAZQBmADEAMgAiAAoAIAAgACAAIAAgACAAIAAgACAAIAAgACAAVgBIAEQAUABhAHQAaAAgAD0AIAAiAEMAOgAvAGoAYgB0AGUAb
QBwAC8AcgBlAHAAbwBzAC8AYwBoAGUAZgAtAHIAZQBwAG8ALwBjAG8AbwBrAGIAbwBvAGsAcwAvAGMAdgBhAC0AZAB5AG4AYQBtAGkAYwBtAGEAcAAvAC4Aa
wBpAHQAYwBoAGUAbgAvAGQAZQBmAGEAdQBsAHQALQB3AGkAbgAyADAAMQAyAHIAMgAtAGMAaABlAGYAMQAyAC8AZABpAGYAZgAuAHYAaABkAHgAIgAKACAAI
AAgACAAIAAgACAAIAAgACAAIAAgAFMAdwBpAHQAYwBoAE4AYQBtAGUAIAA9ACAAIgBlAHgAdABlAHIAbgBhAGwAXwB3AGkAcgBlAGQAIgAKACAAIAAgACAAI
AAgACAAIAAgACAAIAAgAFAAcgBvAGMAZQBzAHMAbwByAEMAbwB1AG4AdAAgAD0AIAAyAAoAIAAgACAAIAAgACAAIAAgACAAIAB9AAoAIAAgACAAIAAgACAAI
AAgACAAIABOAGUAdwAtAEsAaQB0AGMAaABlAG4AVgBNACAAQABOAGUAdwBWAE0AUABhAHIAYQBtAHMAIAB8ACAAQwBvAG4AdgBlAHIAdABUAG8ALQBKAHMAb
wBuAAoA -outputformat Text)
D Local Command END (0m0.00s)

------Exception-------
Class: Kitchen::ActionFailed

Message: Failed to complete #create action: [undefined method `[]' for nil:NilClass]

Please see .kitchen/logs/kitchen.log for more details
Also try running kitchen diagnose --all for configuration

D ------Exception-------
D Class: Kitchen::ActionFailed
D Message: Failed to complete #create action: [undefined method []' for nil:NilClass] D ---Nested Exception--- D Class: NoMethodError D Message: undefined method[]' for nil:NilClass
D ------Backtrace-------
D C:/Users/jbruett/AppData/Local/chefdk/gem/ruby/2.1.0/gems/kitchen-hyperv-0.1.7/lib/kitchen/driver/hyperv.rb:132:i
n create_virtual_machine' D C:/Users/jbruett/AppData/Local/chefdk/gem/ruby/2.1.0/gems/kitchen-hyperv-0.1.7/lib/kitchen/driver/hyperv.rb:55:in create'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:424:in public_sen d' D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:424:inblock in p
erform_action'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:488:in call' D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:488:insynchroniz
e_or_call'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:453:in block in a ction' D C:/opscode/chefdk/embedded/lib/ruby/2.1.0/benchmark.rb:279:inmeasure'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:452:in action' D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:424:inperform_ac
tion'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:352:in create_act ion' D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:341:inblock in t
ransition_to'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:340:in each' D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:340:intransition
_to'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:127:in create' D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/command.rb:176:inpublic_send
'
D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/command.rb:176:in block (2 le vels) in run_action' D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:incall'

D C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block
in create_with_logging_context'
D ----------------------

@smurawski
Copy link
Contributor

@jbruettcva you'll want to run

. C:/Users/jbruett/AppData/Local/chefdk/gem/ruby/2.1.0/gems/kitchen-hyperv-0.1.7/lib/kitchen/driver/../../../support/hyperv.ps1;
$NewVMParams = @{
Generation = 2
MemoryStartupBytes = 1073741824
Name = "default-win2012r2-chef12"
Path = "C:/jbtemp/repos/chef-repo/cookbooks/cva-dynamicmap/.kitchen/default-win2012r2-chef12"
VHDPath = "C:/jbtemp/repos/chef-repo/cookbooks/cva-dynamicmap/.kitchen/default-win2012r2-chef12/diff.vhdx"
SwitchName = "external_wired"
ProcessorCount = 2
}
New-KitchenVM @NewVMParams | ConvertTo-Json

and see what the result is.

@jbruettcva
Copy link
Contributor Author

Running manually produced the following errors:

New-VM : A parameter cannot be found that matches parameter name 'SwitchName'.

Set-VMMemory : Cannot validate argument on parameter 'VMName'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.

Start-VM : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.

@jbruettcva
Copy link
Contributor Author

Running this:
. C:/Users/jbruett/AppData/Local/chefdk/gem/ruby/2.1.0/gems/kitchen-hyperv-0.1.7/lib/kitchen/driver/../../../support/hyperv.ps1;

New-KitchenVM
-name "default-win2012r2-chef12"
-path "C:/jbtemp/repos/chef-repo/cookbooks/cva-dynamicmap/.kitchen/default-win2012r2-chef12"
-vhdpath "C:/jbtemp/repos/chef-repo/cookbooks/cva-dynamicmap/.kitchen/default-win2012r2-chef12/diff.vhdx" -SwitchName "external_wired"
-ProcessorCount 2
-generation 2
-MemoryStartupBytes 1073741824

worked

@smurawski
Copy link
Contributor

closed via #19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants