[Kimchi-devel] [PATCH][Kimchi] Issue #931 Error when editing a template created using a disk image
Lucio Correia
luciojhc at linux.vnet.ibm.com
Fri Apr 22 17:11:45 UTC 2016
On 20-04-2016 15:30, Ramon Medeiros wrote:
> UI wasn't passing path to image disk when updating it, so the backend
> was losing the disk.
>
> Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
> ---
> ui/js/src/kimchi.template_edit_main.js | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js
> index de72452..8b5abfb 100644
> --- a/ui/js/src/kimchi.template_edit_main.js
> +++ b/ui/js/src/kimchi.template_edit_main.js
> @@ -20,6 +20,7 @@ kimchi.template_edit_main = function() {
> var origDisks;
> var origNetworks;
> var templateDiskSize;
> + var baseImageTemplate;
> $('#template-name', templateEditMain).val(kimchi.selectedTemplate);
> $('#edit-template-tabs a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
> $('.tab-content').css('overflow','hidden');
> @@ -89,6 +90,7 @@ kimchi.template_edit_main = function() {
> }
> return false;
> }
> + baseImageTemplate = isImageBasedTemplate;
It seems more secure to call the function here and store true or false
in baseImageTemplate var, like this:
baseImageTemplate = isImageBasedTemplate();
Alternatively, if it works, I would move isImageBasedTemplate() outside
of initTemplate and receiving template as parameter, calling it from
both places.
> enableSpice();
> $('#template-edit-graphics').selectpicker();
>
> @@ -334,7 +336,9 @@ kimchi.template_edit_main = function() {
> var data = {};
> var disks = $('.template-tab-body .item', '#form-template-storage');
> var disksForUpdate = new Array();
> +
> $.each(disks, function(index, diskEntity) {
> +
> var newDisk = {
> 'index' : index,
> 'pool' : {'name': '/plugins/kimchi/storagepools/' + $(diskEntity).find('.template-storage-name').val()},
> @@ -342,6 +346,11 @@ kimchi.template_edit_main = function() {
> 'format' : $(diskEntity).find('.template-storage-disk-format').val()
> };
>
> + // image based template: add base to dictionary
> + if ((baseImageTemplate()) && (index == 0)) {
> + newDisk["base"] = $('#template-edit-vmimage-textbox').val();
> + }
> +
> var storageType = $(diskEntity).find('.template-storage-type').val();
> if(storageType === 'iscsi' || storageType === 'scsi') {
> newDisk['volume'] = newDisk['pool']['name'].split('/').pop();
>
--
Lucio Correia
Software Engineer
IBM LTC Brazil
More information about the Kimchi-devel
mailing list