1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-23 17:33:56 +03:00

Bug #5246: Allow Distributed vSwitches NICs in VM Templates

This commit is contained in:
Tino Vazquez 2017-09-06 12:19:36 +02:00
parent 7eae5ca594
commit e91177f9f6
2 changed files with 17 additions and 8 deletions

View File

@ -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"

View File

@ -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