mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Feature #3518: Add IP column to onevm list
This commit is contained in:
parent
c2f6b2a3e7
commit
97515e6da3
@ -44,6 +44,11 @@
|
||||
:desc: Time since the VM was submitted
|
||||
:size: 10
|
||||
|
||||
:IP:
|
||||
:desc: VM IP addresses
|
||||
:left: true
|
||||
:size: 15
|
||||
|
||||
:default:
|
||||
- :ID
|
||||
- :USER
|
||||
|
@ -123,6 +123,45 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
||||
return short_state_str
|
||||
end
|
||||
|
||||
# Return the IP or several IPs of a VM
|
||||
def self.ip_str(vm)
|
||||
ips = []
|
||||
|
||||
vm_nics = []
|
||||
|
||||
if !vm["TEMPLATE"]["NIC"].nil?
|
||||
vm_nics = [vm["TEMPLATE"]['NIC']].flatten
|
||||
end
|
||||
|
||||
vm_nics.each do |nic|
|
||||
if nic.has_key?("IP")
|
||||
ips.push(nic["IP"])
|
||||
end
|
||||
|
||||
if nic.has_key?("IP6_GLOBAL")
|
||||
ips.push(nic["IP6_GLOBAL"])
|
||||
end
|
||||
|
||||
if nic.has_key?("IP6_ULA")
|
||||
ips.push(nic["IP6_ULA"])
|
||||
end
|
||||
end
|
||||
|
||||
VirtualMachine::EXTERNAL_IP_ATTRS.each do |attr|
|
||||
external_ip = vm["TEMPLATE"][attr]
|
||||
|
||||
if !external_ip.nil? && !ips.include?(external_ip)
|
||||
ips.push(external_ip)
|
||||
end
|
||||
end
|
||||
|
||||
if ips.empty?
|
||||
return "--"
|
||||
else
|
||||
return ips.join(",")
|
||||
end
|
||||
end
|
||||
|
||||
def format_pool(options)
|
||||
config_file = self.class.table_conf
|
||||
|
||||
@ -208,6 +247,10 @@ class OneVMHelper < OpenNebulaHelper::OneHelper
|
||||
OpenNebulaHelper.period_to_str(dtime, false)
|
||||
end
|
||||
|
||||
column :IP, "VM IP addresses", :left, :donottruncate, :size=>15 do |d|
|
||||
OneVMHelper.ip_str(d)
|
||||
end
|
||||
|
||||
default :ID, :USER, :GROUP, :NAME, :STAT, :UCPU, :UMEM, :HOST,
|
||||
:TIME
|
||||
end
|
||||
|
@ -118,6 +118,13 @@ module OpenNebula
|
||||
delete-recreate reboot reboot-hard resched unresched poweroff
|
||||
poweroff-hard}
|
||||
|
||||
EXTERNAL_IP_ATTRS = [
|
||||
'GUEST_IP',
|
||||
'AWS_IP_ADDRESS',
|
||||
'AZ_IPADDRESS',
|
||||
'SL_PRIMARYIPADDRESS'
|
||||
]
|
||||
|
||||
# Creates a VirtualMachine description with just its identifier
|
||||
# this method should be used to create plain VirtualMachine objects.
|
||||
# +id+ the id of the vm
|
||||
|
Loading…
x
Reference in New Issue
Block a user