[Kimchi-devel] [PATCH] Bugfix:#424 Edit Template, "Disk (GB)" is changing with storage pool

Aline Manera alinefm at linux.vnet.ibm.com
Fri Sep 19 02:43:20 UTC 2014


On 09/18/2014 04:33 AM, Wen Wang wrote:
> From: Wen Wang <wenwang at linux.vnet.ibm.com>
>
> This patch fix the bug that value of "Disk(GB)" input box is changing
> with the item of "Storage Pool" in "Templates" --> "Actions" --> "Edit"
> -->"Edit Templates" dialogue. This might be comfusing to user when
> changing the "Storage Pool", "Disk(GB)" is changed with it without even
> notice. This might confuse the users and is not necessary. Solved by
> removing the change.
>
> Signed-off-by: Wen Wang <wenwang at linux.vnet.ibm.com>
> ---
>   ui/js/src/kimchi.template_edit_main.js |   25 -------------------------
>   1 files changed, 0 insertions(+), 25 deletions(-)
>
> diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js
> index cb43091..61d23b4 100644
> --- a/ui/js/src/kimchi.template_edit_main.js
> +++ b/ui/js/src/kimchi.template_edit_main.js
> @@ -117,31 +117,6 @@ kimchi.template_edit_main = function() {
>           });
>       });


> -    $('#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);
> -            });
> -        } else {
> -            if (origPool == storagepool) {
> -                // Previous disk size value
> -                $('input[name="disks"]', templateEditForm).val(origDisks[0].size);
> -            } else {
> -                // Default disk size value
> -                $('input[name="disks"]', templateEditForm).val(10);
> -            }
> -            $('input[name="disks"]', templateEditForm).removeAttr('disabled');
> -        }
> -    });
> -
>       $('#tmpl-edit-button-save').on('click', function() {
>           var editableFields = [ 'name', 'cpus', 'memory', 'storagepool', 'disks', 'graphics'];
>           var data = {};

We can't remove this code.
It is used when a iSCSI or SCSI storage pool is selected. In this case, 
the disk size comes from the volumes selected and can not be changed.

iSCSI and SCSI pools are what we said as read-only pools which means we 
can't create new volumes in it as the volumes are pre-configured by system.
So when user selects one of these pools, he/she needs also to point the 
volume because that we display <pool>/<volumes> in these cases.

What we can do is always display the previous disk size when changing 
from pools that are not iSCSI or SCSI.
To do that we need to change the "else" statement like below:


          } else {
-            if (origPool == storagepool) {
-                // Previous disk size value
-                $('input[name="disks"]', templateEditForm).val(origDisks[0].size);
-            } else {
-                // Default disk size value
-                $('input[name="disks"]', templateEditForm).val(10);
-            }
+            // Previous disk size value
+            $('input[name="disks"]', templateEditForm).val(origDisks[0].size);
              $('input[name="disks"]', templateEditForm).removeAttr('disabled');
          }
      });







More information about the Kimchi-devel mailing list