diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index b8e278cd34..eb80fc264e 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -1458,12 +1458,14 @@ function updateVMInfo(request,vm){ $("[href='#vm_capacity_tab']").on("click", function(){ Sunstone.runAction("VM.monitor",vm_info.ID, - { monitor_resources : "CPU,MEMORY"}); + { monitor_resources : "CPU,MEMORY"}); }) $("[href='#vm_network_tab']").on("click", function(){ - Sunstone.runAction("VM.monitor",vm_info.ID, - { monitor_resources : "NET_TX,NET_RX"}); + if (isNICGraphsSupported(vm_info)) { + Sunstone.runAction("VM.monitor",vm_info.ID, + { monitor_resources : "NET_TX,NET_RX"}); + } }) $("[href='#vm_log_tab']").on("click", function(){ @@ -2103,15 +2105,6 @@ function hotpluggingOps(){ function printNics(vm_info){ - var isHybrid = calculate_isHybrid(vm_info); - - // vCenter has network capabilities - if (vm_info.USER_TEMPLATE.HYPERVISOR && - vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "vcenter") - { - isHybrid = false; - } - var html ='
\
\
\ @@ -2130,7 +2123,7 @@ function printNics(vm_info){ if (Config.isTabActionEnabled("vms-tab", "VM.attachnic")) { // If VM is not RUNNING, then we forget about the attach nic form. - if (vm_info.STATE == "3" && vm_info.LCM_STATE == "3" && !isHybrid){ + if (vm_info.STATE == "3" && vm_info.LCM_STATE == "3" && isNICAttachSupported(vm_info)){ html += '\ ' } else { @@ -2253,9 +2246,7 @@ function printNics(vm_info){ } // Do not show statistics for not hypervisors that do not gather net data - if (!isHybrid && vm_info.USER_TEMPLATE.HYPERVISOR && - vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() != "vcenter") - { + if (isNICGraphsSupported(vm_info)) { html += '\
\
\ diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js index 075c7ea053..65006764c6 100644 --- a/src/sunstone/public/js/sunstone.js +++ b/src/sunstone/public/js/sunstone.js @@ -2058,16 +2058,18 @@ function plot_graph(response, info) { var data = response.monitoring[attribute]; - if(info.derivative == true && data) { - derivative(data); - } + if (data) { + if(info.derivative == true) { + derivative(data); + } - series.push({ - stack: attribute, - // Turns label TEMPLATE/BLABLA into BLABLA - label: labels ? labels[i] : attribute[i].split('/').pop(), - data: data - }); + series.push({ + stack: attribute, + // Turns label TEMPLATE/BLABLA into BLABLA + label: labels ? labels[i] : attribute[i].split('/').pop(), + data: data + }); + } } var humanize = info.humanize_figures ? @@ -2107,7 +2109,9 @@ function plot_graph(response, info) { } }; - $.plot(info.div_graph, series, options); + if (series.length > 0) { + $.plot(info.div_graph, series, options); + }; } @@ -8251,12 +8255,19 @@ function getInternetExplorerVersion(){ } // Return true if the VM has a hybrid section -function calculate_isHybrid(vm_info){ - return vm_info.USER_TEMPLATE.HYPERVISOR && +function isNICGraphsSupported(vm_info){ + return !(vm_info.USER_TEMPLATE.HYPERVISOR && (vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "vcenter" || vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "ec2" || vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "azure" - || vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "softlayer") + || vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "softlayer")); +} + +function isNICAttachSupported(vm_info){ + return !(vm_info.USER_TEMPLATE.HYPERVISOR && + (vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "ec2" + || vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "azure" + || vm_info.USER_TEMPLATE.HYPERVISOR.toLowerCase() == "softlayer")); } // Return the IP or several IPs of a VM