CenturyLinkCloud / chef-provisioning-vsphere

A chef-provisioning provisioner for VMware vSphere
MIT License
66 stars 57 forks source link

vSphere Datacenter not found #112

Open danhiris opened 7 years ago

danhiris commented 7 years ago

I'm trying to converge but I keep getting a datacenter not found error. The datacenter is in a folder. I have a datacenter on a lab cluster that isn't in a specific folder, and everything works great.

Am I declaring the datacenter name correctly? Is this a bug that prevents the datacenter name from being set due to the folder structure?

screen shot 2017-05-08 at 4 09 41 pm

datacenter: 'USF Support Centers/1P - Phoenix NPC - QA'

------Exception------- Class: Kitchen::ActionFailed Message: 1 actions failed. Failed to complete #create action: [vSphere Datacenter not found [USF Support Centers/1P - Phoenix NPC - QA]] on default-redhat

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

UPDATE: I tested this from knife and the datacenter is found. For some reason this is not able to find the datacenter if it's under a folder structure.

I think this code has something to do with it:

rootFolder = vim.serviceInstance.content.rootFolder dc = rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter).find

When looking up data centers, folders should be traversed, not just doing a find on the rootFolder.

This is how knife vsphere does it:

  def traverse_folders_for_dc(folder, dcname)
    children = folder.children.find_all
    children.each do |child|
      if child.class == RbVmomi::VIM::Datacenter && child.name == dcname
        return child
      elsif child.class == RbVmomi::VIM::Folder
        dc = traverse_folders_for_dc(child, dcname)
        return dc if dc
      end
    end
jjasghar commented 7 years ago

Hi! If you're still interested in getting this looked at, please close and reopen this issue against the new maintainers at https://github.com/chef-partners/chef-provisioning-vsphere.

We are in the process of reinvigorating this project and look forward to many collaborations in the future!

Thanks for your time and issue! We have a few updates already, and it would be nice to have everything in one location.

Oh! We also are on the VMware{Code} slack team in #chef if you'd ever like to come by and say hi!