diff --git a/src/cli/one_helper/onevm_helper.rb b/src/cli/one_helper/onevm_helper.rb index 4f8e5153eb..4c88a42c11 100644 --- a/src/cli/one_helper/onevm_helper.rb +++ b/src/cli/one_helper/onevm_helper.rb @@ -46,6 +46,13 @@ private end end +EXTERNAL_IP_ATTRS = [ + 'GUEST_IP', + 'AWS_IP_ADDRESS', + 'AZ_IPADDRESS', + 'SL_PRIMARYIPADDRESS' +]; + class OneVMHelper < OpenNebulaHelper::OneHelper MULTIPLE={ @@ -505,6 +512,14 @@ class OneVMHelper < OpenNebulaHelper::OneHelper vm_monitoring = vm.to_hash['VM']['MONITORING'] + # Find out if it is a hybrid VM to avoid showing local IPs + isHybrid=false + vm_monitoring.each{|key, value| + if EXTERNAL_IP_ATTRS.include? key + isHybrid=true + end + } + order_attrs = %w(CPU MEMORY NETTX NETRX) vm_monitoring_sort = [] @@ -674,7 +689,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper end end - if vm.has_elements?("/VM/TEMPLATE/NIC") + if vm.has_elements?("/VM/TEMPLATE/NIC") and !isHybrid puts CLIHelper.print_header(str_h1 % "VM NICS",false) @@ -777,7 +792,7 @@ class OneVMHelper < OpenNebulaHelper::OneHelper vm.delete_element("/VM/TEMPLATE/NIC") end if !options[:all] - if vm.has_elements?("/VM/TEMPLATE/SECURITY_GROUP_RULE") + if vm.has_elements?("/VM/TEMPLATE/SECURITY_GROUP_RULE") and !isHybrid puts CLIHelper.print_header(str_h1 % "SECURITY",false) puts diff --git a/src/sunstone/public/app/opennebula/vm.js b/src/sunstone/public/app/opennebula/vm.js index 89e4b30521..ced1e72111 100644 --- a/src/sunstone/public/app/opennebula/vm.js +++ b/src/sunstone/public/app/opennebula/vm.js @@ -618,26 +618,6 @@ define(function(require) { var nic = element.TEMPLATE.NIC; var ips = []; - if (nic != undefined) { - if (!$.isArray(nic)) { - nic = [nic]; - } - - $.each(nic, function(index, value) { - if (value.IP) { - ips.push(value.IP); - } - - if (value.IP6_GLOBAL) { - ips.push(value.IP6_GLOBAL); - } - - if (value.IP6_ULA) { - ips.push(value.IP6_ULA); - } - }); - } - var monitoring = element.MONITORING; if (monitoring) { var externalIP; @@ -648,6 +628,28 @@ define(function(require) { } }) } + else + { + if (nic != undefined) { + if (!$.isArray(nic)) { + nic = [nic]; + } + + $.each(nic, function(index, value) { + if (value.IP) { + ips.push(value.IP); + } + + if (value.IP6_GLOBAL) { + ips.push(value.IP6_GLOBAL); + } + + if (value.IP6_ULA) { + ips.push(value.IP6_ULA); + } + }); + } + } if (ips.length > 0) { return ips.join(divider);