mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-29 18:50:08 +03:00
feature #4014: show extra IP's in onevm show
Also fixes bug #4013 (cherry picked from commit 04cae02b1253aa3a1e70850ec4e8384cb66901cc)
This commit is contained in:
parent
8f0c8ce6ea
commit
cafdbade92
@ -701,7 +701,23 @@ in the frontend machine.
|
||||
end
|
||||
end
|
||||
|
||||
if vm.has_elements?("/VM/TEMPLATE/NIC") and !isHybrid
|
||||
# This variable holds the extra IP's got from monitoring. Right
|
||||
# now it adds GUEST_IP and GUEST_IP_ADDRESSES from vcenter
|
||||
# monitoring. If other variables hold IPs just add them to this
|
||||
# array. Duplicate IPs are not shown.
|
||||
extra_ips = []
|
||||
|
||||
if val=vm["/VM/MONITORING/GUEST_IP"]
|
||||
extra_ips << val if val && !val.empty?
|
||||
end
|
||||
|
||||
if val=vm["/VM/MONITORING/GUEST_IP_ADDRESSES"]
|
||||
extra_ips += val.split(',') if val && !val.empty?
|
||||
end
|
||||
|
||||
extra_ips.uniq!
|
||||
|
||||
if vm.has_elements?("/VM/TEMPLATE/NIC") || !extra_ips.empty?
|
||||
puts
|
||||
CLIHelper.print_header(str_h1 % "VM NICS",false)
|
||||
|
||||
@ -711,13 +727,17 @@ in the frontend machine.
|
||||
"VLAN"=>"no",
|
||||
"BRIDGE"=>"-"}
|
||||
|
||||
shown_ips = []
|
||||
|
||||
array_id = 0
|
||||
vm_nics = [vm.to_hash['VM']['TEMPLATE']['NIC']].flatten
|
||||
vm_nics = [vm.to_hash['VM']['TEMPLATE']['NIC']].flatten.compact
|
||||
vm_nics.each {|nic|
|
||||
|
||||
next if nic.has_key?("CLI_DONE")
|
||||
|
||||
if nic.has_key?("IP6_LINK")
|
||||
shown_ips << nic["IP6_LINK"]
|
||||
|
||||
ip6_link = {"IP" => nic.delete("IP6_LINK"),
|
||||
"CLI_DONE" => true,
|
||||
"DOUBLE_ENTRY" => true}
|
||||
@ -727,6 +747,8 @@ in the frontend machine.
|
||||
end
|
||||
|
||||
if nic.has_key?("IP6_ULA")
|
||||
shown_ips << nic["IP6_ULA"]
|
||||
|
||||
ip6_link = {"IP" => nic.delete("IP6_ULA"),
|
||||
"CLI_DONE" => true,
|
||||
"DOUBLE_ENTRY" => true}
|
||||
@ -736,6 +758,8 @@ in the frontend machine.
|
||||
end
|
||||
|
||||
if nic.has_key?("IP6_GLOBAL")
|
||||
shown_ips << nic["IP6_GLOBAL"]
|
||||
|
||||
ip6_link = {"IP" => nic.delete("IP6_GLOBAL"),
|
||||
"CLI_DONE" => true,
|
||||
"DOUBLE_ENTRY" => true}
|
||||
@ -744,10 +768,25 @@ in the frontend machine.
|
||||
array_id += 1
|
||||
end
|
||||
|
||||
shown_ips << nic["IP"] if nic.has_key?("IP")
|
||||
|
||||
nic.merge!(nic_default) {|k,v1,v2| v1}
|
||||
array_id += 1
|
||||
}
|
||||
|
||||
extra_ips -= shown_ips
|
||||
|
||||
# Add extra IPs to the VM NICS table
|
||||
extra_ips.each do |ip|
|
||||
vm_nics << {
|
||||
"NIC_ID" => "-",
|
||||
"IP" => ip,
|
||||
"NETWORK" => "Additional IP",
|
||||
"BRIDGE" => "-",
|
||||
"VLAN" => "-"
|
||||
}
|
||||
end
|
||||
|
||||
CLIHelper::ShowTable.new(nil, self) do
|
||||
column :ID, "", :size=>3 do |d|
|
||||
if d["DOUBLE_ENTRY"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user