<div dir="ltr">A volume in a logical storage pool only uses the format 'raw'. Even if the user specifies a different format type, it will be 'raw' in the end. So it would be nice if the interface didn't allow the user to change the volume format for a logical pool, as it will be ignored anyway.<br><br><a href="https://libvirt.org/storage.html">https://libvirt.org/storage.html</a><br></div><br><div class="gmail_quote">On Tue, Apr 14, 2015 at 3:24 AM Rodrigo Trujillo <<a href="mailto:rodrigo.trujillo@linux.vnet.ibm.com">rodrigo.trujillo@linux.vnet.ibm.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This patch adds a new field (Disk Format) in Storage tab in Template<br>
edit window. Users will then be allowed to select any disk format<br>
supported by Libvirt and Kimchi backend.<br>
The default disk format is qcow2 (first option), so, for compatibility,<br>
if the template register in objecstore does not contain the disk format<br>
information, the new field is going to set 'qcow2' automatically.<br>
For iscsi storagepools, the new field is going to be disabled and the<br>
format is going to be set automatically as 'raw', just like the backend<br>
behaves currently, avoiding errors.<br>
<br>
Signed-off-by: Rodrigo Trujillo <<a href="mailto:rodrigo.trujillo@linux.vnet.ibm.com" target="_blank">rodrigo.trujillo@linux.vnet.ibm.com</a>><br>
---<br>
ui/css/theme-default/template-edit.css | 8 +++++--<br>
ui/js/src/kimchi.template_edit_main.js | 40 +++++++++++++++++++++++++++++-----<br>
ui/pages/template-edit.html.tmpl | 16 ++++++++++++++<br>
3 files changed, 56 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/ui/css/theme-default/template-edit.css b/ui/css/theme-default/template-edit.css<br>
index 7abee7c..ed9f02c 100644<br>
--- a/ui/css/theme-default/template-edit.css<br>
+++ b/ui/css/theme-default/template-edit.css<br>
@@ -95,7 +95,7 @@<br>
<br>
#edit-template-tabs .template-storage-cell{<br>
display: inline-block;<br>
- width: 230px;<br>
+ width: 180px;<br>
}<br>
<br>
#edit-template-tabs .template-storage-cell label {<br>
@@ -114,7 +114,11 @@<br>
}<br>
<br>
#form-template-storage .template-tab-body .template-storage-name {<br>
- width: 220px;<br>
+ width: 170px;<br>
+}<br>
+<br>
+#form-template-storage .template-tab-body .template-storage-disk-format {<br>
+ width: 160px;<br>
}<br>
<br>
#edit-template-tabs .template-tab-body input[readonly] {<br>
diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js<br>
index 85f76cd..48ae26b 100644<br>
--- a/ui/js/src/kimchi.template_edit_main.js<br>
+++ b/ui/js/src/kimchi.template_edit_main.js<br>
@@ -67,7 +67,7 @@ kimchi.template_edit_main = function() {<br>
$('.template-tab-body', '#form-template-storage').append(nodeStorage);<br>
var storageOptions = '';<br>
var scsiOptions = '';<br>
- $('select', '#form-template-storage').find('option').remove();<br>
+ $('select:first', '#form-template-storage').find('option').remove();<br>
$.each(result, function(index, storageEntities) {<br>
if((storageEntities.state === 'active') && (storageEntities.type != 'kimchi-iso')) {<br>
if(storageEntities.type === 'iscsi' || storageEntities.type === 'scsi') {<br>
@@ -77,7 +77,7 @@ kimchi.template_edit_main = function() {<br>
var isSlected = tmpPath === thisName ? ' selected' : '';<br>
scsiOptions += '<option' + isSlected + '>' + tmpPath + '</option>';<br>
});<br>
- $('select', '#form-template-storage').append(scsiOptions);<br>
+ $('select:first', '#form-template-storage').append(scsiOptions);<br>
}, function() {});<br>
} else {<br>
var isSlected = storageEntities.name === thisName ? ' selected' : '';<br>
@@ -85,8 +85,20 @@ kimchi.template_edit_main = function() {<br>
}<br>
}<br>
});<br>
- $('select', '#form-template-storage').append(storageOptions);<br>
- $('select', '#form-template-storage').change(function() {<br>
+ $('select:first', '#form-template-storage').append(storageOptions);<br>
+<br>
+ // Set disk format<br>
+ $('select:last option', '#form-template-storage').each(function() {<br>
+ if ($(this).text() == storageData.storageDiskFormat) {<br>
+ $(this).prop('selected', true);<br>
+ }<br>
+ });<br>
+<br>
+ $('select:last', '#form-template-storage').change(function() {<br>
+ $('.template-storage-disk-format').val($(this).val());<br>
+ });<br>
+<br>
+ $('select:first', '#form-template-storage').change(function() {<br>
var selectedItem = $(this).parent().parent();<br>
var tempStorageNameFull = $(this).val();<br>
var tempName = tempStorageNameFull.split('/');<br>
@@ -99,9 +111,19 @@ kimchi.template_edit_main = function() {<br>
kimchi.getStoragePoolVolume(tempStorageName, tempName[tempName.length-1], function(info) {<br>
volSize = info.capacity / Math.pow(1024, 3);<br>
$('.template-storage-disk', selectedItem).attr('readonly', true).val(volSize);<br>
+ $('select:last option', selectedItem).each(function() {<br>
+ this.selected = (this.text == 'raw');<br>
+ });<br>
+ $('select:last', selectedItem).prop('disabled', true).change();<br>
});<br>
} else {<br>
$('.template-storage-disk', selectedItem).attr('readonly', false);<br>
+ if ($('select:last', selectedItem).prop('disabled') == true) {<br>
+ $('select:last option', selectedItem).each(function() {<br>
+ this.selected = (this.text == 'qcow2');<br>
+ });<br>
+ $('select:last', selectedItem).prop('disabled', false).change();<br>
+ }<br>
}<br>
});<br>
});<br>
@@ -120,7 +142,8 @@ kimchi.template_edit_main = function() {<br>
editMode : 'hide',<br>
storageName : defaultPool,<br>
storageType : defaultType,<br>
- storageDisk : diskEntities.size<br>
+ storageDisk : diskEntities.size,<br>
+ storageDiskFormat : diskEntities.format ? diskEntities.format : 'qcow2'<br>
}<br>
<br>
if (diskEntities.volume) {<br>
@@ -131,6 +154,10 @@ kimchi.template_edit_main = function() {<br>
nodeData.storageDisk = volSize;<br>
addStorageItem(nodeData);<br>
$('.template-storage-disk').attr('readonly', true);<br>
+ $('select:last option', '#form-template-storage').each(function() {<br>
+ this.selected = (this.text == 'raw');<br>
+ });<br>
+ $('select:last', '#form-template-storage').prop('disabled', true).change();<br>
});<br>
} else {<br>
addStorageItem(storageNodeData);<br>
@@ -271,7 +298,8 @@ kimchi.template_edit_main = function() {<br>
origDisks[0]['volume'] && delete origDisks[0]['volume'];<br>
origDisks[0].size = Number($('.template-storage-disk', tmpItem).val());<br>
}<br>
- data[field] = origDisks;<br>
+ origDisks[0].format = $('.template-storage-disk-format', tmpItem).val();<br>
+ data[field] = origDisks;<br>
}<br>
else if (field == 'graphics') {<br>
var type = $('#form-template-general [name="' + field + '"]').val();<br>
diff --git a/ui/pages/template-edit.html.tmpl b/ui/pages/template-edit.html.tmpl<br>
index c7832c9..e64a30f 100644<br>
--- a/ui/pages/template-edit.html.tmpl<br>
+++ b/ui/pages/template-edit.html.tmpl<br>
@@ -104,6 +104,7 @@<br>
<span class="template-storage-cell">$_("Storage Pool")</span><br>
<span class="template-storage-cell">$_("Type")</span><br>
<span class="template-storage-cell">$_("Disk(GB)")</span><br>
+ <span class="template-storage-cell">$_("Disk Format")</span><br>
<button type="button" id="template-edit-storage-add-button" class="action-area"></button><br>
</div><br>
<div class="template-tab-body"><br>
@@ -160,6 +161,21 @@<br>
<span class="template-storage-cell"><br>
<input class="template-storage-disk" value={storageDisk} type="text" /><br>
</span><br>
+ <span class="template-storage-cell"><br>
+ <input class="template-storage-disk-format" value={storageDiskFormat} type="text" style="display:none" /><br>
+ <select><br>
+ <option>qcow2</option><br>
+ <option>raw</option><br>
+ <option>bochs</option><br>
+ <option>cloop</option><br>
+ <option>cow</option><br>
+ <option>dmg</option><br>
+ <option>qcow</option><br>
+ <option>qed</option><br>
+ <option>vmdk</option><br>
+ <option>vpc</option><br>
+ </select><br>
+ </span><br>
</div><br>
</script><br>
<script id="template-interface-tmpl" type="text/html"><br>
--<br>
2.1.0<br>
<br>
_______________________________________________<br>
Kimchi-devel mailing list<br>
<a href="mailto:Kimchi-devel@ovirt.org" target="_blank">Kimchi-devel@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel" target="_blank">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a><br>
</blockquote></div>