From 76636eeae17457f989b0fdafc2a64a8b4182fee2 Mon Sep 17 00:00:00 2001 From: Frederick Borges Date: Tue, 17 Nov 2020 12:55:35 +0100 Subject: [PATCH] B #5037: fix malformed VM IPs (#431) Signed-off-by: Frederick Borges (cherry picked from commit d2d7e546c611770bee27d6dc3abc5caea388fbda) --- src/sunstone/public/app/opennebula/vm.js | 50 +++++++++++++------ .../public/app/utils/tab-datatable.js | 3 ++ 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/sunstone/public/app/opennebula/vm.js b/src/sunstone/public/app/opennebula/vm.js index 32bef39465..77098b3d62 100644 --- a/src/sunstone/public/app/opennebula/vm.js +++ b/src/sunstone/public/app/opennebula/vm.js @@ -789,7 +789,7 @@ define(function(require) { } // Return the IP or several IPs of a VM - function ipsStr(element, divider, groupStrFuntion = groupByIpsStr) { + function ipsStr(element, divider, groupStrFunction = groupByIpsStr) { var divider = divider || "
"; var nics = getNICs(element); var ips = []; @@ -808,6 +808,7 @@ define(function(require) { } }); } + // infoextended: alias will be group by nic return Config.isExtendedVmInfo ? groupStrFuntion(element, nics) @@ -816,11 +817,22 @@ define(function(require) { if (nic["IP"]) { return nic["IP"]; } + else{ + var ipv6 = "" + if (nic["IP6_ULA"]){ + ipv6 += nic["IP6_ULA"]; + } + if (nic["IP6_GLOBAL"]){ + ipv6 = (ipv6 == "") ? "" : ipv6 + "
"; + ipv6 += nic["IP6_GLOBAL"]; + } + return ipv6; + } }).join(divider) : "--"; }; - // Return a dropdown with all the + // Return a dropdown with all the function ipsDropdown(element, divider) { var ipsStr = this.ipsStr(element,divider,groupByIpsDropdown); var ips = ipsStr.split('
'); @@ -828,18 +840,18 @@ define(function(require) { // If its generated by groupByIpsDropdown if (~ipsStr.indexOf("li")){ - ips = [] + ips = [] $.each($.parseHTML(ipsStr), function( index ) { ips.push($( this ).text()); }); ipsStr = ""; } - + // If it has less than "numIPs" IPs var numIPs = 2; if ((ips.length < numIPs)) return ipsStr; - // Take the first x + // Take the first x insideHtml = ""; for (let i = 0; i < numIPs-1; i++) { insideHtml += ips.shift(); @@ -848,7 +860,7 @@ define(function(require) { // Format the other IPs inside a dropdown if (ips.length){ - html += '