[PATCH] Bugfix: UI Disable button "Create" when adding a VM
by Wen Wang
From: Wen Wang <wenwang(a)linux.vnet.ibm.com>
This patch fixed the bug when creating a VM user can still click on
"Create" button for multiple create which is not appropriate. Now the
button is disabled and show "Creating..." instead of "Create" indicate
user that the creating is in progress.
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.guest_add_main.js | 8 ++++++--
ui/pages/guest-add.html.tmpl | 1 +
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/ui/js/src/kimchi.guest_add_main.js b/ui/js/src/kimchi.guest_add_main.js
index f4affbc..df76975 100644
--- a/ui/js/src/kimchi.guest_add_main.js
+++ b/ui/js/src/kimchi.guest_add_main.js
@@ -55,17 +55,21 @@ kimchi.guest_add_main = function() {
$('#form-vm-add').change(function() {
if (validateForm()) {
- $('#vm-doAdd').removeAttr('disabled');
+ $('#vm-doAdd').attr('disabled', false);
}
});
var addGuest = function(event) {
+ $('#vm-doAdd').attr('disabled', true);
+ $('#vm-doAdd').attr('style', 'display:none');
+ $('#vm-doAdding').attr('style', 'display');
var formData = $('#form-vm-add').serializeObject();
-
kimchi.createVM(formData, function() {
kimchi.listVmsAuto();
kimchi.window.close();
}, function(jqXHR, textStatus, errorThrown) {
+ $('#vm-doAdd').attr('style', 'display');
+ $('#vm-doAdding').attr('style', 'display:none');
var reason = jqXHR &&
jqXHR['responseJSON'] &&
jqXHR['responseJSON']['reason'];
diff --git a/ui/pages/guest-add.html.tmpl b/ui/pages/guest-add.html.tmpl
index e3270fb..ab26c1e 100644
--- a/ui/pages/guest-add.html.tmpl
+++ b/ui/pages/guest-add.html.tmpl
@@ -82,6 +82,7 @@
<footer>
<div class="btn-group">
<button id="vm-doAdd" class="btn-normal" disabled="disabled" href="javascript:void(0);"><span class="text">$_("Create")</span></button>
+ <button id="vm-doAdding" class="btn-normal" disabled="disabled" style="display:none" href="javascript:void(0);"><span class="text">$_("Creating...")</span></button>
</div>
</footer>
</div>
--
1.7.1
10 years
[PATCH V5] Edit Template redefined
by Wen Wang
From: Wen Wang <wenwang(a)linux.vnet.ibm.com>
V4 -> V5:
Add support of duplicated-interface configuration in template.
V3 -> V4:
1) Deleted "save" icon for storage & interface tab.
2) Fix the bug when submitting multiple network error. Filter the
duplicated submission.
V2 -> V3:
Fix the bug that iscsi and scsi disk size won't change automatically
V1 -> V2:
1) Enable "iSCSI" and "SCSI" for storage.
2) Changed the storage tab from "storage" to "Storage".
3) Fix the defect that when editing/adding "Storage" or "Interface" line
went down issue.
4) "Storage" and "Interface" content can display properly on Remote and
Image created template.
5) Fix the defect that "Image" didn't show properly when using a Image
created template.
This patch redesigned "Edit Template" diaguage in "Templates". New "Edit
Template" will display all the related information into tabs of
"General", "Storage" and "Interface". Due to unfinished back-end work,
functions are not fully supported, which will be finished in the future
work.
Temporary disabled functions:
1) Multiple disk operation with multiple storage pools edit in template
for which reason the add button in "Storage" tab is disabled.
2) iSCSI and SCSI storage pool add is removed since we are going to
allow this kind of operation in the process of creating a VM.
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
src/kimchi/API.json | 2 -
ui/css/theme-default/template-edit.css | 116 +++++++++-----
ui/js/src/kimchi.template_edit_main.js | 280 ++++++++++++++++++++------------
ui/pages/template-edit.html.tmpl | 158 ++++++++++---------
4 files changed, 339 insertions(+), 217 deletions(-)
diff --git a/src/kimchi/API.json b/src/kimchi/API.json
index 0ad36ab..c5d7bdb 100644
--- a/src/kimchi/API.json
+++ b/src/kimchi/API.json
@@ -470,7 +470,6 @@
"description": "list of which networks will be assigned to the new VM.",
"type": "array",
"items": { "type": "string" },
- "uniqueItems": true,
"error": "KCHTMPL0017E"
},
"folder": {
@@ -641,7 +640,6 @@
"description": "list of which networks will be assigned to the new VM.",
"type": "array",
"items": { "type": "string" },
- "uniqueItems": true,
"error": "KCHTMPL0017E"
},
"folder": {
diff --git a/ui/css/theme-default/template-edit.css b/ui/css/theme-default/template-edit.css
index 4975f1b..094e909 100644
--- a/ui/css/theme-default/template-edit.css
+++ b/ui/css/theme-default/template-edit.css
@@ -17,24 +17,33 @@
*/
#template-edit-window {
font-size: 13px;
- height: 600px;
- width: 1000px;
+ height: 500px;
+ width: 800px;
}
-.template-edit-fieldset {
- float: left;
- padding: 1em;
+#edit-template-tabs {
+ background: none repeat scroll 0 0 transparent;
+ border: medium none;
+ height: 100%;
+ padding: 0;
}
-.template-edit-wrapper-label, .template-edit-wrapper-controls {
+#edit-template-tabs .form-template-inline-wrapper {
+ display: inline-block;
vertical-align: top;
- width: 470px;
}
.template-edit-wrapper-label {
- height: 18px;
- line-height: 18px;
- margin-top: 8px;
+ vertical-align: top;
+ min-width: 100px;
+ height: 35px;
+ line-height: 35px;
+ margin: 7px 0 8px;
+}
+
+.template-edit-wrapper-controls {
+ vertical-align: top;
+ width: 400px;
}
.template-edit-wrapper-controls input[type="text"] {
@@ -56,7 +65,7 @@
.template-edit-wrapper-controls > .dropdown {
margin: 5px 0 0 1px;
- width: 440px;
+ width: 372px;
}
.template-edit-wrapper-controls input[type="text"][disabled] {
@@ -65,41 +74,72 @@
cursor: not-allowed;
}
-.hidden-area {
- display: none;
+#edit-template-tabs .template-tab-header {
+ margin-bottom: 8px;
+ padding-bottom: 2px;
+ font-weight: bold;
+ border-bottom: 1px solid #999999;
+ overflow: hidden;
}
-.template-edit-wrapper-controls .select-list-box {
- width: 464px;
- max-height: 168px;
- overflow: auto;
- margin-top: 5px;
- border: 1px solid #ccc;
+#edit-template-tabs .template-tab-header .action-area {
+ float: right;
+ height: 20px;
+ width: 20px;
}
-.template-edit-wrapper-controls .select-list-box>li>label {
- display: block;
+#edit-template-tabs .template-interface-cell {
+ display: inline-block;
+ width: 250px;
}
-.template-edit-wrapper-controls .select-list-box>li>label>
-input[type="checkbox"] {
- display: none;
+#edit-template-tabs .template-storage-cell{
+ display: inline-block;
+ width: 230px;
+}
+
+#edit-template-tabs .template-storage-cell label {
+ height: 25px;
+ padding: 2px;
+ border: 1px;
}
-.template-edit-wrapper-controls .select-list-box>li>label>.item {
- display: block;
- height: 41px;
- line-height: 41px;
- padding: 0 20px 0 40px;
- border-bottom: 1px solid #ccc;
- box-shadow: 0px 1px 1px #fff;
- text-shadow: -1px -1px 1px #ddd, 1px 1px 1px #fff;
- color: #222;
- font-size: 12px;
+#form-template-storage .template-tab-body select {
+ width: 140px;
}
-.template-edit-wrapper-controls .select-list-box>li>label>
-input[type="checkbox"]:CHECKED+.item {
- background: #f8f8f8 url(../images/theme-default/check-green.png) no-repeat
- 10px center;
+#form-template-storage .template-tab-body input {
+ width: 56px;
+ height: 17px;
}
+
+#form-template-storage .template-tab-body .template-storage-name {
+ width: 220px;
+}
+
+#edit-template-tabs .template-tab-body input[readonly] {
+ background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
+ border-color: transparent;
+ text-overflow: ellipsis;
+}
+
+#edit-template-tabs .template-tab-body .item {
+ height: 25px;
+}
+
+#form-template-interface .template-tab-body select {
+ width: 180px;
+}
+
+#edit-template-tabs .template-tab-body .action-area {
+ float: right;
+}
+
+#edit-template-tabs .template-tab-body .action-area button {
+ width: 20px;
+ height: 20px;
+}
+
+#edit-template-tabs .hide {
+ display: none;
+}
\ No newline at end of file
diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js
index 2f4cc9a..d4e19c2 100644
--- a/ui/js/src/kimchi.template_edit_main.js
+++ b/ui/js/src/kimchi.template_edit_main.js
@@ -16,19 +16,23 @@
* limitations under the License.
*/
kimchi.template_edit_main = function() {
- var templateEditForm = $('#form-template-edit');
+ var templateEditMain = $('#edit-template-tabs');
var origDisks;
var origPool;
+ var origNetworks;
var templateDiskSize;
- $('#template-name', templateEditForm).val(kimchi.selectedTemplate);
- kimchi.retrieveTemplate(kimchi.selectedTemplate, function(template) {
+ $('#template-name', templateEditMain).val(kimchi.selectedTemplate);
+ templateEditMain.tabs();
+
+ var initTemplate = function(template) {
origDisks = template.disks;
origPool = template.storagepool;
+ origNetworks = template.networks;
for(var i=0;i<template.disks.length;i++){
if(template.disks[i].base){
template["vm-image"] = template.disks[i].base;
- $('#templ-edit-cdrom').addClass('hide-content');
- $('#templ-edit-vm-image').removeClass('hide-content');
+ $('.templ-edit-cdrom').addClass('hide');
+ $('.templ-edit-vm-image').removeClass('hide');
break;
}
}
@@ -37,18 +41,12 @@ kimchi.template_edit_main = function() {
if (prop == 'graphics') {
value = value["type"];
}
- $('input[name="' + prop + '"]', templateEditForm).val(value);
- }
- var disks = template.disks;
- $('input[name="disks"]').val(disks[0].size);
- templateDiskSize = $('input[name="disks"]').val();
- if (disks[0].volume) {
- var spool_value = $('#form-template-edit [name="storagepool"]').val();
- $('input[name="storagepool"]', templateEditForm).val(spool_value + '/' + disks[0].volume);
- $('input[name="disks"]', templateEditForm).attr('disabled','disabled');
+ $('input[name="' + prop + '"]', templateEditMain).val(value);
}
var vncOpt = [{label: 'VNC', value: 'vnc'}];
+ $('#template-edit-graphics').append('<option selected>VNC</option>');
+ $('#template-edit-graphics').append('<option>Spice</option>');
kimchi.select('template-edit-graphics-list', vncOpt);
var enableSpice = function() {
if (kimchi.capabilities == undefined) {
@@ -61,119 +59,199 @@ kimchi.template_edit_main = function() {
}
};
enableSpice();
-
- var scsipools = {};
- kimchi.listStoragePools(function(result) {
- var options = [];
- if (result && result.length) {
- $.each(result, function(index, storagePool) {
- if ((storagePool.state=="active") && (storagePool.type !== 'kimchi-iso')) {
- if ((storagePool.type == 'iscsi') || (storagePool.type == 'scsi')){
- scsipools[storagePool.name] = [];
- kimchi.listStorageVolumes(storagePool.name, function(result) {
- if (result && result.length) {
- $.each(result, function(index, storageVolume) {
- options.push({
- label: storagePool.name + '/' + storageVolume.name,
- value: '/storagepools/' + storagePool.name + '/' + storageVolume.name
- });
- scsipools[storagePool.name].push(storageVolume)
- });
- }
- kimchi.select('template-edit-storagePool-list', options);
- });
+ var initStorage = function(result) {
+ var scsipools = {};
+ var addStorageItem = function(storageData) {
+ var thisName = storageData.storageName;
+ var nodeStorage = $.parseHTML(kimchi.substitute($('#template-storage-pool-tmpl').html(), storageData));
+ $('.template-tab-body', '#form-template-storage').append(nodeStorage);
+ var storageOptions = '';
+ var scsiOptions = '';
+ $('select', '#form-template-storage').find('option').remove();
+ $.each(result, function(index, storageEntities) {
+ if((storageEntities.state === 'active') && (storageEntities.type != 'kimchi-iso')) {
+ if(storageEntities.type === 'iscsi' || storageEntities.type === 'scsi') {
+ kimchi.listStorageVolumes(storageEntities.name, function(currentVolume) {
+ $.each(currentVolume, function(indexSCSI, scsiEntities) {
+ var tmpPath = storageEntities.name + '/' + scsiEntities.name;
+ var isSlected = tmpPath === thisName ? ' selected' : '';
+ scsiOptions += '<option' + isSlected + '>' + tmpPath + '</option>';
+ });
+ $('select', '#form-template-storage').append(scsiOptions);
+ }, function() {});
+ } else {
+ var isSlected = storageEntities.name === thisName ? ' selected' : '';
+ storageOptions += '<option' + isSlected + '>' + storageEntities.name + '</option>';
}
- else {
- options.push({
- label: storagePool.name,
- value: '/storagepools/' + storagePool.name
- });
+ }
+ });
+ $('select', '#form-template-storage').append(storageOptions);
+ $('select', '#form-template-storage').change(function() {
+ var selectedItem = $(this).parent().parent();
+ var tempStorageNameFull = $(this).val();
+ var tempType;
+ var tempStorageName =tempStorageNameFull.split('/')[0];
+ var scsiCap;
+ $.each(result, function(index, storageEntities) {
+ if (tempStorageName === storageEntities.name) {
+ selectedItem.find('.template-storage-type').val(storageEntities.type);
+ scsiCap = storageEntities.capacity / Math.pow(1024, 3);
+ tempType = storageEntities.type;
}
+ });
+ if (tempType === 'iscsi' || tempType === 'scsi') {
+ $('.template-storage-disk', selectedItem).attr('readonly', true).val(scsiCap);
+ } else {
+ $('.template-storage-disk', selectedItem).attr('readonly', false).val('10');
}
+ $('.template-storage-name').val(tempStorageNameFull);
});
+ };
+
+ if ((origDisks && origDisks.length) && (origPool && origPool.length)) {
+ splitPool = origPool.split('/');
+ var defaultPool;
+ var defaultType;
+ $.each(result, function(index, poolEntities) {
+ if (poolEntities.name === splitPool[splitPool.length-1]) {
+ defaultType = poolEntities.type;
+ defaultPool = splitPool[splitPool.length-1]
+ }
+ });
+ if (origDisks[0]['volume']) {
+ defaultPool = defaultPool + '/' + origDisks[0]['volume'];
+ }
+ $.each(origDisks, function(index, diskEntities) {
+ var storageNodeData = {
+ viewMode : '',
+ editMode : 'hide',
+ storageName : defaultPool,
+ storageType : defaultType,
+ storageDisk : diskEntities.size
+ }
+ addStorageItem(storageNodeData);
+ });
+ if(defaultType === 'iscsi' || defaultType === 'scsi') {
+ $('.template-storage-disk').attr('readonly', true);
+ }
}
- if ($.isEmptyObject(scsipools)) {
- kimchi.select('template-edit-storagePool-list', options);
- }
- });
- kimchi.listNetworks(function(result) {
- if(result && result.length > 0) {
- var html = '';
- var tmpl = $('#tmpl-network').html();
- $.each(result, function(index, network) {
- if (result[index].state === 'active')
- html += kimchi.substitute(tmpl, network);
+
+ $('#template-edit-storage-add-button').button({
+ icons: {
+ primary: "ui-icon-plusthick"
+ },
+ text: false,
+ disabled: true
+ }).click(function(event) {
+ event.preventDefault();
+ var storageNodeData = {
+ viewMode : 'hide',
+ editMode : '',
+ storageName : 'null',
+ storageType : 'dir',
+ storageDisk : '10'
+ }
+ addStorageItem(storageNodeData);
+ });
+ };
+ var initInterface = function(result) {
+ var networkItemNum = 0;
+ var addInterfaceItem = function(networkData) {
+ var networkName = networkData.networkV;
+ var nodeInterface = $.parseHTML(kimchi.substitute($('#template-interface-tmpl').html(), networkData));
+ $('.template-tab-body', '#form-template-interface').append(nodeInterface);
+ $('.delete', '#form-template-interface').button({
+ icons : {primary : 'ui-icon-trash'},
+ text : false
+ }).click(function(evt) {
+ evt.preventDefault();
+ $(this).parent().parent().remove();
});
- $('#template-edit-network-list').html(html).show();
- if(template.networks && template.networks.length > 0) {
- $('input[name="networks"]', templateEditForm).each(function(index, element) {
- var value = $(element).val();
- if(template.networks.indexOf(value) >= 0) {
- $(element).prop('checked', true);
- }
+ var networkOptions = '';
+ for(var i=0;i<result.length;i++){
+ if(result[i].state === "active") {
+ var isSlected = networkName===result[i].name ? ' selected' : '';
+ networkOptions += '<option' + isSlected + '>' + result[i].name + '</option>';
+ }
+ }
+ $('select', '#form-template-interface #networkID' + networkItemNum).append(networkOptions);
+ networkItemNum += 1;
+ };
+ if(result && result.length > 0) {
+ for(var i=0;i<origNetworks.length;i++) {
+ addInterfaceItem({
+ networkID : 'networkID' + networkItemNum,
+ networkV : origNetworks[i],
+ type : 'network'
});
}
- } else {
- $('#template-edit-network-list').hide();
}
- });
- });
-
- $('#template-edit-storagePool').change(function() {
- storagepool = $(this).val();
- var storageArray = storagepool.split("/");
- if (storageArray.length > 3) {
- volumeName = storageArray.pop();
- poolName = storageArray.pop();
- kimchi.getStoragePoolVolume(poolName, volumeName, function(result) {
- $('input[name="disks"]', templateEditForm).val(result.capacity / Math.pow(1024,3));
- $('input[name="disks"]', templateEditForm).attr('disabled','disabled');
- return false;
- }, function (err) {
- kimchi.message.error(err.responseJSON.reason);
+ $('#template-edit-interface-add-button').button({
+ icons: {
+ primary: 'ui-icon-plusthick'
+ },
+ text: false
+ }).click(function(evt) {
+ evt.preventDefault();
+ addInterfaceItem({
+ networkID : 'networkID' + networkItemNum,
+ networkV : 'default',
+ type : 'network'
+ });
});
- } else {
- $('input[name="disks"]', templateEditForm).removeAttr('disabled');
- $('input[name="disks"]', templateEditForm).val(templateDiskSize);
- }
- });
- $('input[name="disks"]', templateEditForm).keyup(function() {
- templateDiskSize = $('input[name="disks"]', templateEditForm).val();
- });
+ };
+ kimchi.listNetworks(initInterface);
+ kimchi.listStoragePools(initStorage);
+ };
+ kimchi.retrieveTemplate(kimchi.selectedTemplate, initTemplate);
+
$('#tmpl-edit-button-save').on('click', function() {
- var editableFields = [ 'name', 'cpus', 'memory', 'storagepool', 'disks', 'graphics'];
+ var editableFields = [ 'name', 'cpus', 'memory', 'disks', 'graphics'];
var data = {};
+ //Fix me: Only support one storage pool now
+ var storages = $('.template-tab-body .item', '#form-template-storage');
+ var tempName = $('.template-storage-name', storages).val();
+ tempName = tempName.split('/');
+ var tempNameHead =tempName[0];
+ var tempNameTail = tempNameHead;
+ if(tempNameHead === 'iscsi' || tempNameHead =='scsi') {
+ tempNameTail = tempName[tempName.length-1];
+ }
+ tempName = '/storagepools/' + tempNameHead;
+ data['storagepool'] = tempName;
$.each(editableFields, function(i, field) {
/* Support only 1 disk at this moment */
if (field == 'disks') {
- origDisks[0].size = Number($('#form-template-edit [name="' + field + '"]').val());
+ var tmpItem = $('#form-template-storage .item');
+ origDisks[0].size = Number($('.template-storage-disk', tmpItem).val());
+ if($('.template-storage-type', tmpItem).val() === 'iscsi' || $('.template-storage-type', tmpItem).val() =='scsi') {
+ origDisks[0]['volume'] = tempNameTail;
+ } else {
+ origDisks[0]['volume'] && delete origDisks[0]['volume'];
+ }
data[field] = origDisks;
}
else if (field == 'graphics') {
- var type = $('#form-template-edit [name="' + field + '"]').val();
+ var type = $('#form-template-general [name="' + field + '"]').val();
data[field] = {'type': type};
}
else {
- data[field] = $('#form-template-edit [name="' + field + '"]').val();
+ data[field] = $('#form-template-general [name="' + field + '"]').val();
}
});
data['memory'] = Number(data['memory']);
data['cpus'] = Number(data['cpus']);
- storagepool = data['storagepool'];
- storageArray = storagepool.split("/");
- if (storageArray.length > 3){
- /* Support only 1 disk at this moment */
- data["disks"][0].volume = storageArray.pop();
- data['storagepool'] = storageArray.join("/");
- } else if (data["disks"][0].volume) {
- delete data["disks"][0].volume;
- }
- var networks = templateEditForm.serializeObject().networks;
- if (networks instanceof Array) {
- data.networks = networks;
- } else if (networks != null) {
- data.networks = [networks];
+ var networks = $('.template-tab-body .item', '#form-template-interface');
+ var networkForUpdate = new Array();
+ $.each(networks, function(index, networkEntities) {
+ var thisValue = $('select', networkEntities).val();
+ networkForUpdate.push(thisValue);
+ });
+ if (networkForUpdate instanceof Array) {
+ data.networks = networkForUpdate;
+ } else if (networkForUpdate != null) {
+ data.networks = [networkForUpdate];
} else {
data.networks = [];
}
diff --git a/ui/pages/template-edit.html.tmpl b/ui/pages/template-edit.html.tmpl
index 5a71d91..3515546 100644
--- a/ui/pages/template-edit.html.tmpl
+++ b/ui/pages/template-edit.html.tmpl
@@ -28,74 +28,67 @@
<div class="close">X</div>
</header>
<div class="content">
- <form id="form-template-edit">
+ <div id="edit-template-tabs">
<input type="hidden" id="template-name" name="templateName" />
- <fieldset class="template-edit-fieldset">
- <div>
+ <ul>
+ <li>
+ <a href="#form-template-general">$_("General")</a>
+ </li>
+ <li>
+ <a href="#form-template-storage">$_("Storage")</a>
+ </li>
+ <li>
+ <a href="#form-template-interface">$_("Interface")</a>
+ </li>
+ </ul>
+ <form id="form-template-general">
+ <div class="form-template-inline-wrapper">
<div class="template-edit-wrapper-label">
<label for="template-edit-id-textbox">$_("Name")</label>
</div>
- <div class="template-edit-wrapper-controls">
- <input id="template-edit-id-textbox" name="name" type="text" />
- </div>
- </div>
- <div>
<div class="template-edit-wrapper-label">
<label for="template-edit-vendor-textbox">$_("Vendor")</label>
</div>
- <div class="template-edit-wrapper-controls">
- <input id="template-edit-vendor-textbox" name="os_distro" type="text" disabled="disabled" />
- </div>
- </div>
- <div>
<div class="template-edit-wrapper-label">
<label for="template-edit-version-textbox">$_("Version")</label>
</div>
- <div class="template-edit-wrapper-controls">
- <input id="template-edit-version-textbox" name="os_version" type="text" disabled="disabled" />
- </div>
- </div>
- <div>
<div class="template-edit-wrapper-label">
<label for="template-edit-cpu-textbox">$_("CPU Number")</label>
</div>
- <div class="template-edit-wrapper-controls">
- <input id="template-edit-cpu-textbox" name="cpus" type="text" />
- </div>
- </div>
- <div>
<div class="template-edit-wrapper-label">
<label for="template-edit-memory-textbox">$_("Memory (MB)")</label>
</div>
- <div class="template-edit-wrapper-controls">
- <input id="template-edit-memory-textbox" name="memory" type="text" />
+ <div class="template-edit-wrapper-label templ-edit-cdrom">
+ <label for="template-edit-cdrom-textbox">$_("CDROM")</label>
+ </div>
+ <div class="template-edit-wrapper-label templ-edit-vm-image hide">
+ <label for="template-edit-vmimage-textbox">$_("Image File")</label>
</div>
- </div>
- <div>
<div class="template-edit-wrapper-label">
- <label for="template-edit-disk-textbox">$_("Disk (GB)")</label>
+ <label>$_("Graphics")</label>
</div>
+ </div>
+ <div class="form-template-inline-wrapper">
<div class="template-edit-wrapper-controls">
- <input id="template-edit-disk-textbox" name="disks" type="text" />
+ <input id="template-edit-id-textbox" name="name" type="text" />
</div>
- </div>
- </fieldset>
- <fieldset class="template-edit-fieldset">
- <div id="templ-edit-cdrom">
- <div class="template-edit-wrapper-label">
- <label for="template-edit-cdrom-textbox">$_("CDROM")</label>
+ <div class="template-edit-wrapper-controls">
+ <input id="template-edit-vendor-textbox" name="os_distro" type="text" disabled="disabled" />
</div>
<div class="template-edit-wrapper-controls">
- <input id="template-edit-cdrom-textbox" name="cdrom" type="text" disabled="disabled"/>
+ <input id="template-edit-version-textbox" name="os_version" type="text" disabled="disabled" />
</div>
- </div>
- <div id="templ-edit-vm-image" class="hide-content">
- <div class="template-edit-wrapper-label">$_("Image File")</div>
- <div class="template-edit-wrapper-controls"><input name="vm-image" type="text" disabled/></div>
- </div>
- <div>
- <div class="template-edit-wrapper-label">
- <label>$_("Graphics")</label>
+ <div class="template-edit-wrapper-controls">
+ <input id="template-edit-cpu-textbox" name="cpus" type="text" />
+ </div>
+ <div class="template-edit-wrapper-controls">
+ <input id="template-edit-memory-textbox" name="memory" type="text" />
+ </div>
+ <div class="template-edit-wrapper-controls templ-edit-cdrom">
+ <input id="template-edit-cdrom-textbox" name="cdrom" type="text" disabled="disabled" />
+ </div>
+ <div class="template-edit-wrapper-controls templ-edit-vm-image hide">
+ <input id="template-edit-vmimage-textbox" name="vm-image" type="text" disabled="disabled" />
</div>
<div class="template-edit-wrapper-controls">
<div class="btn dropdown popable">
@@ -108,40 +101,26 @@
</div>
</div>
</div>
- <div>
- <div class="template-edit-wrapper-label">
- <label>$_("Storage Pool")</label>
- </div>
- <div class="template-edit-wrapper-controls">
- <div class="btn dropdown popable">
- <input id="template-edit-storagePool" name="storagepool" type="hidden" />
- <span class="text" id="template-edit-storage-label"></span><span class="arrow"></span>
- <div class="popover" style="width: 100%">
- <ul class="select-list" id="template-edit-storagePool-list" data-target="template-edit-storagePool" data-label="template-edit-storage-label">
- </ul>
- </div>
- </div>
- </div>
+ </form>
+ <form id="form-template-storage">
+ <div class="template-tab-header">
+ <span class="template-storage-cell">$_("Storage Pool")</span>
+ <span class="template-storage-cell">$_("Type")</span>
+ <span class="template-storage-cell">$_("Disk(GB)")</span>
+ <button type="button" id="template-edit-storage-add-button" class="action-area"></button>
</div>
- <div>
- <div class="template-edit-wrapper-label">
- <label>$_("Network")</label>
- </div>
- <div class="template-edit-wrapper-controls">
- <ul class="select-list-box" id="template-edit-network-list">
- </ul>
- <script id="tmpl-network" type="text/html">
- <li>
- <label>
- <input name="networks" type="checkbox" value="{name}" />
- <span class="item">{name}</span>
- </label>
- </li>
- </script>
- </div>
+ <div class="template-tab-body">
</div>
- </fieldset>
- </form>
+ </form>
+ <form id="form-template-interface">
+ <div class="template-tab-header">
+ <span class="template-interface-cell">$_("Network")</span>
+ <span class="template-interface-cell">$_("Type")</span>
+ <button type="button" id="template-edit-interface-add-button" class="action-area"></button>
+ </div>
+ <div class="template-tab-body"></div>
+ </form>
+ </div>
</div>
<footer>
<div class="btn-group">
@@ -152,3 +131,30 @@
<script>
kimchi.template_edit_main();
</script>
+<script id="template-storage-pool-tmpl" type="text/html">
+ <div class='item'>
+ <span class="template-storage-cell">
+ <input class="template-storage-name" value={storageName} type="text" style="display:none" />
+ <select></select>
+ </span>
+ <span class="template-storage-cell">
+ <input class="template-storage-type" value={storageType} readonly=true type="text" />
+ </span>
+ <span class="template-storage-cell">
+ <input class="template-storage-disk" value={storageDisk} type="text" />
+ </span>
+ </div>
+</script>
+<script id="template-interface-tmpl" type="text/html">
+ <div class="item" id={networkID}>
+ <span class="template-interface-cell">
+ <select></select>
+ </span>
+ <span class="template-interface-cell">
+ <input value={type} readonly=true type="text" />
+ </span>
+ <span class="action-area">
+ <button class="delete"></button>
+ </span>
+ </div>
+</script>
\ No newline at end of file
--
1.7.1
10 years
[PATCH 0/2] Snapshot bugfixes
by Crístian Viana
Crístian Viana (2):
Return empty dict when request body is empty
bugfix: Use correct error code when current snapshot does not exist
src/kimchi/control/utils.py | 3 +++
src/kimchi/model/vmsnapshots.py | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
--
1.9.3
10 years
[PATCH V4] Edit Template redefined
by Wen Wang
From: Wen Wang <wenwang(a)linux.vnet.ibm.com>
V3 -> V4:
1) Deleted "save" icon for storage & interface tab.
2) Fix the bug when submitting multiple network error. Filter the
duplicated submission.
V2 -> V3:
Fix the bug that iscsi and scsi disk size won't change automatically
V1 -> V2:
1) Enable "iSCSI" and "SCSI" for storage.
2) Changed the storage tab from "storage" to "Storage".
3) Fix the defect that when editing/adding "Storage" or "Interface" line
went down issue.
4) "Storage" and "Interface" content can display properly on Remote and
Image created template.
5) Fix the defect that "Image" didn't show properly when using a Image
created template.
This patch redesigned "Edit Template" diaguage in "Templates". New "Edit
Template" will display all the related information into tabs of
"General", "Storage" and "Interface". Due to unfinished back-end work,
functions are not fully supported, which will be finished in the future
work.
Temporary disabled functions:
1) Multiple disk operation with multiple storage pools edit in template
for which reason the add button in "Storage" tab is disabled.
2) iSCSI and SCSI storage pool add is removed since we are going to
allow this kind of operation in the process of creating a VM.
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/css/theme-default/template-edit.css | 116 +++++++++-----
ui/js/src/kimchi.template_edit_main.js | 286 ++++++++++++++++++++-----------
ui/pages/template-edit.html.tmpl | 158 +++++++++---------
3 files changed, 344 insertions(+), 216 deletions(-)
diff --git a/ui/css/theme-default/template-edit.css b/ui/css/theme-default/template-edit.css
index 4975f1b..094e909 100644
--- a/ui/css/theme-default/template-edit.css
+++ b/ui/css/theme-default/template-edit.css
@@ -17,24 +17,33 @@
*/
#template-edit-window {
font-size: 13px;
- height: 600px;
- width: 1000px;
+ height: 500px;
+ width: 800px;
}
-.template-edit-fieldset {
- float: left;
- padding: 1em;
+#edit-template-tabs {
+ background: none repeat scroll 0 0 transparent;
+ border: medium none;
+ height: 100%;
+ padding: 0;
}
-.template-edit-wrapper-label, .template-edit-wrapper-controls {
+#edit-template-tabs .form-template-inline-wrapper {
+ display: inline-block;
vertical-align: top;
- width: 470px;
}
.template-edit-wrapper-label {
- height: 18px;
- line-height: 18px;
- margin-top: 8px;
+ vertical-align: top;
+ min-width: 100px;
+ height: 35px;
+ line-height: 35px;
+ margin: 7px 0 8px;
+}
+
+.template-edit-wrapper-controls {
+ vertical-align: top;
+ width: 400px;
}
.template-edit-wrapper-controls input[type="text"] {
@@ -56,7 +65,7 @@
.template-edit-wrapper-controls > .dropdown {
margin: 5px 0 0 1px;
- width: 440px;
+ width: 372px;
}
.template-edit-wrapper-controls input[type="text"][disabled] {
@@ -65,41 +74,72 @@
cursor: not-allowed;
}
-.hidden-area {
- display: none;
+#edit-template-tabs .template-tab-header {
+ margin-bottom: 8px;
+ padding-bottom: 2px;
+ font-weight: bold;
+ border-bottom: 1px solid #999999;
+ overflow: hidden;
}
-.template-edit-wrapper-controls .select-list-box {
- width: 464px;
- max-height: 168px;
- overflow: auto;
- margin-top: 5px;
- border: 1px solid #ccc;
+#edit-template-tabs .template-tab-header .action-area {
+ float: right;
+ height: 20px;
+ width: 20px;
}
-.template-edit-wrapper-controls .select-list-box>li>label {
- display: block;
+#edit-template-tabs .template-interface-cell {
+ display: inline-block;
+ width: 250px;
}
-.template-edit-wrapper-controls .select-list-box>li>label>
-input[type="checkbox"] {
- display: none;
+#edit-template-tabs .template-storage-cell{
+ display: inline-block;
+ width: 230px;
+}
+
+#edit-template-tabs .template-storage-cell label {
+ height: 25px;
+ padding: 2px;
+ border: 1px;
}
-.template-edit-wrapper-controls .select-list-box>li>label>.item {
- display: block;
- height: 41px;
- line-height: 41px;
- padding: 0 20px 0 40px;
- border-bottom: 1px solid #ccc;
- box-shadow: 0px 1px 1px #fff;
- text-shadow: -1px -1px 1px #ddd, 1px 1px 1px #fff;
- color: #222;
- font-size: 12px;
+#form-template-storage .template-tab-body select {
+ width: 140px;
}
-.template-edit-wrapper-controls .select-list-box>li>label>
-input[type="checkbox"]:CHECKED+.item {
- background: #f8f8f8 url(../images/theme-default/check-green.png) no-repeat
- 10px center;
+#form-template-storage .template-tab-body input {
+ width: 56px;
+ height: 17px;
}
+
+#form-template-storage .template-tab-body .template-storage-name {
+ width: 220px;
+}
+
+#edit-template-tabs .template-tab-body input[readonly] {
+ background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
+ border-color: transparent;
+ text-overflow: ellipsis;
+}
+
+#edit-template-tabs .template-tab-body .item {
+ height: 25px;
+}
+
+#form-template-interface .template-tab-body select {
+ width: 180px;
+}
+
+#edit-template-tabs .template-tab-body .action-area {
+ float: right;
+}
+
+#edit-template-tabs .template-tab-body .action-area button {
+ width: 20px;
+ height: 20px;
+}
+
+#edit-template-tabs .hide {
+ display: none;
+}
\ No newline at end of file
diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js
index 2f4cc9a..070ba20 100644
--- a/ui/js/src/kimchi.template_edit_main.js
+++ b/ui/js/src/kimchi.template_edit_main.js
@@ -16,19 +16,23 @@
* limitations under the License.
*/
kimchi.template_edit_main = function() {
- var templateEditForm = $('#form-template-edit');
+ var templateEditMain = $('#edit-template-tabs');
var origDisks;
var origPool;
+ var origNetworks;
var templateDiskSize;
- $('#template-name', templateEditForm).val(kimchi.selectedTemplate);
- kimchi.retrieveTemplate(kimchi.selectedTemplate, function(template) {
+ $('#template-name', templateEditMain).val(kimchi.selectedTemplate);
+ templateEditMain.tabs();
+
+ var initTemplate = function(template) {
origDisks = template.disks;
origPool = template.storagepool;
+ origNetworks = template.networks;
for(var i=0;i<template.disks.length;i++){
if(template.disks[i].base){
template["vm-image"] = template.disks[i].base;
- $('#templ-edit-cdrom').addClass('hide-content');
- $('#templ-edit-vm-image').removeClass('hide-content');
+ $('.templ-edit-cdrom').addClass('hide');
+ $('.templ-edit-vm-image').removeClass('hide');
break;
}
}
@@ -37,18 +41,12 @@ kimchi.template_edit_main = function() {
if (prop == 'graphics') {
value = value["type"];
}
- $('input[name="' + prop + '"]', templateEditForm).val(value);
- }
- var disks = template.disks;
- $('input[name="disks"]').val(disks[0].size);
- templateDiskSize = $('input[name="disks"]').val();
- if (disks[0].volume) {
- var spool_value = $('#form-template-edit [name="storagepool"]').val();
- $('input[name="storagepool"]', templateEditForm).val(spool_value + '/' + disks[0].volume);
- $('input[name="disks"]', templateEditForm).attr('disabled','disabled');
+ $('input[name="' + prop + '"]', templateEditMain).val(value);
}
var vncOpt = [{label: 'VNC', value: 'vnc'}];
+ $('#template-edit-graphics').append('<option selected>VNC</option>');
+ $('#template-edit-graphics').append('<option>Spice</option>');
kimchi.select('template-edit-graphics-list', vncOpt);
var enableSpice = function() {
if (kimchi.capabilities == undefined) {
@@ -61,119 +59,203 @@ kimchi.template_edit_main = function() {
}
};
enableSpice();
-
- var scsipools = {};
- kimchi.listStoragePools(function(result) {
- var options = [];
- if (result && result.length) {
- $.each(result, function(index, storagePool) {
- if ((storagePool.state=="active") && (storagePool.type !== 'kimchi-iso')) {
- if ((storagePool.type == 'iscsi') || (storagePool.type == 'scsi')){
- scsipools[storagePool.name] = [];
- kimchi.listStorageVolumes(storagePool.name, function(result) {
- if (result && result.length) {
- $.each(result, function(index, storageVolume) {
- options.push({
- label: storagePool.name + '/' + storageVolume.name,
- value: '/storagepools/' + storagePool.name + '/' + storageVolume.name
- });
- scsipools[storagePool.name].push(storageVolume)
- });
- }
- kimchi.select('template-edit-storagePool-list', options);
- });
- }
- else {
- options.push({
- label: storagePool.name,
- value: '/storagepools/' + storagePool.name
- });
+ var initStorage = function(result) {
+ var scsipools = {};
+ var addStorageItem = function(storageData) {
+ var thisName = storageData.storageName;
+ var nodeStorage = $.parseHTML(kimchi.substitute($('#template-storage-pool-tmpl').html(), storageData));
+ $('.template-tab-body', '#form-template-storage').append(nodeStorage);
+ var storageOptions = '';
+ var scsiOptions = '';
+ $('select', '#form-template-storage').find('option').remove();
+ $.each(result, function(index, storageEntities) {
+ if((storageEntities.state === 'active') && (storageEntities.type != 'kimchi-iso')) {
+ if(storageEntities.type === 'iscsi' || storageEntities.type === 'scsi') {
+ kimchi.listStorageVolumes(storageEntities.name, function(currentVolume) {
+ $.each(currentVolume, function(indexSCSI, scsiEntities) {
+ var tmpPath = storageEntities.name + '/' + scsiEntities.name;
+ var isSlected = tmpPath === thisName ? ' selected' : '';
+ scsiOptions += '<option' + isSlected + '>' + tmpPath + '</option>';
+ });
+ $('select', '#form-template-storage').append(scsiOptions);
+ }, function() {});
+ } else {
+ var isSlected = storageEntities.name === thisName ? ' selected' : '';
+ storageOptions += '<option' + isSlected + '>' + storageEntities.name + '</option>';
}
}
});
- }
- if ($.isEmptyObject(scsipools)) {
- kimchi.select('template-edit-storagePool-list', options);
- }
- });
- kimchi.listNetworks(function(result) {
- if(result && result.length > 0) {
- var html = '';
- var tmpl = $('#tmpl-network').html();
- $.each(result, function(index, network) {
- if (result[index].state === 'active')
- html += kimchi.substitute(tmpl, network);
- });
- $('#template-edit-network-list').html(html).show();
- if(template.networks && template.networks.length > 0) {
- $('input[name="networks"]', templateEditForm).each(function(index, element) {
- var value = $(element).val();
- if(template.networks.indexOf(value) >= 0) {
- $(element).prop('checked', true);
+ $('select', '#form-template-storage').append(storageOptions);
+ $('select', '#form-template-storage').change(function() {
+ var selectedItem = $(this).parent().parent();
+ var tempStorageNameFull = $(this).val();
+ var tempType;
+ var tempStorageName =tempStorageNameFull.split('/')[0];
+ var scsiCap;
+ $.each(result, function(index, storageEntities) {
+ if (tempStorageName === storageEntities.name) {
+ selectedItem.find('.template-storage-type').val(storageEntities.type);
+ scsiCap = storageEntities.capacity / Math.pow(1024, 3);
+ tempType = storageEntities.type;
}
});
+ if (tempType === 'iscsi' || tempType === 'scsi') {
+ $('.template-storage-disk', selectedItem).attr('readonly', true).val(scsiCap);
+ } else {
+ $('.template-storage-disk', selectedItem).attr('readonly', false).val('10');
+ }
+ $('.template-storage-name').val(tempStorageNameFull);
+ });
+ };
+
+ if ((origDisks && origDisks.length) && (origPool && origPool.length)) {
+ splitPool = origPool.split('/');
+ var defaultPool;
+ var defaultType;
+ $.each(result, function(index, poolEntities) {
+ if (poolEntities.name === splitPool[splitPool.length-1]) {
+ defaultType = poolEntities.type;
+ defaultPool = splitPool[splitPool.length-1]
+ }
+ });
+ if (origDisks[0]['volume']) {
+ defaultPool = defaultPool + '/' + origDisks[0]['volume'];
+ }
+ $.each(origDisks, function(index, diskEntities) {
+ var storageNodeData = {
+ viewMode : '',
+ editMode : 'hide',
+ storageName : defaultPool,
+ storageType : defaultType,
+ storageDisk : diskEntities.size
+ }
+ addStorageItem(storageNodeData);
+ });
+ if(defaultType === 'iscsi' || defaultType === 'scsi') {
+ $('.template-storage-disk').attr('readonly', true);
}
- } else {
- $('#template-edit-network-list').hide();
}
- });
- });
- $('#template-edit-storagePool').change(function() {
- storagepool = $(this).val();
- var storageArray = storagepool.split("/");
- if (storageArray.length > 3) {
- volumeName = storageArray.pop();
- poolName = storageArray.pop();
- kimchi.getStoragePoolVolume(poolName, volumeName, function(result) {
- $('input[name="disks"]', templateEditForm).val(result.capacity / Math.pow(1024,3));
- $('input[name="disks"]', templateEditForm).attr('disabled','disabled');
- return false;
- }, function (err) {
- kimchi.message.error(err.responseJSON.reason);
+ $('#template-edit-storage-add-button').button({
+ icons: {
+ primary: "ui-icon-plusthick"
+ },
+ text: false,
+ disabled: true
+ }).click(function(event) {
+ event.preventDefault();
+ var storageNodeData = {
+ viewMode : 'hide',
+ editMode : '',
+ storageName : 'null',
+ storageType : 'dir',
+ storageDisk : '10'
+ }
+ addStorageItem(storageNodeData);
});
- } else {
- $('input[name="disks"]', templateEditForm).removeAttr('disabled');
- $('input[name="disks"]', templateEditForm).val(templateDiskSize);
- }
- });
- $('input[name="disks"]', templateEditForm).keyup(function() {
- templateDiskSize = $('input[name="disks"]', templateEditForm).val();
- });
+ };
+ var initInterface = function(result) {
+ var networkItemNum = 0;
+ var addInterfaceItem = function(networkData) {
+ var networkName = networkData.networkV;
+ var nodeInterface = $.parseHTML(kimchi.substitute($('#template-interface-tmpl').html(), networkData));
+ $('.template-tab-body', '#form-template-interface').append(nodeInterface);
+ $('.delete', '#form-template-interface').button({
+ icons : {primary : 'ui-icon-trash'},
+ text : false
+ }).click(function(evt) {
+ evt.preventDefault();
+ $(this).parent().parent().remove();
+ });
+ var networkOptions = '';
+ for(var i=0;i<result.length;i++){
+ if(result[i].state === "active") {
+ var isSlected = networkName===result[i].name ? ' selected' : '';
+ networkOptions += '<option' + isSlected + '>' + result[i].name + '</option>';
+ }
+ }
+ $('select', '#form-template-interface #networkID' + networkItemNum).append(networkOptions);
+ networkItemNum += 1;
+ };
+ if(result && result.length > 0) {
+ $.each(result, function(index, data) {
+ if($.inArray(data.name, origNetworks) > -1) {
+ addInterfaceItem({
+ networkID : 'networkID' + networkItemNum,
+ networkV : data.name,
+ type : 'network'
+ });
+ }
+ });
+ }
+ $('#template-edit-interface-add-button').button({
+ icons: {
+ primary: 'ui-icon-plusthick'
+ },
+ text: false
+ }).click(function(evt) {
+ evt.preventDefault();
+ addInterfaceItem({
+ networkID : 'networkID' + networkItemNum,
+ networkV : 'default',
+ type : 'network'
+ });
+ });
+ };
+ kimchi.listNetworks(initInterface);
+ kimchi.listStoragePools(initStorage);
+ };
+ kimchi.retrieveTemplate(kimchi.selectedTemplate, initTemplate);
+
$('#tmpl-edit-button-save').on('click', function() {
- var editableFields = [ 'name', 'cpus', 'memory', 'storagepool', 'disks', 'graphics'];
+ var editableFields = [ 'name', 'cpus', 'memory', 'disks', 'graphics'];
var data = {};
+ //Fix me: Only support one storage pool now
+ var storages = $('.template-tab-body .item', '#form-template-storage');
+ var tempName = $('.template-storage-name', storages).val();
+ tempName = tempName.split('/');
+ var tempNameHead =tempName[0];
+ var tempNameTail = tempNameHead;
+ if(tempNameHead === 'iscsi' || tempNameHead =='scsi') {
+ tempNameTail = tempName[tempName.length-1];
+ }
+ tempName = '/storagepools/' + tempNameHead;
+ data['storagepool'] = tempName;
$.each(editableFields, function(i, field) {
/* Support only 1 disk at this moment */
if (field == 'disks') {
- origDisks[0].size = Number($('#form-template-edit [name="' + field + '"]').val());
+ var tmpItem = $('#form-template-storage .item');
+ origDisks[0].size = Number($('.template-storage-disk', tmpItem).val());
+ if($('.template-storage-type', tmpItem).val() === 'iscsi' || $('.template-storage-type', tmpItem).val() =='scsi') {
+ origDisks[0]['volume'] = tempNameTail;
+ } else {
+ origDisks[0]['volume'] && delete origDisks[0]['volume'];
+ }
data[field] = origDisks;
}
else if (field == 'graphics') {
- var type = $('#form-template-edit [name="' + field + '"]').val();
+ var type = $('#form-template-general [name="' + field + '"]').val();
data[field] = {'type': type};
}
else {
- data[field] = $('#form-template-edit [name="' + field + '"]').val();
+ data[field] = $('#form-template-general [name="' + field + '"]').val();
}
});
data['memory'] = Number(data['memory']);
data['cpus'] = Number(data['cpus']);
- storagepool = data['storagepool'];
- storageArray = storagepool.split("/");
- if (storageArray.length > 3){
- /* Support only 1 disk at this moment */
- data["disks"][0].volume = storageArray.pop();
- data['storagepool'] = storageArray.join("/");
- } else if (data["disks"][0].volume) {
- delete data["disks"][0].volume;
- }
- var networks = templateEditForm.serializeObject().networks;
- if (networks instanceof Array) {
- data.networks = networks;
- } else if (networks != null) {
- data.networks = [networks];
+ var networks = $('.template-tab-body .item', '#form-template-interface');
+ var networkForUpdate = new Array();
+ $.each(networks, function(index, networkEntities) {
+ var thisValue = $('select', networkEntities).val();
+ if($.inArray(thisValue, networkForUpdate) === -1) {
+ networkForUpdate.push(thisValue);
+ }
+ });
+ if (networkForUpdate instanceof Array) {
+ data.networks = networkForUpdate;
+ } else if (networkForUpdate != null) {
+ data.networks = [networkForUpdate];
} else {
data.networks = [];
}
diff --git a/ui/pages/template-edit.html.tmpl b/ui/pages/template-edit.html.tmpl
index 5a71d91..3515546 100644
--- a/ui/pages/template-edit.html.tmpl
+++ b/ui/pages/template-edit.html.tmpl
@@ -28,74 +28,67 @@
<div class="close">X</div>
</header>
<div class="content">
- <form id="form-template-edit">
+ <div id="edit-template-tabs">
<input type="hidden" id="template-name" name="templateName" />
- <fieldset class="template-edit-fieldset">
- <div>
+ <ul>
+ <li>
+ <a href="#form-template-general">$_("General")</a>
+ </li>
+ <li>
+ <a href="#form-template-storage">$_("Storage")</a>
+ </li>
+ <li>
+ <a href="#form-template-interface">$_("Interface")</a>
+ </li>
+ </ul>
+ <form id="form-template-general">
+ <div class="form-template-inline-wrapper">
<div class="template-edit-wrapper-label">
<label for="template-edit-id-textbox">$_("Name")</label>
</div>
- <div class="template-edit-wrapper-controls">
- <input id="template-edit-id-textbox" name="name" type="text" />
- </div>
- </div>
- <div>
<div class="template-edit-wrapper-label">
<label for="template-edit-vendor-textbox">$_("Vendor")</label>
</div>
- <div class="template-edit-wrapper-controls">
- <input id="template-edit-vendor-textbox" name="os_distro" type="text" disabled="disabled" />
- </div>
- </div>
- <div>
<div class="template-edit-wrapper-label">
<label for="template-edit-version-textbox">$_("Version")</label>
</div>
- <div class="template-edit-wrapper-controls">
- <input id="template-edit-version-textbox" name="os_version" type="text" disabled="disabled" />
- </div>
- </div>
- <div>
<div class="template-edit-wrapper-label">
<label for="template-edit-cpu-textbox">$_("CPU Number")</label>
</div>
- <div class="template-edit-wrapper-controls">
- <input id="template-edit-cpu-textbox" name="cpus" type="text" />
- </div>
- </div>
- <div>
<div class="template-edit-wrapper-label">
<label for="template-edit-memory-textbox">$_("Memory (MB)")</label>
</div>
- <div class="template-edit-wrapper-controls">
- <input id="template-edit-memory-textbox" name="memory" type="text" />
+ <div class="template-edit-wrapper-label templ-edit-cdrom">
+ <label for="template-edit-cdrom-textbox">$_("CDROM")</label>
+ </div>
+ <div class="template-edit-wrapper-label templ-edit-vm-image hide">
+ <label for="template-edit-vmimage-textbox">$_("Image File")</label>
</div>
- </div>
- <div>
<div class="template-edit-wrapper-label">
- <label for="template-edit-disk-textbox">$_("Disk (GB)")</label>
+ <label>$_("Graphics")</label>
</div>
+ </div>
+ <div class="form-template-inline-wrapper">
<div class="template-edit-wrapper-controls">
- <input id="template-edit-disk-textbox" name="disks" type="text" />
+ <input id="template-edit-id-textbox" name="name" type="text" />
</div>
- </div>
- </fieldset>
- <fieldset class="template-edit-fieldset">
- <div id="templ-edit-cdrom">
- <div class="template-edit-wrapper-label">
- <label for="template-edit-cdrom-textbox">$_("CDROM")</label>
+ <div class="template-edit-wrapper-controls">
+ <input id="template-edit-vendor-textbox" name="os_distro" type="text" disabled="disabled" />
</div>
<div class="template-edit-wrapper-controls">
- <input id="template-edit-cdrom-textbox" name="cdrom" type="text" disabled="disabled"/>
+ <input id="template-edit-version-textbox" name="os_version" type="text" disabled="disabled" />
</div>
- </div>
- <div id="templ-edit-vm-image" class="hide-content">
- <div class="template-edit-wrapper-label">$_("Image File")</div>
- <div class="template-edit-wrapper-controls"><input name="vm-image" type="text" disabled/></div>
- </div>
- <div>
- <div class="template-edit-wrapper-label">
- <label>$_("Graphics")</label>
+ <div class="template-edit-wrapper-controls">
+ <input id="template-edit-cpu-textbox" name="cpus" type="text" />
+ </div>
+ <div class="template-edit-wrapper-controls">
+ <input id="template-edit-memory-textbox" name="memory" type="text" />
+ </div>
+ <div class="template-edit-wrapper-controls templ-edit-cdrom">
+ <input id="template-edit-cdrom-textbox" name="cdrom" type="text" disabled="disabled" />
+ </div>
+ <div class="template-edit-wrapper-controls templ-edit-vm-image hide">
+ <input id="template-edit-vmimage-textbox" name="vm-image" type="text" disabled="disabled" />
</div>
<div class="template-edit-wrapper-controls">
<div class="btn dropdown popable">
@@ -108,40 +101,26 @@
</div>
</div>
</div>
- <div>
- <div class="template-edit-wrapper-label">
- <label>$_("Storage Pool")</label>
- </div>
- <div class="template-edit-wrapper-controls">
- <div class="btn dropdown popable">
- <input id="template-edit-storagePool" name="storagepool" type="hidden" />
- <span class="text" id="template-edit-storage-label"></span><span class="arrow"></span>
- <div class="popover" style="width: 100%">
- <ul class="select-list" id="template-edit-storagePool-list" data-target="template-edit-storagePool" data-label="template-edit-storage-label">
- </ul>
- </div>
- </div>
- </div>
+ </form>
+ <form id="form-template-storage">
+ <div class="template-tab-header">
+ <span class="template-storage-cell">$_("Storage Pool")</span>
+ <span class="template-storage-cell">$_("Type")</span>
+ <span class="template-storage-cell">$_("Disk(GB)")</span>
+ <button type="button" id="template-edit-storage-add-button" class="action-area"></button>
</div>
- <div>
- <div class="template-edit-wrapper-label">
- <label>$_("Network")</label>
- </div>
- <div class="template-edit-wrapper-controls">
- <ul class="select-list-box" id="template-edit-network-list">
- </ul>
- <script id="tmpl-network" type="text/html">
- <li>
- <label>
- <input name="networks" type="checkbox" value="{name}" />
- <span class="item">{name}</span>
- </label>
- </li>
- </script>
- </div>
+ <div class="template-tab-body">
</div>
- </fieldset>
- </form>
+ </form>
+ <form id="form-template-interface">
+ <div class="template-tab-header">
+ <span class="template-interface-cell">$_("Network")</span>
+ <span class="template-interface-cell">$_("Type")</span>
+ <button type="button" id="template-edit-interface-add-button" class="action-area"></button>
+ </div>
+ <div class="template-tab-body"></div>
+ </form>
+ </div>
</div>
<footer>
<div class="btn-group">
@@ -152,3 +131,30 @@
<script>
kimchi.template_edit_main();
</script>
+<script id="template-storage-pool-tmpl" type="text/html">
+ <div class='item'>
+ <span class="template-storage-cell">
+ <input class="template-storage-name" value={storageName} type="text" style="display:none" />
+ <select></select>
+ </span>
+ <span class="template-storage-cell">
+ <input class="template-storage-type" value={storageType} readonly=true type="text" />
+ </span>
+ <span class="template-storage-cell">
+ <input class="template-storage-disk" value={storageDisk} type="text" />
+ </span>
+ </div>
+</script>
+<script id="template-interface-tmpl" type="text/html">
+ <div class="item" id={networkID}>
+ <span class="template-interface-cell">
+ <select></select>
+ </span>
+ <span class="template-interface-cell">
+ <input value={type} readonly=true type="text" />
+ </span>
+ <span class="action-area">
+ <button class="delete"></button>
+ </span>
+ </div>
+</script>
\ No newline at end of file
--
1.7.1
10 years
[PATCH] UI: Enable Upload function in UI
by Wen Wang
From: Wen Wang <wenwang(a)linux.vnet.ibm.com>
After testing, upload funcion works and this patch did the ui change
that enable upload a volume in storage
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.storagepool_add_volume_main.js | 2 +-
ui/pages/storagepool-add-volume.html.tmpl | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui/js/src/kimchi.storagepool_add_volume_main.js b/ui/js/src/kimchi.storagepool_add_volume_main.js
index 590ccde..05c7bb1 100644
--- a/ui/js/src/kimchi.storagepool_add_volume_main.js
+++ b/ui/js/src/kimchi.storagepool_add_volume_main.js
@@ -88,12 +88,12 @@ kimchi.sp_add_volume_main = function() {
sp: kimchi.selectedSP,
formData: fd
}, function(result) {
- kimchi.window.close();
kimchi.topic('kimchi/storageVolumeAdded').publish();
}, onError);
};
$(addButton).on('click', function(event) {
+ kimchi.window.close();
$(this).prop('disabled', true);
$(typeRadios).prop('disabled', true);
if(type === 'download') {
diff --git a/ui/pages/storagepool-add-volume.html.tmpl b/ui/pages/storagepool-add-volume.html.tmpl
index 573a764..298a565 100644
--- a/ui/pages/storagepool-add-volume.html.tmpl
+++ b/ui/pages/storagepool-add-volume.html.tmpl
@@ -47,7 +47,7 @@
</div>
<div class="form-section">
<h2>
- <input type="radio" id="volume-type-upload" class="volume-type" name="volumeType" value="upload" disabled/>
+ <input type="radio" id="volume-type-upload" class="volume-type" name="volumeType" value="upload"/>
<label for="volume-type-upload">
$_("Upload an file")
</label>
--
1.7.1
10 years
[PATCHv5 0/4] LDAP authorization
by lvroyce0210@gmail.com
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
Royce Lv (4):
Split users and groups for permission query
Move validation to authorizaiton
change vm permission tag
Update test model to fix user/group listing
docs/API.md | 19 ++++++----
src/kimchi/control/groups.py | 28 ++++++++++++++
src/kimchi/control/host.py | 14 -------
src/kimchi/control/users.py | 35 +++++++++++++++++
src/kimchi/i18n.py | 1 +
src/kimchi/model/groups.py | 68 +++++++++++++++++++++++++++++++++
src/kimchi/model/host.py | 19 ----------
src/kimchi/model/users.py | 90 ++++++++++++++++++++++++++++++++++++++++++++
src/kimchi/model/vms.py | 62 +++++++++++++++++++++---------
tests/test_model.py | 3 +-
tests/test_rest.py | 4 +-
11 files changed, 281 insertions(+), 62 deletions(-)
create mode 100644 src/kimchi/control/groups.py
create mode 100644 src/kimchi/control/users.py
create mode 100644 src/kimchi/model/groups.py
create mode 100644 src/kimchi/model/users.py
--
1.8.3.2
10 years
[v2] UI: Guest Snapshot
by huoyuxin@linux.vnet.ibm.com
From: Yu Xin Huo <huoyuxin(a)linux.vnet.ibm.com>
Signed-off-by: Yu Xin Huo <huoyuxin(a)linux.vnet.ibm.com>
---
ui/css/theme-default/guest-edit.css | 34 +++++++++++-
ui/js/src/kimchi.api.js | 69 ++++++++++++++++++++++
ui/js/src/kimchi.guest_edit_main.js | 107 +++++++++++++++++++++++++++++++++++
ui/pages/guest-edit.html.tmpl | 27 +++++++++
4 files changed, 236 insertions(+), 1 deletions(-)
diff --git a/ui/css/theme-default/guest-edit.css b/ui/css/theme-default/guest-edit.css
index b1d3931..a565c99 100644
--- a/ui/css/theme-default/guest-edit.css
+++ b/ui/css/theme-default/guest-edit.css
@@ -96,6 +96,7 @@
}
#form-guest-edit-storage .header,
+.guest-edit-snapshot .header,
.guest-edit-interface .header {
margin-bottom: 8px;
padding-bottom: 2px;
@@ -105,6 +106,7 @@
}
#form-guest-edit-storage .body .item,
+.guest-edit-snapshot .body .item,
.guest-edit-interface .body .item {
margin: 5px 0;
}
@@ -115,6 +117,32 @@
width: 250px;
}
+.guest-edit-snapshot .cell {
+ display: inline-block;
+}
+
+.guest-edit-snapshot .sel {
+ width: 35px;
+ vertical-align: top;
+}
+
+.guest-edit-snapshot .icon {
+ background: url('../../images/theme-default/kimchi-loading15x15.gif') no-repeat;
+ display: inline-block;
+ width: 20px;
+ height: 20px;
+ vertical-align: middle;
+ margin-left: 2px;
+}
+
+.guest-edit-snapshot .name {
+ width: 400px;
+}
+
+.guest-edit-snapshot .created {
+ width: 250px;
+}
+
#form-guest-edit-storage .cell.dev {
width: 60px;
}
@@ -135,6 +163,7 @@
}
#form-guest-edit-storage .action-area,
+.guest-edit-snapshot .action-area,
.guest-edit-interface .action-area {
float: right;
}
@@ -144,12 +173,14 @@
}
#form-guest-edit-storage button,
+.guest-edit-snapshot button,
.guest-edit-interface button {
width: 20px;
height: 20px;
}
#form-guest-edit-storage .header button,
+.guest-edit-snapshot .header button,
.guest-edit-interface .header button {
margin-bottom: 1px;
}
@@ -159,8 +190,9 @@
margin-right: 2px;
}
+.guest-edit-snapshot .hide,
.guest-edit-interface .hide {
- display: none;
+ display: none!important;
}
.guest-edit-permission {
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index 78c6d66..a592298 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -1260,5 +1260,74 @@ var kimchi = {
kimchi.message.error(data.responseJSON.reason);
}
});
+ },
+
+ listSnapshots : function(vm, suc, err) {
+ kimchi.requestJSON({
+ url : kimchi.url+'vms/'+encodeURIComponent(vm)+'/snapshots',
+ type : 'GET',
+ contentType : 'application/json',
+ dataType : 'json',
+ resend : true,
+ success : suc,
+ error : err ? err : function(data) {
+ kimchi.message.error(data.responseJSON.reason);
+ }
+ });
+ },
+
+ getCurrentSnapshot : function(vm, suc, err, sync) {
+ kimchi.requestJSON({
+ url : kimchi.url+'vms/'+encodeURIComponent(vm)+'/snapshots/current',
+ type : 'GET',
+ contentType : 'application/json',
+ dataType : 'json',
+ async : !sync,
+ resend : true,
+ success : suc,
+ error : err ? err : function(data) {
+ if(data.status!=404) kimchi.message.error(data.responseJSON.reason);
+ }
+ });
+ },
+
+ revertSnapshot : function(vm, snapshot, suc, err) {
+ kimchi.requestJSON({
+ url : kimchi.url+'vms/'+encodeURIComponent(vm)+'/snapshots/'+encodeURIComponent(snapshot)+'/revert',
+ type : 'POST',
+ contentType : 'application/json',
+ dataType : 'json',
+ success : suc,
+ error : err ? err : function(data) {
+ kimchi.message.error(data.responseJSON.reason);
+ }
+ });
+ },
+
+ createSnapshot : function(vm, suc, err) {
+ kimchi.requestJSON({
+ url : kimchi.url+'vms/'+encodeURIComponent(vm)+'/snapshots',
+ type : 'POST',
+ contentType : 'application/json',
+ dataType : 'json',
+ data : JSON.stringify({}),
+ success : suc,
+ error : err ? err : function(data) {
+ kimchi.message.error(data.responseJSON.reason);
+ }
+ });
+ },
+
+ deleteSnapshot : function(vm, snapshot, suc, err) {
+ kimchi.requestJSON({
+ url : kimchi.url+'vms/'+encodeURIComponent(vm)+'/snapshots/'+encodeURIComponent(snapshot),
+ type : 'DELETE',
+ contentType : 'application/json',
+ dataType : 'json',
+ success : suc,
+ error : err ? err : function(data) {
+ kimchi.message.error(data.responseJSON.reason);
+ }
+ });
}
};
diff --git a/ui/js/src/kimchi.guest_edit_main.js b/ui/js/src/kimchi.guest_edit_main.js
index 9d87a73..0dc3a31 100644
--- a/ui/js/src/kimchi.guest_edit_main.js
+++ b/ui/js/src/kimchi.guest_edit_main.js
@@ -461,6 +461,112 @@ kimchi.guest_edit_main = function() {
});
};
+ var setupSnapshot = function() {
+ var currentSnapshot;
+ var postTask = function(){
+ listGeneratingSnapshots();
+ $("button", "#form-guest-edit-snapshot").button("enable");
+ };
+ var addItem = function(data, container) {
+ var itemNode = $.parseHTML(kimchi.substitute($('#snapshot-tmpl').html(),data));
+ $("."+container, "#form-guest-edit-snapshot").append(itemNode);
+ if(kimchi.thisVMState === "running") {
+ $("button", itemNode).remove();
+ }else{
+ $(".delete", itemNode).button({
+ icons: { primary: "ui-icon-trash" },
+ text: false
+ }).click(function(evt){
+ evt.preventDefault();
+ var item = $(this).parent().parent();
+ kimchi.deleteSnapshot(kimchi.selectedGuest, item.prop("id"), function(){
+ item.remove();
+ });
+ });
+ $(".revert", itemNode).button({
+ icons: { primary: "ui-icon-arrowthick-1-ne" },
+ text: false
+ }).click(function(evt){
+ evt.preventDefault();
+ var item = $(this).parent().parent();
+ $(".ui-icon-check", item).addClass("hide");
+ $(".icon", item).removeClass("hide");
+ $("button", "#form-guest-edit-snapshot").button("disable");
+ kimchi.revertSnapshot(kimchi.selectedGuest, item.prop("id"), function(){
+ currentSnapshot = item.prop("id");
+ $(".ui-icon-check", $(".body", "#form-guest-edit-snapshot")).addClass("hide");
+ $(".ui-icon-check", item).removeClass("hide");
+ $(".icon", item).addClass("hide");
+ $("button", "#form-guest-edit-snapshot").button("enable");
+ }, function(data){
+ kimchi.message.error(data.responseJSON.reason);
+ $(".icon", item).addClass("hide");
+ if(currentSnapshot) $(".ui-icon-check", currentSnapshot).removeClass("hide");
+ $("button", "#form-guest-edit-snapshot").button("enable");
+ });
+ });
+ }
+ return itemNode;
+ };
+ var addOngoingItem = function(task){
+ var uri = task.target_uri;
+ addItem({
+ name: uri.substring(uri.lastIndexOf('/')+1, uri.length),
+ created: "",
+ current: "hide",
+ listMode: "hide",
+ createMode: ""
+ }, 'task');
+ if(kimchi.trackingTasks.indexOf(task.id)==-1)
+ kimchi.trackTask(task.id, function(task){
+ postTask();
+ }, function(err){
+ kimchi.message.error(err.message);
+ postTask();
+ });
+ };
+ var listGeneratingSnapshots = function(){
+ $(".task", "#form-guest-edit-snapshot").empty();
+ kimchi.getTasksByFilter('status=running&target_uri='+encodeURIComponent('^/snapshots/*'), function(tasks) {
+ for(var i=0;i<tasks.length;i++){
+ addOngoingItem(tasks[i]);
+ }
+ if(tasks.length==0) listSnapshots();
+ });
+ };
+ var listSnapshots = function(){
+ $(".body", "#form-guest-edit-snapshot").empty();
+ kimchi.getCurrentSnapshot(kimchi.selectedGuest, function(snapshot){
+ currentSnapshot = snapshot.name;
+ });
+ kimchi.listSnapshots(kimchi.selectedGuest, function(data){
+ for(var i=0;i<data.length;i++){
+ data[i].created = new Date(data[i].created*1000).toLocaleString();
+ data[i].current = data[i].name==currentSnapshot?"":"hide";
+ data[i].createMode = "hide";
+ data[i].listMode = "";
+ var item = addItem(data[i], 'body');
+ }
+ });
+ };
+ listGeneratingSnapshots();
+ if(kimchi.thisVMState === "running") {
+ $("#form-guest-edit-snapshot .revert").remove();
+ $("#form-guest-edit-snapshot .add").remove();
+ }else{
+ $(".add", "#form-guest-edit-snapshot").button({
+ icons: { primary: "ui-icon-plusthick" },
+ text: false
+ }).click(function(evt){
+ evt.preventDefault();
+ $("button", "#form-guest-edit-snapshot").button("disable");
+ kimchi.createSnapshot(kimchi.selectedGuest, function(task){
+ addOngoingItem(task);
+ });
+ });
+ }
+ };
+
var initContent = function(guest) {
guest['icon'] = guest['icon'] || 'images/icon-vm.png';
$('#form-guest-edit-general').fillWithObject(guest);
@@ -496,6 +602,7 @@ kimchi.guest_edit_main = function() {
setupInterface();
setupPermission();
setupPCIDevice();
+ setupSnapshot();
kimchi.topic('kimchi/vmCDROMAttached').subscribe(onAttached);
kimchi.topic('kimchi/vmCDROMReplaced').subscribe(onReplaced);
diff --git a/ui/pages/guest-edit.html.tmpl b/ui/pages/guest-edit.html.tmpl
index 512909a..dd320b9 100644
--- a/ui/pages/guest-edit.html.tmpl
+++ b/ui/pages/guest-edit.html.tmpl
@@ -44,6 +44,9 @@
<li>
<a href="#form-guest-edit-pci">$_("Host PCI Device")</a>
</li>
+ <li>
+ <a href="#form-guest-edit-snapshot">$_("Snapshot")</a>
+ </li>
</ul>
<form id="form-guest-edit-general">
<fieldset class="guest-edit-fieldset">
@@ -160,6 +163,16 @@
<div class="body"></div>
</div>
</form>
+ <form id="form-guest-edit-snapshot" class="guest-edit-snapshot">
+ <div class="header">
+ <span class="cell sel"></span>
+ <span class="cell name">$_("Name")</span>
+ <span class="cell created">$_("Created")</span>
+ <button class="add action-area"></button>
+ </div>
+ <div class="task"></div>
+ <div class="body"></div>
+ </form>
</div>
</div>
<footer>
@@ -251,6 +264,20 @@
<button></button>
</div>
</script>
+<script id="snapshot-tmpl" type="text/html">
+ <div class="item" id="{name}">
+ <span class="cell sel">
+ <span class="icon {createMode}"></span>
+ <span class="ui-icon ui-icon-check {current}"></span>
+ </span>
+ <span class="cell name">{name}</span>
+ <span class="cell created">{created}</span>
+ <span class="action-area">
+ <button class="revert {listMode}" title="$_("revert")"></button>
+ <button class="delete {listMode}"></button>
+ </span>
+ <div>
+</script>
<script type="text/javascript">
kimchi.guest_edit_main();
</script>
--
1.7.1
10 years
[PATCH v5] Auto Topology for Guest Templates
by Christy Perez
1. UI calls GET host/cpuinfo
curl -k -u user -H 'Content-Type: application/json' \
-H 'Accept: application/json' https://localhost:8001/host/cpuinfo
{
"cores":2,
"threading_enabled":true,
"sockets":1,
"threads_per_core":2
}
2. UI displays appropriate title and checkboxes
- For both arches (based on Aline's suggestion),
include a checkbox that says, "Configure vCPU topology manually."
If checked, two fields appear, labeled, 'cores,' and 'threads.'
For the threads box, have another dropdown that's the same in
theory as the SMTX choices: a drop-down of 1, 2, 4, 8 (depending on
the threads_per_socket value).
Can the 'cores' box have a hover hint that lists the max?
Since sockets will never be more than one, let's list it as a static
placeholder (or leave it off completely).
Checking this box will make the CPU box inactive, and the CPU number
should now be calculated by the UI: CPUs = cores * threads (from the
new boxes).
- If that manual tickbox isn't selected:
- Display the same box for CPUs as before.
- Display a menu labled SMT (Power)/Hyper-Threads (x86) with up to five selections:
Automatic, 1, 2, 4, 8.
The max SMT value displayed will be dependant upoon threads_per_core
from above. The default option should be 'Automatic.'
For 'Automatic,' send in '0' for the threads value (#3 below).
Otherwise, pass the threads selection value (#3 below).
Note: This is more architecture-agnostic. The only difference is the label.
I'm in favor of keeping SMT somewhere in the screen for Power, since that
is how users traditionally think of this, and will look for it.
3. UI calls POST template with threads value set to '0' (x86) or SMTX (Power)
Note that vcpus is still optional, so no change in how that's handled needs
to be done.
$ curl -k -u user -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' https://localhost:8001/templates -d'{"name": "test_auto_topo", "cdrom": "/home/iso-pool/Fedora-Live-Desktop-x86_64-20-1.iso", "cpu_info": {"topology": {"threads":0}}}'
{
"cpus":1,
"cpu_info":{
"topology":{
"cores":1,
"threads":1,
"sockets":1
}
},
"graphics":{
"type":"vnc",
"listen":"127.0.0.1"
},
"cdrom":"/home/iso-pool/Fedora-Live-Desktop-x86_64-20-1.iso",
"networks":[
"default"
],
"icon":"images/icon-fedora.png",
"os_distro":"fedora",
"name":"test_auto_topo",
"disks":[
{
"index":0,
"size":10
}
],
"invalid":{},
"os_version":"20",
"storagepool":"/storagepools/default",
"memory":1024,
"folder":[]
}
Christy Perez (1):
Parts to allow Kimchi to configure the cpu topology.
docs/API.md | 28 ++++++
src/kimchi/API.json | 11 +--
src/kimchi/control/cpuinfo.py | 37 ++++++++
src/kimchi/control/host.py | 2 +
src/kimchi/i18n.py | 6 +-
src/kimchi/model/cpuinfo.py | 215 ++++++++++++++++++++++++++++++++++++++++++
src/kimchi/model/host.py | 2 +-
src/kimchi/model/templates.py | 25 +++--
8 files changed, 309 insertions(+), 17 deletions(-)
create mode 100644 src/kimchi/control/cpuinfo.py
create mode 100644 src/kimchi/model/cpuinfo.py
--
1.9.3
10 years
[PATCH] Use dedicate function to remove unused namespace
by lvroyce@linux.vnet.ibm.com
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
c5cb1515 used "cleanup_namespaces=True" to clean unused namespace.
But on rhel lxml library, this argument is not supported and result
in error:
File "./src/kimchi/model/utils.py", line 145,
in _kimchi_get_metadata_node
objectify.deannotate(kimchi, cleanup_namespaces=True)
File "lxml.objectify.pyx", line 1728,
in lxml.objectify.deannotate (src/lxml/lxml.objectify.c:17914)
TypeError: deannotate() got an unexpected keyword argument 'cleanup_namespaces'
So use a dedicate function to clean the unused namespace.
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
src/kimchi/model/utils.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/kimchi/model/utils.py b/src/kimchi/model/utils.py
index dc911a9..e02ec66 100644
--- a/src/kimchi/model/utils.py
+++ b/src/kimchi/model/utils.py
@@ -143,6 +143,7 @@ def _kimchi_get_metadata_node(dom, tag):
elem.tag = elem.tag[i+1:]
objectify.deannotate(kimchi, cleanup_namespaces=True)
+ etree.cleanup_namespaces(kimchi)
return kimchi
return None
--
1.8.3.2
10 years
[PATCH] Use dedicate function to remove unused namespace
by lvroyce@linux.vnet.ibm.com
From: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
c5cb1515 used "cleanup_namespaces=True" to clean unused namespace.
But on rhel lxml library, this argument is not supported and result
in error:
File "./src/kimchi/model/utils.py", line 145,
in _kimchi_get_metadata_node
objectify.deannotate(kimchi, cleanup_namespaces=True)
File "lxml.objectify.pyx", line 1728,
in lxml.objectify.deannotate (src/lxml/lxml.objectify.c:17914)
TypeError: deannotate() got an unexpected keyword argument 'cleanup_namespaces'
So use a dedicate function to clean the unused namespace.
Signed-off-by: Royce Lv <lvroyce(a)linux.vnet.ibm.com>
---
src/kimchi/model/utils.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/kimchi/model/utils.py b/src/kimchi/model/utils.py
index dc911a9..9896289 100644
--- a/src/kimchi/model/utils.py
+++ b/src/kimchi/model/utils.py
@@ -142,7 +142,8 @@ def _kimchi_get_metadata_node(dom, tag):
if i >= 0:
elem.tag = elem.tag[i+1:]
- objectify.deannotate(kimchi, cleanup_namespaces=True)
+ objectify.deannotate(kimchi)
+ etree.cleanup_namespaces(kimchi)
return kimchi
return None
--
1.8.3.2
10 years