mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-30 22:50:10 +03:00
Feature #3614: New dialog to edit host/cluster reserved cpu & memory
This commit is contained in:
parent
6dfbb82f95
commit
7e212fb3ea
@ -40,7 +40,8 @@ define(function(require) {
|
||||
require('utils/dialogs/confirm'),
|
||||
require('utils/dialogs/confirm-with-select'),
|
||||
require('utils/dialogs/generic-confirm'),
|
||||
require('utils/dialogs/clusters')
|
||||
require('utils/dialogs/clusters'),
|
||||
require('utils/dialogs/overcommit')
|
||||
]
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@ define(function(require) {
|
||||
var Locale = require('utils/locale');
|
||||
var RenameTr = require('utils/panel/rename-tr');
|
||||
var TemplateTable = require('utils/panel/template-table');
|
||||
var Sunstone = require('sunstone');
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
@ -33,16 +34,33 @@ define(function(require) {
|
||||
var RESOURCE = "Cluster";
|
||||
var XML_ROOT = "CLUSTER";
|
||||
|
||||
var OVERCOMMIT_DIALOG_ID = require('utils/dialogs/overcommit/dialogId');
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
|
||||
function Panel(info) {
|
||||
var that = this;
|
||||
|
||||
this.title = Locale.tr("Info");
|
||||
this.icon = "fa-info-circle";
|
||||
|
||||
this.element = info[XML_ROOT];
|
||||
|
||||
// Hide information in the template table. Unshow values are stored
|
||||
// in the unshownTemplate object to be used when the element info is updated.
|
||||
that.unshownTemplate = {};
|
||||
that.strippedTemplate = {};
|
||||
var unshownKeys = ['RESERVED_CPU', 'RESERVED_MEM'];
|
||||
$.each(that.element.TEMPLATE, function(key, value) {
|
||||
if ($.inArray(key, unshownKeys) > -1) {
|
||||
that.unshownTemplate[key] = value;
|
||||
} else {
|
||||
that.strippedTemplate[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -58,8 +76,10 @@ define(function(require) {
|
||||
|
||||
function _html() {
|
||||
var renameTrHTML = RenameTr.html(TAB_ID, RESOURCE, this.element.NAME);
|
||||
var templateTableHTML = TemplateTable.html(this.element.TEMPLATE, RESOURCE,
|
||||
Locale.tr("Attributes"));
|
||||
var templateTableHTML = TemplateTable.html(
|
||||
this.strippedTemplate,
|
||||
RESOURCE,
|
||||
Locale.tr("Attributes"));
|
||||
|
||||
return TemplateHTML({
|
||||
'element': this.element,
|
||||
@ -69,8 +89,23 @@ define(function(require) {
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
|
||||
RenameTr.setup(TAB_ID, RESOURCE, this.element.ID, context);
|
||||
|
||||
TemplateTable.setup(this.element.TEMPLATE, RESOURCE, this.element.ID, context);
|
||||
TemplateTable.setup(this.strippedTemplate, RESOURCE, this.element.ID, context, this.unshownTemplate);
|
||||
|
||||
$(".edit_reserved", context).on("click", function(){
|
||||
var dialog = Sunstone.getDialog(OVERCOMMIT_DIALOG_ID);
|
||||
|
||||
dialog.setParams(
|
||||
{ element: that.element,
|
||||
action : "Cluster.append_template",
|
||||
resourceName : Locale.tr("Cluster")
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -31,6 +31,29 @@
|
||||
{{{renameTrHTML}}}
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="dataTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="3">{{tr "Overcommitment"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Reserved CPU"}}</td>
|
||||
<td class="value_td" style="width:50%;">{{valOrDefault element.TEMPLATE.RESERVED_CPU "-"}}</td>
|
||||
<td>
|
||||
<a class="edit_reserved edit_e" href="#"> <i class="fa fa-pencil-square-o right"/></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Reserved Memory"}}</td>
|
||||
<td class="value_td" style="width:50%;">{{humanizeSize "KB" element.TEMPLATE.RESERVED_MEM}}</td>
|
||||
<td>
|
||||
<a class="edit_reserved edit_e" href="#"> <i class="fa fa-pencil-square-o right"/></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -30,6 +30,7 @@ define(function(require) {
|
||||
var MemoryBars = require('../utils/memory-bars');
|
||||
var DatastoresCapacityTable = require('../utils/datastores-capacity-table');
|
||||
var CanImportWilds = require('../utils/can-import-wilds');
|
||||
var Sunstone = require('sunstone');
|
||||
|
||||
/*
|
||||
TEMPLATES
|
||||
@ -46,6 +47,8 @@ define(function(require) {
|
||||
var RESOURCE = "Host"
|
||||
var XML_ROOT = "HOST"
|
||||
|
||||
var OVERCOMMIT_DIALOG_ID = require('utils/dialogs/overcommit/dialogId');
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
@ -64,7 +67,7 @@ define(function(require) {
|
||||
// object to be used when the host info is updated.
|
||||
that.unshownTemplate = {};
|
||||
that.strippedTemplate = {};
|
||||
var unshownKeys = ['HOST', 'VM', 'WILDS'];
|
||||
var unshownKeys = ['HOST', 'VM', 'WILDS', 'RESERVED_CPU', 'RESERVED_MEM'];
|
||||
$.each(that.element.TEMPLATE, function(key, value) {
|
||||
if ($.inArray(key, unshownKeys) > -1) {
|
||||
that.unshownTemplate[key] = value;
|
||||
@ -113,10 +116,26 @@ define(function(require) {
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
|
||||
RenameTr.setup(TAB_ID, RESOURCE, this.element.ID, context);
|
||||
ClusterTr.setup(RESOURCE, this.element.ID, this.element.CLUSTER_ID, context);
|
||||
TemplateTable.setup(this.strippedTemplate, RESOURCE, this.element.ID, context, this.unshownTemplate);
|
||||
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context);
|
||||
|
||||
$(".edit_reserved", context).on("click", function(){
|
||||
var dialog = Sunstone.getDialog(OVERCOMMIT_DIALOG_ID);
|
||||
|
||||
dialog.setParams(
|
||||
{ element: that.element,
|
||||
action : "Host.append_template",
|
||||
resourceName : Locale.tr("Host")
|
||||
});
|
||||
|
||||
dialog.show();
|
||||
return false;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
@ -73,6 +73,29 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="dataTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="3">{{tr "Overcommitment"}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Reserved CPU"}}</td>
|
||||
<td class="value_td" style="width:50%;">{{valOrDefault element.TEMPLATE.RESERVED_CPU "-"}}</td>
|
||||
<td>
|
||||
<a class="edit_reserved edit_e" href="#"> <i class="fa fa-pencil-square-o right"/></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="key_td">{{tr "Reserved Memory"}}</td>
|
||||
<td class="value_td" style="width:50%;">{{humanizeSize "KB" element.TEMPLATE.RESERVED_MEM}}</td>
|
||||
<td>
|
||||
<a class="edit_reserved edit_e" href="#"> <i class="fa fa-pencil-square-o right"/></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{{datastoresCapacityTableHTML}}}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -26,6 +26,10 @@ define(function(require) {
|
||||
* @return {string} human readable size
|
||||
*/
|
||||
var humanizeSize = function(unit, value, options) {
|
||||
if (value == undefined || value == ""){
|
||||
return "-";
|
||||
}
|
||||
|
||||
switch(unit.toUpperCase()){
|
||||
case 'B':
|
||||
return Humanize.sizeFromB(value);
|
||||
|
112
src/sunstone/public/app/utils/dialogs/overcommit.js
Normal file
112
src/sunstone/public/app/utils/dialogs/overcommit.js
Normal file
@ -0,0 +1,112 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems */
|
||||
/* */
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
|
||||
/* not use this file except in compliance with the License. You may obtain */
|
||||
/* a copy of the License at */
|
||||
/* */
|
||||
/* http://www.apache.org/licenses/LICENSE-2.0 */
|
||||
/* */
|
||||
/* Unless required by applicable law or agreed to in writing, software */
|
||||
/* distributed under the License is distributed on an "AS IS" BASIS, */
|
||||
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
||||
/* See the License for the specific language governing permissions and */
|
||||
/* limitations under the License. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
define(function(require) {
|
||||
/*
|
||||
DEPENDENCIES
|
||||
*/
|
||||
|
||||
var BaseDialog = require('utils/dialogs/dialog');
|
||||
var TemplateHTML = require('hbs!./overcommit/html');
|
||||
var Sunstone = require('sunstone');
|
||||
var Notifier = require('utils/notifier');
|
||||
var WizardFields = require('utils/wizard-fields');
|
||||
var TemplateUtils = require('utils/template-utils');
|
||||
var Config = require('sunstone-config');
|
||||
|
||||
/*
|
||||
CONSTANTS
|
||||
*/
|
||||
|
||||
var DIALOG_ID = require('./overcommit/dialogId');
|
||||
|
||||
/*
|
||||
CONSTRUCTOR
|
||||
*/
|
||||
function Dialog() {
|
||||
this.dialogId = DIALOG_ID;
|
||||
|
||||
BaseDialog.call(this);
|
||||
}
|
||||
|
||||
Dialog.DIALOG_ID = DIALOG_ID;
|
||||
Dialog.prototype = Object.create(BaseDialog.prototype);
|
||||
Dialog.prototype.constructor = Dialog;
|
||||
Dialog.prototype.html = _html;
|
||||
Dialog.prototype.onShow = _onShow;
|
||||
Dialog.prototype.setup = _setup;
|
||||
Dialog.prototype.setParams = _setParams;
|
||||
|
||||
return Dialog;
|
||||
|
||||
/*
|
||||
FUNCTION DEFINITIONS
|
||||
*/
|
||||
|
||||
function _html() {
|
||||
return TemplateHTML({
|
||||
'dialogId': this.dialogId
|
||||
});
|
||||
}
|
||||
|
||||
function _setup(context) {
|
||||
var that = this;
|
||||
|
||||
$('#' + that.dialogId + 'Form', context).submit(function() {
|
||||
var obj = WizardFields.retrieve(context);
|
||||
|
||||
if (obj.RESERVED_CPU == undefined){
|
||||
obj.RESERVED_CPU = "";
|
||||
}
|
||||
|
||||
if (obj.RESERVED_MEM == undefined){
|
||||
obj.RESERVED_MEM = "";
|
||||
}
|
||||
|
||||
Sunstone.runAction(that.action, that.element.ID,
|
||||
TemplateUtils.templateToString(obj));
|
||||
|
||||
Sunstone.getDialog(that.dialogId).hide();
|
||||
Sunstone.getDialog(that.dialogId).reset();
|
||||
return false;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function _onShow(context) {
|
||||
$("#element_id", context).text(this.element.ID);
|
||||
$("#element_name", context).text(this.element.NAME);
|
||||
$("#resource_name", context).text(this.resourceName);
|
||||
|
||||
WizardFields.fill(context, this.element.TEMPLATE);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} params.
|
||||
* - params.element : host or cluster element
|
||||
* - params.action : sunstone action e.g. "Host.append_template"
|
||||
* - params.resourceName : For the header. e.g. "Host"
|
||||
*/
|
||||
function _setParams(params) {
|
||||
this.element = params.element;
|
||||
|
||||
this.action = params.action;
|
||||
this.resourceName = params.resourceName;
|
||||
}
|
||||
});
|
19
src/sunstone/public/app/utils/dialogs/overcommit/dialogId.js
Normal file
19
src/sunstone/public/app/utils/dialogs/overcommit/dialogId.js
Normal file
@ -0,0 +1,19 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems */
|
||||
/* */
|
||||
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
|
||||
/* not use this file except in compliance with the License. You may obtain */
|
||||
/* a copy of the License at */
|
||||
/* */
|
||||
/* http://www.apache.org/licenses/LICENSE-2.0 */
|
||||
/* */
|
||||
/* Unless required by applicable law or agreed to in writing, software */
|
||||
/* distributed under the License is distributed on an "AS IS" BASIS, */
|
||||
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
|
||||
/* See the License for the specific language governing permissions and */
|
||||
/* limitations under the License. */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
define(function(require) {
|
||||
return 'overcommitDialog';
|
||||
});
|
73
src/sunstone/public/app/utils/dialogs/overcommit/html.hbs
Normal file
73
src/sunstone/public/app/utils/dialogs/overcommit/html.hbs
Normal file
@ -0,0 +1,73 @@
|
||||
{{! -------------------------------------------------------------------------- }}
|
||||
{{! Copyright 2002-2016, OpenNebula Project, OpenNebula Systems }}
|
||||
{{! }}
|
||||
{{! Licensed under the Apache License, Version 2.0 (the "License"); you may }}
|
||||
{{! not use this file except in compliance with the License. You may obtain }}
|
||||
{{! a copy of the License at }}
|
||||
{{! }}
|
||||
{{! http://www.apache.org/licenses/LICENSE-2.0 }}
|
||||
{{! }}
|
||||
{{! Unless required by applicable law or agreed to in writing, software }}
|
||||
{{! distributed under the License is distributed on an "AS IS" BASIS, }}
|
||||
{{! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }}
|
||||
{{! See the License for the specific language governing permissions and }}
|
||||
{{! limitations under the License. }}
|
||||
{{! -------------------------------------------------------------------------- }}
|
||||
|
||||
<div id="{{dialogId}}" class="reveal large" role="dialog" data-reveal >
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<h3 class="subheader">{{tr "Host Overcommitment"}}</h3>
|
||||
<h4 class="subheader"><span id="resource_name"/> <span id="element_id"/> <span id="element_name"/></h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="reveal-body">
|
||||
<form id="{{dialogId}}Form" action="">
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<br/>
|
||||
<p>
|
||||
{{tr "Prior to assigning a VM to a Host, the available capacity is checked to ensure that the VM fits in the host. The capacity is obtained by the monitor probes. You may alter this behaviour by reserving an amount of capacity. You can reserve this capacity:"}}
|
||||
</p>
|
||||
<ul>
|
||||
<li>{{tr "Cluster-wise. All the hosts of the cluster will reserve the same amount of capacity."}}</li>
|
||||
<li>{{tr "Host-wise. This value will override those defined at cluster level."}}</li>
|
||||
</ul>
|
||||
<br/>
|
||||
<p>
|
||||
{{tr "These values can be negative, in that case you'll be actually increasing the overall capacity so overcommitting host capacity."}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="medium-6 columns">
|
||||
<label>
|
||||
{{tr "Reserved CPU"}}
|
||||
<input wizard_field="RESERVED_CPU" type="number"/>
|
||||
</label>
|
||||
</div>
|
||||
<div class="medium-6 columns">
|
||||
<label>
|
||||
{{tr "Reserved Memory in KB"}}
|
||||
<input wizard_field="RESERVED_MEM" type="number"/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-12 columns">
|
||||
<p class="label secondary radius right">
|
||||
{{tr "The values will overwrite the monitoring values in the next monitorization cycle"}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="reveal-footer">
|
||||
<div class="form_buttons">
|
||||
<button class="button radius right success" type="submit">{{tr "Update"}}</button>
|
||||
</div>
|
||||
</div>
|
||||
<button class="close-button" data-close aria-label="{{tr "Close modal"}}" type="button">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user