1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-25 06:03:36 +03:00

F #3859: Update Sunstone Host/VM paths(#4325)

Signed-off-by: Jorge Lobo <jlobo@opennebula.systems>
This commit is contained in:
Jorge Lobo 2020-03-09 10:23:30 +01:00 committed by GitHub
parent 549a533e95
commit e0f99c3ca8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 100 additions and 82 deletions

View File

@ -28,6 +28,7 @@ define(function(require) {
Foundation.Reveal.defaults.closeOnClick = false;
_setupDataTableSearch();
_setDataTableErrMode();
var SETTINGS_TAB_ID = require('tabs/settings-tab/tabId');
var PROVISION_TAB_ID = require('tabs/provision-tab/tabId');
@ -279,6 +280,12 @@ define(function(require) {
return null;
}
function _setDataTableErrMode(){
$.fn.dataTable.ext.errMode = function(settings, techNote, message) {
console.log('data table error: '+message);
};
}
function _setupDataTableSearch() {
$.fn.dataTable.ext.type.order['file-size-pre'] = function ( data ) {
var matches = data.match( /^(\d+(?:\.\d+)?)\s*([a-z]+)/i );

View File

@ -159,12 +159,15 @@ define(function(require) {
break;
}
this.maxCPU += parseInt(element.HOST_SHARE.MAX_CPU);
this.allocatedCPU += parseInt(element.HOST_SHARE.CPU_USAGE);
this.realCPU += parseInt(element.HOST_SHARE.USED_CPU);
this.maxMemory += parseInt(element.HOST_SHARE.MAX_MEM);
this.allocatedMemory += parseInt(element.HOST_SHARE.MEM_USAGE);
this.realMemory += parseInt(element.HOST_SHARE.USED_MEM);
this.maxCPU += parseInt((element && element.HOST_SHARE && element.HOST_SHARE.MAX_CPU)||0);
this.allocatedCPU += parseInt((element && element.HOST_SHARE && element.HOST_SHARE.CPU_USAGE)||0);
this.realCPU += parseInt((element && element.MONITORING && element.MONITORING.CAPACITY && element.MONITORING.CAPACITY.USED_CPU)||0);//
this.maxMemory += parseInt((element && element.HOST_SHARE && element.HOST_SHARE.MAX_MEM)||0);
this.allocatedMemory += parseInt((element && element.HOST_SHARE && element.HOST_SHARE.MEM_USAGE)||0);
this.realMemory += parseInt((element && element.MONITORING && element.MONITORING.CAPACITY && element.MONITORING.CAPACITY.USED_MEMORY)||0);//MONITORING.CAPACITY.USED_MEMORY
console.log("-->",element);
var state = OpenNebulaHost.simpleStateStr(element.STATE);
@ -239,10 +242,13 @@ define(function(require) {
"1rem",
{"percentage": ratio_allocated_cpu, "str": info_str})
);
var percentage = ratio_allocated_cpu > 100 ? 100 : ratio_allocated_cpu;
$("#dashboard_host_allocated_cpu_meter").animate({
value: percentage,
}, time, "swing");
if(!isNaN(ratio_allocated_cpu)){
var percentage = ratio_allocated_cpu > 100 ? 100 : ratio_allocated_cpu;
$("#dashboard_host_allocated_cpu_meter").animate({
value: percentage,
}, time, "swing");
}
var ratio_real_cpu = 0;
if (this.maxCPU > 0) {
@ -258,10 +264,13 @@ define(function(require) {
"1rem",
{"percentage": ratio_real_cpu, "str": info_str})
);
var percentage = ratio_real_cpu > 100 ? 100 : ratio_real_cpu;
$("#dashboard_host_real_cpu_meter").animate({
value: percentage,
}, time, "swing");
if(!isNaN(ratio_real_cpu)){
var percentage = ratio_real_cpu > 100 ? 100 : ratio_real_cpu;
$("#dashboard_host_real_cpu_meter").animate({
value: percentage,
}, time, "swing");
}
var ratio_allocated_mem = 0;
if (this.maxMemory > 0) {
@ -277,10 +286,13 @@ define(function(require) {
"1rem",
{"percentage": ratio_allocated_mem, "str": info_str})
);
var percentage = ratio_allocated_mem > 100 ? 100 : ratio_allocated_mem;
$("#dashboard_host_allocated_mem_meter").animate({
value: percentage,
}, time, "swing");
if(!isNaN(ratio_allocated_mem)){
var percentage = ratio_allocated_mem > 100 ? 100 : ratio_allocated_mem;
$("#dashboard_host_allocated_mem_meter").animate({
value: percentage,
}, time, "swing");
}
var ratio_real_mem = 0;
if (this.maxMemory > 0) {
@ -289,6 +301,7 @@ define(function(require) {
} else {
info_str = Humanize.size(this.realMemory) + " / -";
}
$("#dashboard_host_real_mem").html(quotaDashboard(
"dashboard_host_real_mem",
Locale.tr("Real Memory"),
@ -296,10 +309,13 @@ define(function(require) {
"1rem",
{"percentage": ratio_real_mem, "str": info_str})
);
var percentage = ratio_real_mem > 100 ? 100 : ratio_real_mem;
$("#dashboard_host_real_mem_meter").animate({
value: percentage,
}, time, "swing");
if(!isNaN(ratio_real_mem)){
var percentage = ratio_real_mem > 100 ? 100 : ratio_real_mem;
$("#dashboard_host_real_mem_meter").animate({
value: percentage,
}, time, "swing");
}
}

View File

@ -73,18 +73,6 @@ define(function(require) {
});
}
that.imMadNameList = [];
if (Config.onedConf.IM_MAD !== undefined) {
$.each(Config.onedConf.IM_MAD, function(index, imMad) {
if (imMad.SUNSTONE_NAME !== undefined) {
that.imMadNameList.push({
'displayName': imMad["SUNSTONE_NAME"],
'driverName': imMad["NAME"]
});
}
});
}
BaseFormPanel.call(this);
};
@ -106,8 +94,7 @@ define(function(require) {
return TemplateWizardHTML({
'formPanelId': this.formPanelId,
'vCenterClustersHTML': this.vCenterClusters.html(),
'vmMadNameList': this.vmMadNameList,
'imMadNameList': this.imMadNameList
'vmMadNameList': this.vmMadNameList
});
}
@ -117,6 +104,7 @@ define(function(require) {
$(".drivers", context).hide();
$("#host_type_mad", context).on("change", function() {
console.log("-->", this.value);
$("#vmm_mad", context).val(this.value).change();
$("#im_mad", context).val(this.value).change();
$(".vcenter_credentials", context).hide();

View File

@ -65,7 +65,7 @@
<div class="large-12 columns">
<label for="im">{{tr "Information"}}</label>
<select id="im_mad" name="im">
{{#each imMadNameList}}
{{#each vmMadNameList}}
<option value="{{this.driverName}}">{{this.displayName}}</option>
{{/each}}
<option value="custom">{{tr "Custom"}}</option>

View File

@ -201,22 +201,26 @@ define(function(require) {
//.off and .on prevent multiple clicks events
$(context).off("click", "#update_reserved_hosts").on("click", "#update_reserved_hosts", function(){
$("#update_reserved_hosts", context).prop("disabled", true);
var reservedCPU = parseInt($("#textInput_reserved_cpu_hosts", context).val());
var CPU = parseInt(that.element.HOST_SHARE.FREE_CPU);
var reservedMem = parseInt(Humanize.sizeToMB($("#textInput_reserved_mem_hosts").val()) * 1024);
var MEM = parseInt(that.element.HOST_SHARE.FREE_MEM);
if (parseInt(that.element.HOST_SHARE.USED_CPU) > 0){
CPU += parseInt(that.element.HOST_SHARE.USED_CPU);
}
reservedCPU = CPU - reservedCPU;
if (parseInt(that.element.HOST_SHARE.USED_MEM) > 0){
MEM += parseInt(that.element.HOST_SHARE.USED_MEM);
}
reservedMem = MEM - reservedMem;
var positionFreeAndUsed = that && that.element && that.element.MONITORING && that.element.MONITORING.CAPACITY;
if(positionFreeAndUsed){
$("#update_reserved_hosts", context).prop("disabled", true);
var reservedCPU = parseInt($("#textInput_reserved_cpu_hosts", context).val());
var CPU = parseInt(positionFreeAndUsed.FREE_CPU||0);
var reservedMem = parseInt(Humanize.sizeToMB($("#textInput_reserved_mem_hosts").val()) * 1024);
var MEM = parseInt((positionFreeAndUsed.FREE_MEMORY)||0);
if (parseInt(positionFreeAndUsed.USED_CPU||0) > 0){
CPU += parseInt(positionFreeAndUsed.USED_CPU||0);
}
reservedCPU = CPU - reservedCPU;
if (parseInt(positionFreeAndUsed.USED_MEMORY||0) > 0){
MEM += parseInt(positionFreeAndUsed.USED_MEMORY||0);
}
reservedMem = MEM - reservedMem;
var obj = { RESERVED_CPU: reservedCPU, RESERVED_MEM: reservedMem };
Sunstone.runAction("Host.append_template", that.element.ID, TemplateUtils.templateToString(obj));
var obj = { RESERVED_CPU: reservedCPU, RESERVED_MEM: reservedMem };
Sunstone.runAction("Host.append_template", that.element.ID, TemplateUtils.templateToString(obj));
}
});
$("#change_bar_cpu_hosts", context).on("input", function(){

View File

@ -76,20 +76,20 @@ define(function(require) {
data: {
id: this.element.ID,
monitor: {
monitor_resources : "HOST_SHARE/CPU_USAGE,HOST_SHARE/USED_CPU,HOST_SHARE/MAX_CPU,HOST_SHARE/TOTAL_CPU,HOST_SHARE/MEM_USAGE,HOST_SHARE/USED_MEM,HOST_SHARE/MAX_MEM,HOST_SHARE/TOTAL_MEM"
monitor_resources : "HOST_SHARE/CPU_USAGE,MONITORING/CAPACITY/USED_CPU,HOST_SHARE/MAX_CPU,HOST_SHARE/TOTAL_CPU,HOST_SHARE/MEM_USAGE,MONITORING/CAPACITY/USED_MEMORY,HOST_SHARE/MAX_MEM,HOST_SHARE/TOTAL_MEM"
}
},
success: function(req, response) {
var host_graphs = [
{
monitor_resources : "HOST_SHARE/CPU_USAGE,HOST_SHARE/USED_CPU,HOST_SHARE/MAX_CPU,HOST_SHARE/TOTAL_CPU",
monitor_resources : "HOST_SHARE/CPU_USAGE,MONITORING/CAPACITY/USED_CPU,HOST_SHARE/MAX_CPU,HOST_SHARE/TOTAL_CPU",
labels : Locale.tr("Allocated") + "," + Locale.tr("Real") + "," + Locale.tr("Total") + "," + Locale.tr("Total +/- reserved"),
humanize_figures : false,
div_graph : $("#host_cpu_graph"),
div_legend : $("#host_cpu_legend")
},
{
monitor_resources : "HOST_SHARE/MEM_USAGE,HOST_SHARE/USED_MEM,HOST_SHARE/MAX_MEM,HOST_SHARE/TOTAL_MEM",
monitor_resources : "HOST_SHARE/MEM_USAGE,MONITORING/CAPACITY/USED_MEMORY,HOST_SHARE/MAX_MEM,HOST_SHARE/TOTAL_MEM",
labels : Locale.tr("Allocated") + "," + Locale.tr("Real") + "," + Locale.tr("Total") + "," + Locale.tr("Total +/- reserved"),
humanize_figures : false,
humanize_figures : true,

View File

@ -93,8 +93,14 @@ define(function(require) {
function _setup(context) {
var that = this;
if (that && that.element && that.element.HOST_SHARE && that.element.HOST_SHARE.NUMA_NODES) {
var numaNodes = that.element.HOST_SHARE.NUMA_NODES.NODE;
if (
that &&
that.element &&
that.element.MONITORING &&
that.element.MONITORING.HOST_SHARE &&
that.element.MONITORING.HOST_SHARE.NUMA_NODES
) {
var numaNodes = that.element.MONITORING.HOST_SHARE.NUMA_NODES.NODE;
if (!(numaNodes instanceof Array)) {
numaNodes = [numaNodes];
}
@ -102,7 +108,11 @@ define(function(require) {
var select = $("<select/>",{'id': SELECT_ID});
options.map(function(element){
if(element && element.value){
var selected = that && that.element && that.element.TEMPLATE && that.element.TEMPLATE.PIN_POLICY && that.element.TEMPLATE.PIN_POLICY === element.value;
var selected = that &&
that.element &&
that.element.TEMPLATE &&
that.element.TEMPLATE.PIN_POLICY &&
that.element.TEMPLATE.PIN_POLICY === element.value;
select.append($("<option/>",{'value':element.value}).text(capitalize(element.value)).prop('selected', selected));
}
});

View File

@ -27,44 +27,37 @@ define(function(require) {
@param {Boolean} hostShareFlag if true the info param is the HOST_SHARE element instead of HOSt
*/
var _html = function(host, hostShareFlag) {
var hostShare = hostShareFlag ? host : host.HOST_SHARE;
var maxCPU = parseInt(hostShare.MAX_CPU);
var hostShare = hostShareFlag ? host : host && host.HOST_SHARE;
var hostMonitoring = hostShareFlag ? host : host.MONITORING && host.MONITORING.CAPACITY
var maxCPU = parseInt(hostShare.MAX_CPU||0);
var infoStr;
var allocatedCPUBar
if (hostShare.CPU_USAGE) {
var allocatedCPU = parseInt(hostShare.CPU_USAGE);
if (maxCPU > 0) {
var ratioAllocatedCPU = Math.round((allocatedCPU / maxCPU) * 100);
infoStr = allocatedCPU + ' / ' + maxCPU + ' (' + ratioAllocatedCPU + '%)';
} else {
infoStr = "";
}
allocatedCPUBar = ProgressBar.html(allocatedCPU, maxCPU, infoStr);
}
var realCPUBar
if (hostShare.USED_CPU) {
var realCPU = parseInt(hostShare.USED_CPU);
if (hostMonitoring && hostMonitoring.USED_CPU) {
var realCPU = parseInt(hostMonitoring.USED_CPU);
if (maxCPU > 0) {
var ratioRealCPU = Math.round((realCPU / maxCPU) * 100);
infoStr = realCPU + ' / ' + maxCPU + ' (' + ratioRealCPU + '%)';
} else {
infoStr = "";
}
realCPUBar = ProgressBar.html(realCPU, maxCPU, infoStr);
}
return {
real: realCPUBar,
allocated: allocatedCPUBar
}
}
return {
'html': _html
}

View File

@ -28,43 +28,36 @@ define(function(require) {
*/
var _html = function(host, hostShareFlag) {
var hostShare = hostShareFlag ? host : host.HOST_SHARE;
var maxMem = parseInt(hostShare.MAX_MEM);
var hostMonitoring = hostShareFlag ? host : host.MONITORING && host.MONITORING.CAPACITY
var maxMem = parseInt(hostShare.MAX_MEM||0);
var infoStr = "";
var allocatedMemBar;
if (hostShare.MEM_USAGE) {
var allocatedMem = parseInt(hostShare.MEM_USAGE);
if (maxMem > 0) {
var ratioAllocatedMem = Math.round((allocatedMem / maxMem) * 100);
infoStr = Humanize.size(allocatedMem) + ' / ' + Humanize.size(maxMem) + ' (' + ratioAllocatedMem + '%)';
} else {
infoStr = Humanize.size(allocatedMem) + ' / -';
}
allocatedMemBar = ProgressBar.html(allocatedMem, maxMem, infoStr);
}
var realMemBar;
if (hostShare.USED_MEM) {
var realMem = parseInt(hostShare.USED_MEM);
if (hostMonitoring && hostMonitoring.USED_MEM) {
var realMem = parseInt(hostMonitoring.USED_MEM);
if (maxMem > 0) {
var ratioRealMem = Math.round((realMem / maxMem) * 100);
infoStr = Humanize.size(realMem) + ' / ' + Humanize.size(maxMem) + ' (' + ratioRealMem + '%)';
} else {
infoStr = Humanize.size(realMem) + ' / -';
}
realMemBar = ProgressBar.html(realMem, maxMem, infoStr);
}
return {
real: realMemBar,
allocated: allocatedMemBar
}
}
return {
'html': _html
}

View File

@ -97,9 +97,16 @@ define(function(require) {
hosts = [hosts];
}
hosts.map(function(host){
if(host && host.HOST_SHARE && host.NAME && host.HOST_SHARE.NUMA_NODES && host.HOST_SHARE.NUMA_NODES.NODE){
if(
host &&
host.MONITORING &&
host.MONITORING.HOST_SHARE &&
host.NAME &&
host.MONITORING.HOST_SHARE.NUMA_NODES &&
host.MONITORING.HOST_SHARE.NUMA_NODES.NODE
){
var name = host.NAME;
var numaNodes = host.HOST_SHARE.NUMA_NODES.NODE;
var numaNodes = host.MONITORING.HOST_SHARE.NUMA_NODES.NODE;
if (!(numaNodes instanceof Array)) {
numaNodes = [numaNodes];
}