mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Minor fixes in vCenter driver
(cherry picked from commit ea017e54de61d9c9806e29f89fa329a83f16a194)
This commit is contained in:
parent
0e34cd4f81
commit
6665d41f2a
@ -614,7 +614,9 @@ class Template
|
||||
|
||||
def get_vcenter_nics
|
||||
nics = []
|
||||
@item.config.hardware.device.each { |device| nics << device if is_nic?(device)}
|
||||
@item.config.hardware.device.each do |device|
|
||||
nics << device if is_nic?(device)
|
||||
end
|
||||
|
||||
nics
|
||||
end
|
||||
@ -622,12 +624,17 @@ class Template
|
||||
def retrieve_from_device(device)
|
||||
res = {}
|
||||
|
||||
# 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
|
||||
if device.backing.port.portKey.match(/^[a-z]+-\d+$/)
|
||||
# Lets find out if it is a standard or distributed network
|
||||
# If distributed, it needs to be instantiated from the ref
|
||||
vim_eth_dist_class =
|
||||
RbVmomi::VIM::VirtualEthernetCardDistributedVirtualPortBackingInfo
|
||||
|
||||
if device.backing.is_a? vim_eth_dist_class
|
||||
if device.backint.port.portKey &&
|
||||
device.backing.port.portKey.match(/^[a-z]+-\d+$/)
|
||||
ref = device.backing.port.portKey
|
||||
elsif device.backing.port.portgroupKey.match(/^[a-z]+-\d+$/)
|
||||
elsif device.backing.port.portgroupKey &&
|
||||
device.backing.port.portgroupKey.match(/^[a-z]+-\d+$/)
|
||||
ref = device.backing.port.portgroupKey
|
||||
else
|
||||
raise "Cannot get hold of Network for device #{device}"
|
||||
@ -668,7 +675,6 @@ class Template
|
||||
nics = []
|
||||
inets_raw = nil
|
||||
inets = {}
|
||||
num_device = 0
|
||||
@item["config.hardware.device"].each do |device|
|
||||
next unless is_nic?(device)
|
||||
|
||||
@ -680,7 +686,7 @@ class Template
|
||||
inets = parse_live.call(inets_raw) if inets.empty?
|
||||
|
||||
if !inets[nic[:mac]]
|
||||
ipAddresses = inets[nic[:mac]].ipConfig.ipAddress
|
||||
ipAddresses = inets[nic[:mac]].ipConfig.ipAddress rescue nil
|
||||
end
|
||||
|
||||
if !ipAddresses.nil? && !ipAddresses.empty?
|
||||
|
Loading…
x
Reference in New Issue
Block a user