From 0ca6225c644318b7114858514e25bef5f724a647 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Tue, 7 Oct 2014 16:01:53 +0200 Subject: [PATCH] Feature #3227: Add vCenter and Hybrid IPs to VMs in Sunstone --- src/sunstone/public/js/plugins/vms-tab.js | 64 ++++++++++++++++------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index 95f50bf71c..6833005b07 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -967,31 +967,55 @@ function str_start_time(vm){ // Return the IP or several IPs of a VM function ip_str(vm){ - var nic = vm.TEMPLATE.NIC; - if (nic == undefined){ - return '--'; + if (vm.USER_TEMPLATE.HYPERVISOR) + { + switch(vm.USER_TEMPLATE.HYPERVISOR.toLowerCase()) + { + case "vcenter": + ip = vm.TEMPLATE.GUEST_IP?vm.TEMPLATE.GUEST_IP:"--"; + break; + case "ec2": + ip = vm.TEMPLATE.IP_ADDRESS?vm.TEMPLATE.IP_ADDRESS:"--"; + break; + case "azure": + ip = vm.TEMPLATE.IPADDRESS?vm.TEMPLATE.IPADDRESS:"--"; + break; + case "softlayer": + ip = vm.TEMPLATE.PRIMARYIPADDRESS?vm.TEMPLATE.PRIMARYIPADDRESS:"--"; + break; + default: + ip = "--"; + } } + else + { + var nic = vm.TEMPLATE.NIC; - if (!$.isArray(nic)){ - nic = [nic]; + if (nic == undefined){ + return '--'; + } + + if (!$.isArray(nic)){ + nic = [nic]; + } + + ip = ''; + $.each(nic, function(index,value){ + if (value.IP){ + ip += value.IP+'
'; + } + + if (value.IP6_GLOBAL){ + ip += value.IP6_GLOBAL+'
'; + } + + if (value.IP6_ULA){ + ip += value.IP6_ULA+'
'; + } + }); } - ip = ''; - $.each(nic, function(index,value){ - if (value.IP){ - ip += value.IP+'
'; - } - - if (value.IP6_GLOBAL){ - ip += value.IP6_GLOBAL+'
'; - } - - if (value.IP6_ULA){ - ip += value.IP6_ULA+'
'; - } - }); - return ip; };