diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/network.rb b/src/vmm_mad/remotes/lib/vcenter_driver/network.rb index 33a599c2f6..b61829bbba 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/network.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/network.rb @@ -123,7 +123,7 @@ class Network end def self.get_network_type(device) - if device.backing.network.instance_of?(RbVmomi::VIM::DistributedVirtualPortgroup) + if device.backing.is_a? RbVmomi::VIM::VirtualEthernetCardDistributedVirtualPortBackingInfo return "Distributed Port Group" else return "Port Group" diff --git a/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb b/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb index 38e966a1ed..82e1b826e0 100644 --- a/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb +++ b/src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb @@ -542,15 +542,24 @@ class Template def get_vcenter_nics nics = [] @item["config.hardware.device"].each do |device| - nic = {} + nic = {} + network = nil if is_nic?(device) - begin - nic[:net_name] = device.backing.network.name - nic[:net_ref] = device.backing.network._ref - nic[:pg_type] = VCenterDriver::Network.get_network_type(device) - nics << nic - rescue + + # Let's find out if it is a standard or distributed network + # If distributed, it needs to be instantitaed from the ref + if device.backing.is_a? RbVmomi::VIM::VirtualEthernetCardDistributedVirtualPortBackingInfo + ref = device.backing.port.portKey == "0" ? device.backing.port.portgroupKey : device.backing.port.portKey + network = RbVmomi::VIM::Network.new(@vi_client.vim, ref) + else + network = device.backing.network end + + nic[:net_name] = network.name + nic[:net_ref] = network._ref + nic[:pg_type] = VCenterDriver::Network.get_network_type(device) + + nics << nic end end return nics