1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-25 23:21:29 +03:00

B #3563: Fix VM import (#3609)

Fix the problem when trying to import a VM with
guest.net.ipConfig attribute unset.
This commit is contained in:
Angel Luis Moya Gonzalez 2019-08-22 14:09:44 +02:00 committed by Tino Vázquez
parent 7a76cb85ab
commit 244a5ee737
2 changed files with 20 additions and 14 deletions

View File

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

View File

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