Revision 9025c199
src/sunstone/public/app/tabs/clusters-tab/panels/info.js | ||
---|---|---|
24 | 24 |
var RenameTr = require('utils/panel/rename-tr'); |
25 | 25 |
var TemplateTable = require('utils/panel/template-table'); |
26 | 26 |
var Sunstone = require('sunstone'); |
27 |
var TemplateUtils = require('utils/template-utils'); |
|
27 | 28 |
|
28 | 29 |
/* |
29 | 30 |
CONSTANTS |
... | ... | |
47 | 48 |
this.icon = "fa-info-circle"; |
48 | 49 |
|
49 | 50 |
this.element = info[XML_ROOT]; |
51 |
this.percent = false; |
|
50 | 52 |
|
51 | 53 |
// Hide information in the template table. Unshow values are stored |
52 | 54 |
// in the unshownTemplate object to be used when the element info is updated. |
53 | 55 |
that.unshownTemplate = {}; |
54 | 56 |
that.strippedTemplate = {}; |
55 |
var unshownKeys = ['RESERVED_CPU', 'RESERVED_MEM']; |
|
57 |
var unshownKeys = ['HOST', 'RESERVED_CPU', 'RESERVED_MEM'];
|
|
56 | 58 |
$.each(that.element.TEMPLATE, function(key, value) { |
57 | 59 |
if ($.inArray(key, unshownKeys) > -1) { |
58 | 60 |
that.unshownTemplate[key] = value; |
... | ... | |
80 | 82 |
this.strippedTemplate, |
81 | 83 |
RESOURCE, |
82 | 84 |
Locale.tr("Attributes")); |
83 |
|
|
85 |
var reservedMem; |
|
86 |
(this.element.TEMPLATE.RESERVED_MEM != "0%")?reservedMem = parseInt(this.element.TEMPLATE.RESERVED_MEM): reservedMem = 0; |
|
87 |
var reservedCPU |
|
88 |
(this.element.TEMPLATE.RESERVED_CPU != "0%")? reservedCPU = parseInt(this.element.TEMPLATE.RESERVED_CPU): reservedCPU = 0; |
|
84 | 89 |
return TemplateHTML({ |
85 | 90 |
'element': this.element, |
86 | 91 |
'renameTrHTML': renameTrHTML, |
87 |
'templateTableHTML': templateTableHTML |
|
92 |
'templateTableHTML': templateTableHTML, |
|
93 |
'percentCPU': reservedCPU, |
|
94 |
'percentMEM': reservedMem, |
|
88 | 95 |
}); |
89 | 96 |
} |
90 | 97 |
|
98 |
function changeBarCPU(){ |
|
99 |
if(parseInt(document.getElementById('change_bar_cpu').value) > 0) |
|
100 |
document.getElementById('textInput_reserved_cpu').style.backgroundColor = 'rgba(111, 220, 111,0.5)'; |
|
101 |
if(parseInt(document.getElementById('change_bar_cpu').value) < 0) |
|
102 |
document.getElementById('textInput_reserved_cpu').style.backgroundColor = 'rgba(255, 80, 80,0.5)'; |
|
103 |
document.getElementById('textInput_reserved_cpu').value = document.getElementById('change_bar_cpu').value; |
|
104 |
} |
|
105 |
|
|
106 |
function changeInputCPU(){ |
|
107 |
document.getElementById('change_bar_cpu').value = document.getElementById('textInput_reserved_cpu').value; |
|
108 |
} |
|
109 |
|
|
110 |
function changeBarMEM(){ |
|
111 |
if(parseInt(document.getElementById('change_bar_mem').value) > 0) |
|
112 |
document.getElementById('textInput_reserved_mem').style.backgroundColor = 'rgba(111, 220, 111,0.5)'; |
|
113 |
if(parseInt(document.getElementById('change_bar_mem').value) < 0) |
|
114 |
document.getElementById('textInput_reserved_mem').style.backgroundColor = 'rgba(255, 80, 80,0.5)'; |
|
115 |
document.getElementById('textInput_reserved_mem').value = document.getElementById('change_bar_mem').value; |
|
116 |
} |
|
117 |
|
|
118 |
function changeInputMEM(){ |
|
119 |
document.getElementById('change_bar_mem').value = document.getElementById('textInput_reserved_mem').value; |
|
120 |
} |
|
121 |
|
|
91 | 122 |
function _setup(context) { |
92 | 123 |
var that = this; |
93 | 124 |
|
... | ... | |
95 | 126 |
|
96 | 127 |
TemplateTable.setup(this.strippedTemplate, RESOURCE, this.element.ID, context, this.unshownTemplate); |
97 | 128 |
|
98 |
$(".edit_reserved", context).on("click", function(){ |
|
99 |
var dialog = Sunstone.getDialog(OVERCOMMIT_DIALOG_ID); |
|
129 |
document.getElementById("change_bar_cpu").addEventListener("change", changeBarCPU); |
|
130 |
document.getElementById("textInput_reserved_cpu").addEventListener("change", changeInputCPU); |
|
131 |
document.getElementById("change_bar_mem").addEventListener("change", changeBarMEM); |
|
132 |
document.getElementById("textInput_reserved_mem").addEventListener("change", changeInputMEM); |
|
100 | 133 |
|
101 |
dialog.setParams( |
|
102 |
{ element: that.element, |
|
103 |
action : "Cluster.append_template", |
|
104 |
resourceName : Locale.tr("Cluster"), |
|
105 |
tabId : TAB_ID |
|
106 |
}); |
|
134 |
$(document).off('click', '.update_reserved').on("click", '.update_reserved', function(){ |
|
135 |
var reservedCPU = document.getElementById('change_bar_cpu').value+'%'; |
|
136 |
var reservedMem = document.getElementById('change_bar_mem').value+'%'; |
|
107 | 137 |
|
108 |
dialog.show();
|
|
109 |
return false;
|
|
138 |
var obj = {RESERVED_CPU: reservedCPU, RESERVED_MEM: reservedMem};
|
|
139 |
Sunstone.runAction("Cluster.append_template", that.element.ID, TemplateUtils.templateToString(obj));
|
|
110 | 140 |
}); |
111 | 141 |
} |
112 | 142 |
}); |
src/sunstone/public/app/tabs/clusters-tab/panels/info/html.hbs | ||
---|---|---|
31 | 31 |
{{{renameTrHTML}}} |
32 | 32 |
</tbody> |
33 | 33 |
</table> |
34 |
<table class="dataTable"> |
|
35 |
<thead> |
|
36 |
<tr> |
|
37 |
<th colspan="3">{{tr "Overcommitment"}}</th> |
|
38 |
</tr> |
|
39 |
</thead> |
|
40 |
<tbody> |
|
41 |
<tr> |
|
42 |
<td class="key_td">{{tr "Reserved CPU"}}</td> |
|
43 |
<td class="value_td" style="width:50%;">{{valOrDefault element.TEMPLATE.RESERVED_CPU "-"}}</td> |
|
44 |
<td> |
|
45 |
<a class="edit_reserved edit_e" href="#"> <i class="fa fa-pencil-square-o right"/></a> |
|
46 |
</td> |
|
47 |
</tr> |
|
48 |
<tr> |
|
49 |
<td class="key_td">{{tr "Reserved Memory"}}</td> |
|
50 |
<td class="value_td" style="width:50%;">{{humanizeSize "KB" element.TEMPLATE.RESERVED_MEM}}</td> |
|
51 |
<td> |
|
52 |
<a class="edit_reserved edit_e" href="#"> <i class="fa fa-pencil-square-o right"/></a> |
|
53 |
</td> |
|
54 |
</tr> |
|
55 |
</tbody> |
|
56 |
</table> |
|
57 | 34 |
</div> |
58 | 35 |
</div> |
59 | 36 |
<div class="row"> |
37 |
<div class="large-12 columns"> |
|
38 |
<table class="dataTable"> |
|
39 |
<thead> |
|
40 |
<tr> |
|
41 |
<th colspan="4">{{tr "Overcommitment"}} |
|
42 |
<span class="right"> |
|
43 |
<button id="update_reserved" type="button" class="button small success update_reserved right radius"> |
|
44 |
{{tr "Update"}} |
|
45 |
</button> |
|
46 |
</span> |
|
47 |
</th> |
|
48 |
</tr> |
|
49 |
</thead> |
|
50 |
<tbody> |
|
51 |
<tr colspan="3" class= "overcommit_percent"> |
|
52 |
<td class="key_td">{{tr "Reserved CPU"}}</td> |
|
53 |
<td><input type="range" name="rangeInput" id="change_bar_cpu" min="-100" value="{{percentCPU}}" max="100"> |
|
54 |
<label align="center">0%</label></td> |
|
55 |
<td><input type="text" id="textInput_reserved_cpu" value="{{percentCPU}}" min="-100" max="100" size="1"></td> |
|
56 |
</tr> |
|
57 |
<tr colspan="3" class= "overcommit_percent"> |
|
58 |
<td class="key_td">{{tr "Reserved Memory"}}</td> |
|
59 |
<td><input type="range" name="rangeInput" id="change_bar_mem" min="-100" value="{{percentMEM}}" max="100"> |
|
60 |
<label align="center">0%</label></td> |
|
61 |
<td><input type="text" id="textInput_reserved_mem" value="{{percentMEM}}" min="-100" max="100" size="1"></td> |
|
62 |
</tr> |
|
63 |
</tbody> |
|
64 |
</table> |
|
65 |
</div> |
|
66 |
</div> |
|
67 |
<div class="row"> |
|
60 | 68 |
<div class="large-9 columns"> |
61 | 69 |
{{{templateTableHTML}}} |
62 | 70 |
</div> |
src/sunstone/public/app/tabs/hosts-tab/panels/info.js | ||
---|---|---|
92 | 92 |
this.strippedTemplate, |
93 | 93 |
RESOURCE, |
94 | 94 |
Locale.tr("Attributes")); |
95 |
|
|
95 |
console.log(this.element); |
|
96 | 96 |
var renameTrHTML = RenameTr.html(TAB_ID, RESOURCE, this.element.NAME); |
97 | 97 |
var clusterTrHTML = ClusterTr.html(this.element.CLUSTER); |
98 | 98 |
var permissionsTableHTML = PermissionsTable.html(TAB_ID, RESOURCE, this.element); |
99 | 99 |
var cpuBars = CPUBars.html(this.element); |
100 | 100 |
var memoryBars = MemoryBars.html(this.element); |
101 | 101 |
var datastoresCapacityTableHTML = DatastoresCapacityTable.html(this.element); |
102 |
var realCPU = parseInt(this.element.HOST_SHARE.FREE_CPU); |
|
103 |
if(this.element.HOST_SHARE.USED_CPU != "") |
|
104 |
realCPU += parseInt(this.element.HOST_SHARE.USED_CPU); |
|
105 |
var realMEM = parseInt(this.element.HOST_SHARE.FREE_MEM); |
|
106 |
if(this.element.HOST_SHARE.USED_MEM != "") |
|
107 |
realMEM += parseInt(this.element.HOST_SHARE.USED_MEM); |
|
102 |
var realCPU = parseInt(this.element.HOST_SHARE.TOTAL_CPU); |
|
103 |
var realMEM = parseInt(this.element.HOST_SHARE.TOTAL_MEM); |
|
104 |
|
|
108 | 105 |
|
109 | 106 |
return TemplateInfo({ |
110 | 107 |
'element': this.element, |
... | ... | |
116 | 113 |
'memoryBars': memoryBars, |
117 | 114 |
'stateStr': OpenNebulaHost.stateStr(this.element.STATE), |
118 | 115 |
'datastoresCapacityTableHTML': datastoresCapacityTableHTML, |
116 |
'maxReservedMEM': realMEM * 2, |
|
119 | 117 |
'maxReservedCPU': realCPU * 2, |
120 | 118 |
'realCPU': realCPU, |
121 | 119 |
'realMEM': Humanize.size(realMEM), |
122 |
'maxReservedMEM': realMEM * 2, |
|
123 | 120 |
'virtualMEMInput': Humanize.size(this.element.HOST_SHARE.MAX_MEM) |
124 | 121 |
}); |
125 | 122 |
} |
126 | 123 |
|
127 | 124 |
function changeBarCPU(){ |
125 |
if(parseInt(document.getElementById('change_bar_cpu').value) > this.element.HOST_SHARE.TOTAL_CPU) |
|
126 |
document.getElementById('textInput_reserved_cpu').style.backgroundColor = 'rgba(111, 220, 111,0.5)'; |
|
127 |
if(parseInt(document.getElementById('change_bar_cpu').value) < this.element.HOST_SHARE.TOTAL_CPU) |
|
128 |
document.getElementById('textInput_reserved_cpu').style.backgroundColor = 'rgba(255, 80, 80,0.5)'; |
|
128 | 129 |
document.getElementById('textInput_reserved_cpu').value = document.getElementById('change_bar_cpu').value; |
129 | 130 |
} |
130 | 131 |
|
... | ... | |
133 | 134 |
} |
134 | 135 |
|
135 | 136 |
function changeBarMEM(){ |
137 |
if(parseInt(document.getElementById('change_bar_mem').value) > this.element.HOST_SHARE.TOTAL_MEM) |
|
138 |
document.getElementById('textInput_reserved_mem').style.backgroundColor = 'rgba(111, 220, 111,0.5)'; |
|
139 |
if(parseInt(document.getElementById('change_bar_mem').value) < this.element.HOST_SHARE.TOTAL_MEM) |
|
140 |
document.getElementById('textInput_reserved_mem').style.backgroundColor = 'rgba(255, 80, 80,0.5)'; |
|
136 | 141 |
document.getElementById('textInput_reserved_mem').value = Humanize.size(parseInt(document.getElementById('change_bar_mem').value)); |
137 | 142 |
} |
138 | 143 |
|
... | ... | |
148 | 153 |
TemplateTable.setup(this.strippedTemplate, RESOURCE, this.element.ID, context, this.unshownTemplate); |
149 | 154 |
PermissionsTable.setup(TAB_ID, RESOURCE, this.element, context); |
150 | 155 |
|
151 |
$("", context).on("click", function(){ |
|
152 |
var dialog = Sunstone.getDialog(OVERCOMMIT_DIALOG_ID); |
|
153 |
|
|
154 |
dialog.setParams( |
|
155 |
{ element: that.element, |
|
156 |
action : "Host.append_template", |
|
157 |
resourceName : Locale.tr("Host"), |
|
158 |
tabId : TAB_ID |
|
159 |
}); |
|
160 |
|
|
161 |
dialog.show(); |
|
162 |
return false; |
|
163 |
}); |
|
164 |
|
|
165 | 156 |
//.off and .on prevent multiple clicks events |
166 | 157 |
$(document).off('click', '.update_reserved').on("click", '.update_reserved', function(){ |
167 | 158 |
var reservedCPU = parseInt(document.getElementById('change_bar_cpu').value); |
src/sunstone/public/app/tabs/hosts-tab/panels/monitor.js | ||
---|---|---|
76 | 76 |
data: { |
77 | 77 |
id: this.element.ID, |
78 | 78 |
monitor: { |
79 |
monitor_resources : "HOST_SHARE/CPU_USAGE,HOST_SHARE/USED_CPU,HOST_SHARE/MAX_CPU,HOST_SHARE/MEM_USAGE,HOST_SHARE/USED_MEM,HOST_SHARE/MAX_MEM"
|
|
79 |
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"
|
|
80 | 80 |
} |
81 | 81 |
}, |
82 | 82 |
success: function(req, response) { |
83 |
console.log(response); |
|
83 | 84 |
var host_graphs = [ |
84 | 85 |
{ |
85 |
monitor_resources : "HOST_SHARE/CPU_USAGE,HOST_SHARE/USED_CPU,HOST_SHARE/MAX_CPU", |
|
86 |
labels : Locale.tr("Allocated") + "," + Locale.tr("Real") + "," + Locale.tr("Total"), |
|
86 |
monitor_resources : "HOST_SHARE/CPU_USAGE,HOST_SHARE/USED_CPU,HOST_SHARE/MAX_CPU,HOST_SHARE/TOTAL_CPU",
|
|
87 |
labels : Locale.tr("Allocated") + "," + Locale.tr("Real") + "," + Locale.tr("Total") + "," + Locale.tr("Total +/- reserved"),
|
|
87 | 88 |
humanize_figures : false, |
88 | 89 |
div_graph : $("#host_cpu_graph"), |
89 | 90 |
div_legend : $("#host_cpu_legend") |
90 | 91 |
}, |
91 | 92 |
{ |
92 |
monitor_resources : "HOST_SHARE/MEM_USAGE,HOST_SHARE/USED_MEM,HOST_SHARE/MAX_MEM", |
|
93 |
labels : Locale.tr("Allocated") + "," + Locale.tr("Real") + "," + Locale.tr("Total"), |
|
93 |
monitor_resources : "HOST_SHARE/MEM_USAGE,HOST_SHARE/USED_MEM,HOST_SHARE/MAX_MEM,HOST_SHARE/TOTAL_MEM", |
|
94 |
labels : Locale.tr("Allocated") + "," + Locale.tr("Real") + "," + Locale.tr("Total") + "," + Locale.tr("Total +/- reserved"), |
|
95 |
humanize_figures : false, |
|
94 | 96 |
humanize_figures : true, |
95 | 97 |
div_graph : $("#host_mem_graph"), |
96 | 98 |
div_legend : $("#host_mem_legend") |
Also available in: Unified diff