M #~: fix lost var ips (#4679)

Signed-off-by: Jorge Lobo <jlobo@opennebula.systems>
This commit is contained in:
Jorge Lobo authored and GitHub committed 2020-05-07 18:42:24 +02:00
1 parent bdd325a6f8
commit 2d3ef1be41
1 file changed
+23 -31
+23 -31
View File
@@ -765,16 +765,37 @@ define(function(require) {
function getNICs(element){
var nics = element && element.TEMPLATE && element.TEMPLATE.NIC;
var pci = element && element.TEMPLATE && element.TEMPLATE.PCI;
if (nics == undefined || nics == false){
nics = [];
}
if (!$.isArray(nics)) {
nics = [nics];
}
if (pci != undefined || pci != false) {
if (!$.isArray(pci)) {
pci = [pci];
}
$.each(pci, function(){
if (this["TYPE"] == "NIC"){
nics.push(this);
}
});
}
return nics;
}
// Return the IP or several IPs of a VM
function ipsStr(element, divider, groupStrFuntion = groupByIpsStr) {
var divider = divider || "<br>";
var nics = getNICs(element);
var ips = [];
var monitoring = element && element.MONITORING;
if (monitoring) {
var externalIP;
$.each(EXTERNAL_IP_ATTRS, function(index, IPAttr) {
externalIP = monitoring[IPAttr];
if (externalIP) {
var splitArr = externalIP.split(",");
$.each(splitArr, function(i,ip){
if (ip && ($.inArray(ip, ips) == -1)) {
ips.push(ip);
@@ -783,35 +804,6 @@ define(function(require) {
}
});
}
if (nics == undefined || nics == false){
nics = [];
}
if (!$.isArray(nics)) {
nics = [nics];
}
if (pci != undefined || pci != false) {
if (!$.isArray(pci)) {
pci = [pci];
}
$.each(pci, function(){
if (this["TYPE"] == "NIC"){
nics.push(this);
}
});
}
return nics;
}
// Return the IP or several IPs of a VM
function ipsStr(element, divider, groupStrFuntion = groupByIpsStr) {
var divider = divider || "<br>";
var nics = getNICs(element);
// infoextended: alias will be group by nic
return (
config.system_config &&