Skip to content

Commit

Permalink
Adding 'sockets' field in the topology of Templates
Browse files Browse the repository at this point in the history
Following the changes of bug fix #1072, this patch adds the
'sockets' values to be editable in the CPU topology. Since
sockets is now a component of the calculation of Max CPUs of
a VM, it makes sense to allow user control of it.

As with cores and threads, the defautl value of sockets is
returned by the cpu_info API.

Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
  • Loading branch information
danielhb authored and alinefm committed Nov 24, 2016
1 parent 21e2608 commit 51c5c30
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
21 changes: 17 additions & 4 deletions ui/js/src/kimchi.template_edit_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,15 @@ kimchi.template_edit_main = function() {

var initProcessor = function(){
var setCPUValue = function(){
if(!$('#cores').hasClass("invalid-field")&&$('#cores').val()!=""){
var computedCpu = parseInt($("#cores").val())*parseInt($("#threads").val());
if(!$('#sockets').hasClass("invalid-field") &&
!$('#cores').hasClass("invalid-field") &&
$('#sockets').val()!="" && $('#cores').val()!=""){

var sockets = parseInt($("#sockets").val());
var cores = parseInt($("#cores").val());
var threads = parseInt($("#threads").val());

var computedCpu = sockets * cores * threads;
$("#vcpus").val(computedCpu);
if ($("#cpus-check").prop("checked")) {
//If topology is checked, set maxcpu to be the same as # of cpu otherwise, backend gives error
Expand All @@ -654,7 +661,10 @@ kimchi.template_edit_main = function() {
};
$("input:text", "#form-template-processor").on('keyup', function() {
$(this).toggleClass("invalid-field", !$(this).val().match('^[0-9]*$'));
if ($(this).prop('id') == 'cores') setCPUValue();
if ($(this).prop('id') == 'sockets' ||
$(this).prop('id') == 'cores') {
setCPUValue();
}
});
$("input:checkbox", "#form-template-processor").click(function() {
$('#threads').selectpicker();
Expand All @@ -680,6 +690,9 @@ kimchi.template_edit_main = function() {
if (template.cpu_info.maxvcpus) {
$("#guest-edit-max-processor-textbox").val(template.cpu_info.maxvcpus);
}
if (topo && topo.sockets) {
$("#sockets").val(topo.sockets);
}
if (topo && topo.cores) {
$("#cores").val(topo.cores);
}
Expand Down Expand Up @@ -815,7 +828,7 @@ kimchi.template_edit_main = function() {
vcpus: cpu,
maxvcpus: maxCpuFinal,
topology: {
sockets: 1,
sockets: parseInt($("#sockets").val()),
cores: parseInt($("#cores").val()),
threads: parseInt($("#threads").val())
}
Expand Down
12 changes: 7 additions & 5 deletions ui/pages/template-edit.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,17 @@
<label for="cpus-check">$_("Manually set CPU topology")</label>
</div>
<div class="topology">
<div class="form-group">
<label for="sockets">$_("Sockets")</label>
<input type="text" class="form-control" value="1" id="sockets" />
</div>
<div class="form-group">
<label for="cores">$_("Cores")</label>
<input type="text" class="form-control" value="1" id="cores" />
</div>
<div>
<div class="form-group">
<label for="threads">$_("Threads")</label>
<select id="threads" class="selectpicker col-md-12 col-lg-12"></select>
</div>
<div class="form-group">
<label for="threads">$_("Threads")</label>
<select id="threads" class="selectpicker col-md-12 col-lg-12"></select>
</div>
</div>
</form>
Expand Down

0 comments on commit 51c5c30

Please sign in to comment.