Closed Brunzer closed 6 years ago
I took a look at the code for the find_network() method and there's a split occuring on "/", so it seems as though we could specify a path for the network in the field network_name rather than just the name of the network.
def find_network(name)
base = datacenter.networkFolder
entity_array = name.split("/").reject(&:empty?)
entity_array.each do |item|
case base
when RbVmomi::VIM::Folder
base = base.find(item)
when RbVmomi::VIM::VmwareDistributedVirtualSwitch
idx = base.summary.portgroupName.find_index(item)
base = idx.nil? ? nil : base.portgroup[idx]
end
end
raise "vSphere Network not found [#{name}]" if base.nil?
base
end
I tested that out by specifying `network_name = 'foldername/networkname'" and sure enough I was able to find the network in this case, though this raises another question.
What's the proper way to specify your network_name if it's located in a port group that is within a folder rather than at the root level? Technically the path in vsphere to my network would be 'folder_name/portgroup_name/network_name', but omitting the portgroup_name in my network_name ensured that the network was actually found.
I think we'll have to patch that find_network
method to get this fixed for you @Brunzer :(
If you'd like to take a shot at it and PR it I'd love to see it.
Versions:
Platform Details
Scenario:
Chef-provisioning runs cannot find the specified network if the distributed switch is not at the rootFolder. I have a folder which holds the distributed switch and then the networks under that switch. Provisioning continuously states that "vSphere Network not found"
Steps to Reproduce:
Create a folder in vSphere and place your distributed switch in it. Then create a network within that switch. Attempt a provisioning run using that network and it will fail when it attempts to find the network.
Expected Result:
Looking for a network in vsphere should traverse any folders until you get to the leaf object where the network(s) would be stored
Actual Result:
This seems similar to an issue from a while back with trying to find the Datacenter that is within a folder. That issue for reference was https://github.com/chef-partners/chef-provisioning-vsphere/issues/23