mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
parent
9ed720d6cf
commit
430729bf92
@ -672,7 +672,6 @@ define(function(require) {
|
||||
"ipsStr": ipsStr,
|
||||
"ipsDropdown": ipsDropdown,
|
||||
"groupByIpsStr": groupByIpsStr,
|
||||
"aliasStr": aliasStr,
|
||||
"retrieveExternalIPs": retrieveExternalIPs,
|
||||
"retrieveExternalNetworkAttrs": retrieveExternalNetworkAttrs,
|
||||
"isNICGraphsSupported": isNICGraphsSupported,
|
||||
@ -788,12 +787,19 @@ define(function(require) {
|
||||
return nics;
|
||||
}
|
||||
|
||||
// Return the IP or several IPs of a VM
|
||||
function ipsStr(element, divider, groupStrFunction) {
|
||||
var divider = divider || "<br>";
|
||||
// Return the IP or several IPs of a VM
|
||||
function ipsStr(element, options) {
|
||||
options = $.extend({
|
||||
defaultValue: '--',
|
||||
divider: '<br>',
|
||||
groupStrFunction: groupByIpsStr,
|
||||
forceGroup: false
|
||||
}, options)
|
||||
|
||||
var nics = getNICs(element);
|
||||
var ips = [];
|
||||
var monitoring = element && element.MONITORING;
|
||||
var ips = [];
|
||||
|
||||
if (monitoring) {
|
||||
var externalIP;
|
||||
$.each(EXTERNAL_IP_ATTRS, function(index, IPAttr) {
|
||||
@ -810,46 +816,39 @@ 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 || options.forceGroup) {
|
||||
return options.groupStrFunction(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(options.divider)
|
||||
) : (
|
||||
options.defaultValue
|
||||
)
|
||||
};
|
||||
|
||||
// Return a dropdown with all the
|
||||
function ipsDropdown(element, divider) {
|
||||
var ipsStr = this.ipsStr(element,divider,groupByIpsDropdown);
|
||||
var ips = ipsStr.split("<br>");
|
||||
var ipsHtml = this.ipsStr(element, { divider, groupStrFunction: groupByIpsDropdown });
|
||||
var ips = ipsHtml.split("<br>");
|
||||
var html = "";
|
||||
|
||||
// If its generated by groupByIpsDropdown
|
||||
if (~ipsStr.indexOf("li")){
|
||||
if (~ipsHtml.indexOf("li")){
|
||||
ips = [];
|
||||
$.each($.parseHTML(ipsStr), function( index ) {
|
||||
$.each($.parseHTML(ipsHtml), function() {
|
||||
ips.push($( this ).text());
|
||||
});
|
||||
ipsStr = "<ul style='list-style-type:none;'>" + ipsStr + "</ul>";
|
||||
ipsHtml = "<ul style='list-style-type:none;'>" + ipsHtml + "</ul>";
|
||||
}
|
||||
|
||||
// If it has less than "numIPs" IPs
|
||||
var numIPs = 2;
|
||||
if ((ips.length < numIPs)) return ipsStr;
|
||||
if ((ips.length < numIPs)) return ipsHtml;
|
||||
|
||||
// Take the first x
|
||||
insideHtml = "";
|
||||
@ -903,10 +902,12 @@ define(function(require) {
|
||||
};
|
||||
|
||||
function groupByIpsStr(element = {}, nics = []) {
|
||||
identation = " ";
|
||||
var 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 ip = nic.IP || nic.IP6_ULA + "<br>" + identation + nic.IP6_GLOBAL
|
||||
|
||||
column.append($("<p/>").css("margin-bottom", 0).html(nic.NIC_ID + ": " + ip))
|
||||
|
||||
if (nic.ALIAS_IDS) {
|
||||
|
||||
@ -916,66 +917,42 @@ define(function(require) {
|
||||
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 = 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)); }
|
||||
}).html(alias_ip)); }
|
||||
});
|
||||
}
|
||||
|
||||
return column.append(nicSection);
|
||||
return column;
|
||||
}, $("<div/>")).html();
|
||||
};
|
||||
|
||||
// Return the Alias or several Aliases of a VM
|
||||
function aliasStr(element, divider) {
|
||||
var divider = divider || "<br>";
|
||||
var nic_alias = element.TEMPLATE.NIC_ALIAS;
|
||||
var ips = [];
|
||||
function isVNCSupported(element = {}) {
|
||||
var actionEnabled = Config.isTabActionEnabled('vms-tab', 'VM.startvnc')
|
||||
var vncSupported = graphicSupported(element, 'vnc')
|
||||
|
||||
if (nic_alias == undefined){
|
||||
nic_alias = [];
|
||||
}
|
||||
|
||||
if (!$.isArray(nic_alias)) {
|
||||
nic_alias = [nic_alias];
|
||||
}
|
||||
|
||||
if(ips.length==0) {
|
||||
$.each(nic_alias, function(index, value) {
|
||||
$.each(NIC_ALIAS_IP_ATTRS, function(j, attr){
|
||||
if (value[attr]) {
|
||||
ips.push(value[attr]);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (ips.length > 0) {
|
||||
return ips.join(divider);
|
||||
} else {
|
||||
return "--";
|
||||
}
|
||||
};
|
||||
|
||||
// returns true if the vnc button should be enabled
|
||||
function isVNCSupported(element) {
|
||||
return (Config.isTabActionEnabled("vms-tab", "VM.startvnc") && graphicSupported(element, "vnc"))
|
||||
? true : false;
|
||||
return actionEnabled && vncSupported
|
||||
}
|
||||
|
||||
function isSPICESupported(element) {
|
||||
return (Config.isTabActionEnabled("vms-tab", "VM.startspice") && graphicSupported(element, "spice"))
|
||||
? true : false;
|
||||
function isSPICESupported(element = {}) {
|
||||
var actionEnabled = Config.isTabActionEnabled('vms-tab', 'VM.startspice')
|
||||
var spiceSupported = graphicSupported(element, 'spice')
|
||||
|
||||
return actionEnabled && spiceSupported
|
||||
}
|
||||
|
||||
function isWFileSupported(element) {
|
||||
function isWFileSupported(element = {}) {
|
||||
var history = retrieveLastHistoryRecord(element);
|
||||
return (
|
||||
Config.isTabActionEnabled("vms-tab", "VM.save_virt_viewer") && history &&
|
||||
(graphicSupported(element, "vnc") || graphicSupported(element, "spice"))
|
||||
)
|
||||
var actionEnabled = Config.isTabActionEnabled("vms-tab", "VM.save_virt_viewer")
|
||||
var vncSupported = graphicSupported(element, 'vnc')
|
||||
var spiceSupported = graphicSupported(element, 'spice')
|
||||
|
||||
return (actionEnabled && history && (vncSupported || spiceSupported))
|
||||
? {
|
||||
hostname: history.HOSTNAME,
|
||||
type: element.TEMPLATE.GRAPHICS.TYPE.toLowerCase(),
|
||||
@ -1026,8 +1003,8 @@ define(function(require) {
|
||||
var state = parseInt(element.LCM_STATE);
|
||||
rtn = graphics &&
|
||||
graphics.TYPE &&
|
||||
graphics.TYPE.toLowerCase() == type &&
|
||||
$.inArray(state, VNC_STATES) != -1;
|
||||
graphics.TYPE.toLowerCase() === type &&
|
||||
$.inArray(state, VNC_STATES) !== -1;
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
@ -26,12 +26,9 @@ define(function(require) {
|
||||
var roles_vm_buttons = require('./roles/roles-vm-buttons');
|
||||
var Sunstone = require('sunstone');
|
||||
var DomDataTable = require('utils/dom-datatable');
|
||||
var VMsTableUtils = require('tabs/vms-tab/utils/datatable-common');
|
||||
var SunstoneConfig = require('sunstone-config');
|
||||
var Vnc = require('utils/vnc');
|
||||
var Spice = require('utils/spice');
|
||||
var Notifier = require('utils/notifier');
|
||||
var OpenNebulaAction = require("opennebula/action");
|
||||
var OpenNebulaVM = require("opennebula/vm");
|
||||
|
||||
var VMS_TAB_ID = require('tabs/vms-tab/tabId');
|
||||
@ -224,7 +221,7 @@ define(function(require) {
|
||||
: '<span class="has-tip" title="'+
|
||||
Locale.tr("Waiting for the VM to be ready")+'"><i class="fas fa-clock"/></span>'
|
||||
}
|
||||
ips = OpenNebulaVM.ipsStr(data.VM);
|
||||
ips = OpenNebulaVM.ipsStr(data.VM, { forceGroup: true });
|
||||
|
||||
if (OpenNebulaVM.isVNCSupported(data.VM)) {
|
||||
actions += OpenNebulaVM.buttonVnc(id);
|
||||
@ -251,7 +248,9 @@ define(function(require) {
|
||||
if (that.serviceroleVMsDataTable) {
|
||||
that.serviceroleVMsDataTable.updateView(null, roleVms, true);
|
||||
}
|
||||
|
||||
that.remoteButtonSetup(context);
|
||||
Tips.setup(context);
|
||||
});
|
||||
|
||||
|
||||
|
@ -1017,56 +1017,11 @@ define(function(require) {
|
||||
}
|
||||
|
||||
function get_provision_ips(data) {
|
||||
return "<i class=\"fas fa-fw fa-lg fa-globe\"></i> " + OpenNebula.VM.ipsStr(data, ", ");
|
||||
}
|
||||
|
||||
// @params
|
||||
// data: and IMAGE object
|
||||
// Example: data.ID
|
||||
// @returns and object containing the following properties
|
||||
// color: css class for this state.
|
||||
// color + '-color' font color class
|
||||
// color + '-bg' background class
|
||||
// str: user friendly state string
|
||||
function get_provision_image_state(data) {
|
||||
var state = OpenNebula.Image.stateStr(data.STATE);
|
||||
var state_color;
|
||||
var state_str;
|
||||
|
||||
switch (state) {
|
||||
case "READY":
|
||||
case "USED":
|
||||
state_color = "running";
|
||||
state_str = Locale.tr("READY");
|
||||
break;
|
||||
case "DISABLED":
|
||||
case "USED_PERS":
|
||||
state_color = "off";
|
||||
state_str = Locale.tr("OFF");
|
||||
break;
|
||||
case "LOCKED":
|
||||
case "CLONE":
|
||||
case "INIT":
|
||||
state_color = "deploying";
|
||||
state_str = Locale.tr("DEPLOYING") + " (1/3)";
|
||||
break;
|
||||
case "ERROR":
|
||||
state_color = "error";
|
||||
state_str = Locale.tr("ERROR");
|
||||
break;
|
||||
case "DELETE":
|
||||
state_color = "error";
|
||||
state_str = Locale.tr("DELETING");
|
||||
break;
|
||||
default:
|
||||
state_color = "powering_off";
|
||||
state_str = Locale.tr("UNKNOWN");
|
||||
break;
|
||||
}
|
||||
|
||||
return {
|
||||
color: state_color,
|
||||
str: state_str
|
||||
};
|
||||
return (
|
||||
"<div style=\"display: flex; gap: 5px;\">" +
|
||||
"<i class=\"fas fa-fw fa-lg fa-globe\"></i>" +
|
||||
"<div>" + OpenNebula.VM.ipsStr(data, { divider: ", " }) + "</div>" +
|
||||
"</div>"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -22,7 +22,6 @@ define(function(require) {
|
||||
var TabDataTable = require('utils/tab-datatable');
|
||||
var VMsTableUtils = require('./utils/datatable-common');
|
||||
var OpenNebulaVM = require('opennebula/vm');
|
||||
var OpenNebulaAction = require("opennebula/action");
|
||||
var SunstoneConfig = require('sunstone-config');
|
||||
var Locale = require('utils/locale');
|
||||
var StateActions = require('./utils/state-actions');
|
||||
@ -32,7 +31,6 @@ define(function(require) {
|
||||
var Notifier = require('utils/notifier');
|
||||
var DashboardUtils = require('utils/dashboard');
|
||||
var SearchDropdown = require('hbs!./datatable/search');
|
||||
var TemplateUtils = require('utils/template-utils');
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
@ -235,16 +233,12 @@ define(function(require) {
|
||||
|
||||
// Enable actions available to any of the selected VMs
|
||||
var nodes = $('tr', that.dataTable); //visible nodes only
|
||||
$.each($('input.check_item:checked', nodes), function(){
|
||||
$.each($('input.check_item:checked', nodes), function() {
|
||||
StateActions.enableStateActions($(this).attr("state"), $(this).attr("lcm_state"));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
@ -74,13 +74,7 @@ define(function(require) {
|
||||
var hostnameHTML = OpenNebula.VM.hostnameStrLink(this.element);
|
||||
var vrouterHTML = "--";
|
||||
|
||||
var IP = OpenNebula.VM.ipsStr(this.element);
|
||||
|
||||
var alias = (
|
||||
config.system_config &&
|
||||
config.system_config.get_extended_vm_info &&
|
||||
config.system_config.get_extended_vm_info === "true"
|
||||
) ? null : OpenNebula.VM.aliasStr(this.element);
|
||||
var IP = OpenNebula.VM.ipsStr(this.element, { forceGroup: true });
|
||||
|
||||
if (this.element.TEMPLATE.VROUTER_ID != undefined){
|
||||
vrouterHTML = Navigation.link(
|
||||
@ -135,7 +129,6 @@ define(function(require) {
|
||||
"prettyStartTime": prettyStartTime,
|
||||
"deployId": deployId,
|
||||
"IP": IP,
|
||||
"alias": alias,
|
||||
"resched": resched,
|
||||
"permissionsTableHTML": permissionsTableHTML,
|
||||
"templateTableVcenterHTML": templateTableVcenterHTML,
|
||||
|
@ -53,14 +53,6 @@
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
{{#if alias }}
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Alias"}}</td>
|
||||
<td class="value_td">{{{alias}}}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{{/if }}
|
||||
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Start time"}}</td>
|
||||
<td class="value_td">{{prettyStartTime}}</td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user