mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-25 23:21:29 +03:00
Fix the problem when trying to import a VM with guest.net.ipConfig attribute unset.
This commit is contained in:
parent
7a76cb85ab
commit
244a5ee737
@ -64,9 +64,10 @@ module VirtualMachineMonitor
|
||||
@monitor[:used_cpu] = 0 if @monitor[:used_cpu].to_i < 0
|
||||
|
||||
guest_ip_addresses = []
|
||||
if self['guest.net']
|
||||
unless self['guest.net'].empty?
|
||||
self['guest.net'].each do |net|
|
||||
next unless net.ipConfig && net.ipConfig.ipAddress
|
||||
next unless net.ipConfig
|
||||
next if net.ipConfig.ipAddress.empty?
|
||||
|
||||
net.ipConfig.ipAddress.each do |ip|
|
||||
guest_ip_addresses << ip.ipAddress
|
||||
@ -246,9 +247,10 @@ module VirtualMachineMonitor
|
||||
@monitor[:used_cpu] = 0 if @monitor[:used_cpu].to_i < 0
|
||||
|
||||
guest_ip_addresses = []
|
||||
if self['guest.net']
|
||||
unless self['guest.net'].empty?
|
||||
@vm_info['guest.net'].each do |net|
|
||||
next unless net.ipConfig && net.ipConfig.ipAddress
|
||||
next unless net.ipConfig
|
||||
next if net.ipConfig.ipAddress.empty?
|
||||
|
||||
net.ipConfig.ipAddress.each do |ip|
|
||||
guest_ip_addresses << ip.ipAddress
|
||||
|
@ -394,17 +394,21 @@ class Template
|
||||
network.info
|
||||
|
||||
# Iterate over Retrieve vCenter VM NICs
|
||||
vm_object.item.guest.net.each do |net|
|
||||
mac = net.macAddress
|
||||
if nic[:mac] == mac
|
||||
net.ipConfig.ipAddress.each do |ip_config|
|
||||
ip = IPAddr.new(ip_config.ipAddress)
|
||||
ar_array = network.to_hash['VNET']['AR_POOL']['AR']
|
||||
ar_array = [ar_array] if ar_array.is_a?(Hash)
|
||||
ipv4, ipv6 = find_ip_in_ar(ip, ar_array) if ar_array
|
||||
break if ipv4 !="" or ipv6 != ""
|
||||
unless vm_object.item.guest.net.empty?
|
||||
vm_object.item.guest.net.each do |net|
|
||||
mac = net.macAddress
|
||||
if nic[:mac] == mac
|
||||
next unless net.ipConfig
|
||||
next if net.ipConfig.ipAddress.empty?
|
||||
net.ipConfig.ipAddress.each do |ip_config|
|
||||
ip = IPAddr.new(ip_config.ipAddress)
|
||||
ar_array = network.to_hash['VNET']['AR_POOL']['AR']
|
||||
ar_array = [ar_array] if ar_array.is_a?(Hash)
|
||||
ipv4, ipv6 = find_ip_in_ar(ip, ar_array) if ar_array
|
||||
break if ipv4 !="" or ipv6 != ""
|
||||
end
|
||||
break
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
return ipv4, ipv6
|
||||
|
Loading…
Reference in New Issue
Block a user