mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
parent
005d8739fb
commit
9d469cb8f0
@ -398,7 +398,8 @@ define(function(require) {
|
||||
"IP6_ULA",
|
||||
"VROUTER_IP",
|
||||
"VROUTER_IP6_GLOBAL",
|
||||
"VROUTER_IP6_ULA"
|
||||
"VROUTER_IP6_ULA",
|
||||
"EXTERNAL_IP",
|
||||
];
|
||||
|
||||
var EXTERNAL_NETWORK_ATTRIBUTES = [
|
||||
@ -924,17 +925,20 @@ define(function(require) {
|
||||
|
||||
// Return the IP or several IPs of a VM
|
||||
function ipsStr(element, divider, groupStrFunction) {
|
||||
var defaultValue = '--'
|
||||
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];
|
||||
$.each(EXTERNAL_IP_ATTRS, function(_, IPAttr) {
|
||||
var externalIP = monitoring[IPAttr];
|
||||
|
||||
if (externalIP) {
|
||||
var splitArr = externalIP.split(",");
|
||||
$.each(splitArr, function(i,ip){
|
||||
|
||||
$.each(splitArr, function(_,ip){
|
||||
if (ip && ($.inArray(ip, ips) == -1)) {
|
||||
ips.push(ip);
|
||||
}
|
||||
@ -944,26 +948,21 @@ define(function(require) {
|
||||
}
|
||||
|
||||
// infoextended: alias will be group by nic
|
||||
return Config.isExtendedVmInfo
|
||||
? (groupStrFunction !== null && typeof groupStrFunction === "function"? groupStrFunction(element, nics) : groupByIpsStr(element, nics))
|
||||
: (ips.length == 0 && nics && nics.length > 0)
|
||||
? $.map(nics, function(nic) {
|
||||
if (nic["IP"]) {
|
||||
return nic["IP"];
|
||||
}
|
||||
else{
|
||||
var ipv6 = "";
|
||||
if (nic["IP6_ULA"]){
|
||||
ipv6 += nic["IP6_ULA"];
|
||||
}
|
||||
if (nic["IP6_GLOBAL"]){
|
||||
ipv6 = (ipv6 == "") ? "" : ipv6 + "<br>";
|
||||
ipv6 += nic["IP6_GLOBAL"];
|
||||
}
|
||||
return ipv6;
|
||||
}
|
||||
}).join(divider)
|
||||
: "--";
|
||||
if (Config.isExtendedVmInfo) {
|
||||
return typeof groupStrFunction === "function"
|
||||
? groupStrFunction(element, nics)
|
||||
: groupByIpsStr(element, nics)
|
||||
}
|
||||
|
||||
return (ips.length === 0 && nics && nics.length > 0) ? (
|
||||
$.map(nics, function(nic) {
|
||||
return $.map(NIC_ALIAS_IP_ATTRS, function(attribute) {
|
||||
return nic[attribute]
|
||||
})
|
||||
}).join(divider)
|
||||
) : (
|
||||
defaultValue
|
||||
)
|
||||
};
|
||||
|
||||
// Return a dropdown with all the
|
||||
@ -975,7 +974,7 @@ define(function(require) {
|
||||
// If its generated by groupByIpsDropdown
|
||||
if (~ipsStr.indexOf("li")){
|
||||
ips = [];
|
||||
$.each($.parseHTML(ipsStr), function( index ) {
|
||||
$.each($.parseHTML(ipsStr), function() {
|
||||
ips.push($( this ).text());
|
||||
});
|
||||
ipsStr = "<ul style='list-style-type:none;'>" + ipsStr + "</ul>";
|
||||
@ -1005,30 +1004,45 @@ define(function(require) {
|
||||
};
|
||||
|
||||
function groupByIpsDropdown(element = {}, nics = []) {
|
||||
|
||||
// Show the first IP two times for the dropdown.
|
||||
var copy_nics = Object.assign([], nics);
|
||||
|
||||
var first_nic = Object.assign({}, nics[0]);
|
||||
delete first_nic["EXTERNAL_IP"];
|
||||
delete first_nic["ALIAS_IDS"];
|
||||
copy_nics.unshift(first_nic);
|
||||
|
||||
return copy_nics.reduce(function(column, nic) {
|
||||
identation = " ";
|
||||
var ip = (nic.IP) ? nic.IP : nic.IP6_ULA + " " + identation + nic.IP6_GLOBAL;
|
||||
var nicSection = nic.NIC_ID ? $("<li/>").append($("<a/>").css("color", "gray").html(nic.NIC_ID + ": " + ip)) : $("<li/>").append("<li>").html("-") ;
|
||||
var identation = " ";
|
||||
var ip = nic.IP || nic.IP6_ULA + " " + identation + nic.IP6_GLOBAL;
|
||||
|
||||
var nicSection = nic.NIC_ID
|
||||
? $("<li/>").append($("<a/>").css("color", "gray").html(nic.NIC_ID + ": " + ip))
|
||||
: $("<li/>").append("<li>").html("-") ;
|
||||
|
||||
if (String(nic.EXTERNAL_IP).toLowerCase() !== 'yes') {
|
||||
var externalIp = " " + nic.NIC_ID + ": " + nic.EXTERNAL_IP
|
||||
nicSection.append($("<li/>").append($("<a/>").css("color", "gray").html(externalIp)))
|
||||
}
|
||||
|
||||
if (nic.ALIAS_IDS) {
|
||||
nic.ALIAS_IDS.split(",").forEach(function(aliasId) {
|
||||
var templateAlias = Array.isArray(element.TEMPLATE.NIC_ALIAS)
|
||||
? element.TEMPLATE.NIC_ALIAS : [element.TEMPLATE.NIC_ALIAS];
|
||||
var alias = templateAlias.find(function(alias) { return alias.NIC_ID === aliasId; });
|
||||
? element.TEMPLATE.NIC_ALIAS
|
||||
: [element.TEMPLATE.NIC_ALIAS];
|
||||
|
||||
var alias = templateAlias.find(function(alias) {
|
||||
return alias.NIC_ID === aliasId;
|
||||
});
|
||||
|
||||
if (alias) {
|
||||
var alias_ip = alias.IP ? alias.IP : alias.IP6_ULA + " " + identation + "> " + alias.IP6_GLOBAL;
|
||||
var alias_ip = alias.IP || alias.IP6_ULA + " " + identation + "> " + alias.IP6_GLOBAL;
|
||||
|
||||
nicSection.append($("<li/>").append($("<a/>").css({
|
||||
"color": "gray",
|
||||
"font-style": "italic",
|
||||
}).html(identation + "> " + alias_ip))); }
|
||||
}).html(identation + "> " + alias_ip)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1037,28 +1051,40 @@ define(function(require) {
|
||||
};
|
||||
|
||||
function groupByIpsStr(element = {}, nics = []) {
|
||||
identation = " ";
|
||||
return nics.reduce(function(column, nic) {
|
||||
var ip = (nic.IP) ? nic.IP : nic.IP6_ULA + "<br>" + identation + nic.IP6_GLOBAL;
|
||||
var nicSection = $("<p>").css("margin-bottom", 0).html(nic.NIC_ID + ": " + ip);
|
||||
var identation = " ";
|
||||
|
||||
var res = nics.reduce(function(column, nic) {
|
||||
var ip = nic.IP || nic.IP6_ULA + "<br>" + identation + nic.IP6_GLOBAL
|
||||
|
||||
column.append($("<p/>").css("margin-bottom", 0).html(nic.NIC_ID + ": " + ip))
|
||||
|
||||
if (String(nic.EXTERNAL_IP).toLowerCase() !== 'yes') {
|
||||
var externalIp = nic.NIC_ID + ": " + nic.EXTERNAL_IP
|
||||
|
||||
column.append($("<p/>").css("margin-bottom", 0).html(externalIp))
|
||||
}
|
||||
|
||||
if (nic.ALIAS_IDS) {
|
||||
|
||||
nic.ALIAS_IDS.split(",").forEach(function(aliasId) {
|
||||
var templateAlias = Array.isArray(element.TEMPLATE.NIC_ALIAS)
|
||||
? element.TEMPLATE.NIC_ALIAS : [element.TEMPLATE.NIC_ALIAS];
|
||||
? element.TEMPLATE.NIC_ALIAS
|
||||
: [element.TEMPLATE.NIC_ALIAS];
|
||||
|
||||
var alias = templateAlias.find(function(alias) { return alias.NIC_ID === aliasId; });
|
||||
|
||||
if (alias) {
|
||||
var alias_ip = alias.IP ? alias.IP : alias.IP6_ULA + "<br>" + identation + "> " + alias.IP6_GLOBAL;
|
||||
nicSection.append($("<p/>").css({
|
||||
var alias_ip = identation + "> " + alias.IP ||
|
||||
alias.IP6_ULA + "<br>" + identation + "> " + alias.IP6_GLOBAL;
|
||||
|
||||
column.append($("<p/>").css({
|
||||
"margin-bottom": 0,
|
||||
"font-style": "italic",
|
||||
}).html(identation + "> " + alias_ip)); }
|
||||
"font-style": "italic"
|
||||
}).html(alias_ip));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return column.append(nicSection);
|
||||
return column;
|
||||
}, $("<div/>")).html();
|
||||
};
|
||||
|
||||
|
@ -64,13 +64,14 @@ define(function(require) {
|
||||
"bSortClasses" : false,
|
||||
"bDeferRender": true,
|
||||
"aoColumnDefs": [
|
||||
{"sType": "ip-address", "aTargets": [0]},
|
||||
{"sType": "num", "aTargets": [1]},
|
||||
{"sType": "date-euro", "aTargets": [ 10 ]},
|
||||
{"bSortable": false, "aTargets": ["check", 11]},
|
||||
{"sWidth": "35px", "aTargets": [0]},
|
||||
{"bVisible": true, "aTargets": SunstoneConfig.tabTableColumns(TAB_NAME)},
|
||||
{"bVisible": false, "aTargets": ['_all']}
|
||||
{"sType": "ip-address", "aTargets": [0]},
|
||||
{"sType": "num", "aTargets": [1]},
|
||||
{"sType": "date-euro", "aTargets": [ 10 ]},
|
||||
{"bSortable": false, "aTargets": ["check", 11]},
|
||||
{"sWidth": "35px", "aTargets": [0]},
|
||||
{"bVisible": true, "aTargets": SunstoneConfig.tabTableColumns(TAB_NAME)},
|
||||
{"bVisible": false, "aTargets": ['_all']},
|
||||
{"sClass": "middle", "aTargets": ['_all']}
|
||||
]
|
||||
};
|
||||
|
||||
|
@ -225,22 +225,30 @@ define(function(require) {
|
||||
return html;
|
||||
}
|
||||
|
||||
function _ipTr(nic, attr){
|
||||
var v = "--";
|
||||
if(nic && attr){
|
||||
if(!Array.isArray(attr)){
|
||||
attr = [attr];
|
||||
}
|
||||
attr.map(function(attr){
|
||||
if(nic[attr]){
|
||||
v = nic[attr];
|
||||
if (nic["VROUTER_"+attr] != undefined){
|
||||
v += ("<br/>" + nic["VROUTER_"+attr] + Locale.tr(" (VRouter)"));
|
||||
}
|
||||
}
|
||||
});
|
||||
function _ipTr(nic, attributes) {
|
||||
var ips = [];
|
||||
var defaultValue = '--'
|
||||
|
||||
if (!nic || !attributes) return defaultValue
|
||||
|
||||
if (!Array.isArray(attributes)) {
|
||||
attributes = [attributes];
|
||||
}
|
||||
return v;
|
||||
|
||||
attributes.map(function(attribute) {
|
||||
if (nic[attribute]) {
|
||||
// filter attributes with dual value: YES or <IP>
|
||||
if (String(nic[attribute]).toLowerCase() !== 'yes') {
|
||||
ips.push(nic[attribute])
|
||||
}
|
||||
|
||||
if (nic["VROUTER_" + attribute] !== undefined) {
|
||||
ips.push(nic["VROUTER_" + attribute] + Locale.tr(" (VRouter)"));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return ips.length === 0 ? defaultValue : ips.join('<br/>');
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
@ -347,9 +355,9 @@ define(function(require) {
|
||||
|
||||
var pci_address = is_pci ? nic.ADDRESS : "";
|
||||
|
||||
var ipStr = "IP";
|
||||
var ipAttribute = "IP";
|
||||
if (nic.IP6 !== undefined){
|
||||
ipStr = "IP6";
|
||||
ipAttribute = "IP6";
|
||||
}
|
||||
|
||||
var nic_alias = [];
|
||||
@ -369,7 +377,7 @@ define(function(require) {
|
||||
nic_dt_data.push({
|
||||
NIC_ID : nic.NIC_ID,
|
||||
NETWORK : Navigation.link(nic.NETWORK, "vnets-tab", nic.NETWORK_ID),
|
||||
IP : _ipTr(nic, [ipStr, "IP"]),
|
||||
IP : _ipTr(nic, [ipAttribute, 'EXTERNAL_IP']),
|
||||
NIC_ALIAS : nic_alias,
|
||||
MAC : nic.MAC,
|
||||
PCI_ADDRESS: pci_address,
|
||||
@ -429,29 +437,39 @@ define(function(require) {
|
||||
if(row.data().NIC_ALIAS.length > 0) {
|
||||
var html = "";
|
||||
|
||||
$.each(row.data().NIC_ALIAS, function(index, elem) {
|
||||
$.each(row.data().NIC_ALIAS, function() {
|
||||
var new_div = "<div id=alias_" + this.NIC_ID + " style=\"margin-left: 40px; margin-bottom: 5px\">" +
|
||||
"<b>" + "- Alias-" + this.ALIAS_ID + ":" + "</b>";
|
||||
|
||||
if(this.IP !== undefined) {
|
||||
new_div += " " + this.IP;
|
||||
new_div += " " + this.IP;
|
||||
}
|
||||
|
||||
if(String(this.EXTERNAL_IP).toLowerCase() !== 'yes') {
|
||||
new_div += " " + this.EXTERNAL_IP;
|
||||
}
|
||||
|
||||
if(this.IP6 !== undefined) {
|
||||
new_div += " " + this.IP6;
|
||||
new_div += " " + this.IP6;
|
||||
}
|
||||
|
||||
new_div += " " + this.MAC;
|
||||
|
||||
if(this.IP6_ULA !== undefined) {
|
||||
new_div += " <b>ULA</b> " + this.IP6_ULA;
|
||||
new_div += " <b>ULA</b> " + this.IP6_ULA;
|
||||
}
|
||||
|
||||
if(this.IP6_GLOBAL !== undefined) {
|
||||
new_div += " <b>Global</b> " + this.IP6_GLOBAL;
|
||||
new_div += " <b>Global</b> " + this.IP6_GLOBAL;
|
||||
}
|
||||
|
||||
new_div += " " + this.ACTIONS + "</div>";
|
||||
|
||||
html += new_div;
|
||||
|
||||
if (Config.isTabActionEnabled("vms-tab", "VM.detachnic")) {
|
||||
context.off("click", ".detachnic");
|
||||
context.on("click", ".detachnic", {element_id: that.element.ID}, detach_alias);
|
||||
context.off("click", ".detachnic");
|
||||
context.on("click", ".detachnic", {element_id: that.element.ID}, detach_alias);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -43,6 +43,10 @@ table {
|
||||
}
|
||||
}
|
||||
|
||||
&.middle {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.cpu{
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
|
Loading…
x
Reference in New Issue
Block a user