diff --git a/src/cli/one_helper/onevm_helper.rb b/src/cli/one_helper/onevm_helper.rb index 524d256cc3..20c76fb998 100644 --- a/src/cli/one_helper/onevm_helper.rb +++ b/src/cli/one_helper/onevm_helper.rb @@ -452,7 +452,28 @@ class OneVMHelper < OpenNebulaHelper::OneHelper puts CLIHelper.print_header(str_h1 % "VM NICS",false) - vm_nics = [vm.to_hash['VM']['TEMPLATE']['NIC']].flatten if !vm_nics + # vm_nics is defined for hybridvisors. If there are both IP from + # the hybridvisor and from OpenNebula nics check if the IP is the + # same as one of IPs generated by OpenNebula and show standard + # information. If it's a different IP show all the information. + # + # The template can already contain one NIC not controled by + # OpenNebula and we want to show also that info. + if vm_nics + if vm.has_elements?("/VM/TEMPLATE/NIC") + nics = [vm.to_hash['VM']['TEMPLATE']['NIC']].flatten + ips = nics.map {|n| n['IP'] } + ip = vm_nics.first['IP'] + + if ips.include? ip + vm_nics = nics + else + vm_nics += nics + end + end + else + vm_nics = [vm.to_hash['VM']['TEMPLATE']['NIC']].flatten + end nic_default = {"NETWORK" => "-", "IP" => "-",