A column with VM IP addresses shown via 'onevm list' command

Hi!

I wonder if it’s possible in the output of ‘onevm list’ command to get the list of IP addressed of running VMs in a separated column like it’s done for HOST or NAME ones?

Yes, it possible. Follow the simple guide below.

  1. Open the /usr/lib/one/ruby/cli/one_helper/onevm_helper.rb and look for line 142 or section start with “def format_pool

  2. Add the following lines - perhaps after the column Name.

column :IP, "IP address of the Virtual Machine", :size=>15 do |d|
     d["TEMPLATE"]["NIC"]["IP"]
 end
  1. Add the new column (IP) as default column at line 215

default :ID, :USER, :GROUP, :NAME, :IP, :STAT, :UCPU, :UMEM, :HOST, :TIME

  1. Open /etc/one/cli/onevm.yaml and the following lines - perhaps after the column Name.
:IP:
  :desc: IP address of the Virtual Machine
  :size: 15
  :left: true
  1. Add the new column (IP) as default column in /etc/one/cli/onevm.yaml also

:default:

  • :ID
  • :USER
  • :GROUP
  • :NAME
    - :IP
  • :STAT
  • :UCPU
  • :UMEM
  • :HOST
  • :TIME

NOTE: The changes will not work if there is VM(s) with 2 IP addresses. Hope the developer able to assist on this.

Hi,

The IP column is actually supported out of the box in OpenNebula 4.14, although the doc is a bit buried in the release notes.
You don’t need to edit the helper.rb file, simply add the :IP column to the :default: group in /etc/one/cli/onevm.yaml. And yes, the column in 4.14 shows all IPs when there are more than one.

Sorry, I forgot to mentioned that we are still using 4.12. Since we have some custom extensions and they don’t work with 4.14 yet we need some time to adopt them for 4.14 before upgrading our production cloud to the latest stable version. So Carlos, thanks for clarifying that things and anandharaj for sharing the recipe how to achieve a desirable behavior on 4.12!