-
Notifications
You must be signed in to change notification settings - Fork 124
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
vm vmdk add gets undefined method `each' for nil:NilClass (NoMethodError) #444
Comments
Hi, thanks for providing a stack trace. It looks like it's from the older 1.2.23 though, can you re-run using the latest and paste the stack trace please? |
Hi, WARNING: No knife configuration file found
DEBUG: value for config item vsphere_host: **************
DEBUG: value for config item vsphere_path: /sdk
DEBUG: value for config item vsphere_port: 443
DEBUG: value for config item vsphere_nossl:
DEBUG: value for config item vsphere_user: **************
DEBUG: value for config item vsphere_pass: **************
DEBUG: value for config item vsphere_pass: **************
DEBUG: value for config item vsphere_pass: **************
DEBUG: value for config item vsphere_insecure: true
DEBUG: value for config item proxy_host:
DEBUG: value for config item proxy_port:
DEBUG: value for config item folder:
DEBUG: value for config item vsphere_dc: QA and DEV
DEBUG: value for config item target_lun:
Datastore: K2-QA-3 (2.45 TB(2697227927552) / 8.00 TB)
Choosing: K2-QA-3
C:/Users/tfsagent/AppData/Local/chefdk/gem/ruby/2.4.0/gems/knife-vsphere-2.1.1/lib/chef/k
nife/vsphere_vm_vmdk_add.rb:86:in `block in run
':
undefined method `each' for nil:NilClass
(NoMethodError)
from C:/Users/tfsagent/AppData/Local/chefdk/gem/ruby/2.4.0/gems/knife-vsphere-2.1.1/lib/
chef/knife/vsphere_vm_vmdk_add.rb:85:in `each'
from C:/Users/tfsagent/AppData/Local/chefdk/gem/ruby/2.4.0/gems/knife-vsphere-2.1.1/lib/
chef/knife/vsphere_vm_vmdk_add.rb:85:in `run'
from C:/opscode/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4-universal-mingw32/l
ib/chef/knife.rb:442:in `block in run_with_pretty_exceptions'
from C:/opscode/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4-universal-mingw32/l
ib/chef/local_mode.rb:44:in `with_server_connectivity'
from C:/opscode/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4-universal-mingw32/l
ib/chef/knife.rb:441:in `run_with_pretty_exceptions'
from C:/opscode/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4-universal-mingw32/l
ib/chef/knife.rb:219:in `run'
from C:/opscode/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4-universal-mingw32/l
ib/chef/application/knife.rb:156:in `run'
from C:/opscode/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4-universal-mingw32/b
in/knife:25:in `<top (required)>'
from C:/opscode/chefdk/bin/knife:267:in `load'
from C:/opscode/chefdk/bin/knife:267:in `<main>' |
Thanks for the updated stack trace. It's dying in code like this: pc = vmdk_datastore._connection.serviceContent.propertyCollector
vms = vmdk_datastore.vm
vm_files = pc.collectMultiple vms, 'layoutEx.file'
vm_files.keys.each do |vmFile|
vm_files[vmFile]['layoutEx.file'].each do |layout|
if layout.name.match(/^\[#{vmdk_datastore.name}\] #{vmname}\/#{vmname}_([0-9]+).vmdk/)
num = Regexp.last_match(1)
next_vmdk = num.to_i + 1 if next_vmdk <= num.to_i
end
end
end Here's it's finding all the VMs on the chosen datastore ( It seems that So two ideas to get you going:
Please let me know how this works out. |
The workaround works! changing (vm_files.keys || []).each do |vmFile| was not enough , i had to change this one also However, i don't think i understood what is the impact of this workaround ? We moved to this new vCenter few days ago and our provisioning worked for 2-3 first machines (same datastore was picked according to logs ) , the datastore itself was used before for testing and some machine creation before we moved.. so i can't say its really new. Thanks again for the quick response and solution and please let us know if we can keep it this way. |
Hi, the code as is makes certain assumptions that when it asks for files it gets back a list of files, but in your case, it's getting nothing and then treating that nothing as if it were a list of zero files. That The changes will go away if you update. I'll try to understand what's happening here and come up with a cleaner way of doing it. That section of code happens to be on my hit list as it's asking VMWare for all the files on all the VMs on the datastore, only to filter out for the ones to do with the VM it already has. There has to be a more efficient way. |
Worked few days ago but now we came across this issue, tried new version , old but nothing really helps , appreciate your assistance.
Versions:
Platform Details
Scenario:
knife vsphere vm vmdk add
Please paste the command and output (run with
-VV
). Don't forget to X out any passwords or sensitive information:2018-07-17T16:36:58.5881285Z INFO: Using configuration from D:/Agents/Agent2/_work/87/s/knife.rb
'2018-07-17T16:36:58.6662514Z DEBUG: value for config item vsphere_host: *******
2018-07-17T16:36:58.6662514Z DEBUG: value for config item vsphere_path: /sdk
2018-07-17T16:36:58.6662514Z DEBUG: value for config item vsphere_port: 443
2018-07-17T16:36:58.6662514Z DEBUG: value for config item vsphere_nossl:
2018-07-17T16:36:58.6662514Z DEBUG: value for config item vsphere_user: ********
2018-07-17T16:36:58.6662514Z DEBUG: value for config item vsphere_pass: ********
2018-07-17T16:36:58.6662514Z DEBUG: value for config item vsphere_pass: ********
2018-07-17T16:36:58.6662514Z DEBUG: value for config item vsphere_pass: ********
2018-07-17T16:36:58.6662514Z DEBUG: value for config item vsphere_insecure: true
2018-07-17T16:36:58.6662514Z DEBUG: value for config item proxy_host:
2018-07-17T16:36:58.6662514Z DEBUG: value for config item proxy_port:
2018-07-17T16:36:58.9687282Z DEBUG: value for config item folder:
2018-07-17T16:36:58.9687282Z DEBUG: value for config item vsphere_dc: QA and DEV
2018-07-17T16:37:00.1574818Z DEBUG: value for config item target_lun:
2018-07-17T16:37:00.2325364Z Datastore: K2-QA-3 (2.45 TB(2697227927552) / 8.00 TB)
2018-07-17T16:37:00.2991042Z Choosing: K2-QA-3
2018-07-17T16:37:01.6030146Z C:/Users/tfsagent/AppData/Local/chefdk/gem/ruby/2.4.0/gems/knife-vsphere-1.2.23/lib/chef/knife/vsphere_vm_vmdk_add.rb:80:in
block in run': undefined method
each' for nil:NilClass (NoMethodError)2018-07-17T16:37:01.6030146Z from C:/Users/tfsagent/AppData/Local/chefdk/gem/ruby/2.4.0/gems/knife-vsphere-1.2.23/lib/chef/knife/vsphere_vm_vmdk_add.rb:79:in
each' 2018-07-17T16:37:01.6030146Z from C:/Users/tfsagent/AppData/Local/chefdk/gem/ruby/2.4.0/gems/knife-vsphere-1.2.23/lib/chef/knife/vsphere_vm_vmdk_add.rb:79:in
run'2018-07-17T16:37:01.6030146Z from C:/opscode/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4-universal-mingw32/lib/chef/knife.rb:442:in
block in run_with_pretty_exceptions' 2018-07-17T16:37:01.6030146Z from C:/opscode/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4-universal-mingw32/lib/chef/local_mode.rb:44:in
with_server_connectivity'2018-07-17T16:37:01.6030146Z from C:/opscode/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4-universal-mingw32/lib/chef/knife.rb:441:in
run_with_pretty_exceptions' 2018-07-17T16:37:01.6030146Z from C:/opscode/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4-universal-mingw32/lib/chef/knife.rb:219:in
run'2018-07-17T16:37:01.6030146Z from C:/opscode/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4-universal-mingw32/lib/chef/application/knife.rb:156:in
run' 2018-07-17T16:37:01.6030146Z from C:/opscode/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.6.4-universal-mingw32/bin/knife:25:in
<top (required)>'2018-07-17T16:37:01.6030146Z from C:/opscode/chefdk/bin/knife:267:in
load' 2018-07-17T16:37:01.6030146Z from C:/opscode/chefdk/bin/knife:267:in
The text was updated successfully, but these errors were encountered: