[Kimchi-devel] [PATCH 2/3] UI: change the disks field of template when the pool changes.

shaohef at linux.vnet.ibm.com shaohef at linux.vnet.ibm.com
Wed Apr 2 14:19:44 UTC 2014


From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>

when pool is scsi/iscsi, we should not let user input the size
of disk.

We should get the disk size from the volume information.

Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
 ui/js/src/kimchi.template_edit_main.js | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js
index 386095b..0aaf6e5 100644
--- a/ui/js/src/kimchi.template_edit_main.js
+++ b/ui/js/src/kimchi.template_edit_main.js
@@ -101,6 +101,25 @@ kimchi.template_edit_main = function() {
         kimchi.window.close();
     });
 
+    $('#template-edit-storagePool').change(function() {
+        storagepool = $(this).val();
+        storageArray = storagepool.split("/");
+        if (storageArray.length > 3){
+            $('input[name="disks"]').prop( "disabled",true);
+            volumeName = storageArray.pop();
+            poolName = storageArray[2]
+            kimchi.listStorageVolume(poolName, volumeName, function(result) {
+                if (result) {
+                    size = result.allocation/(1024*1024*1024);
+                    $('input[name="disks"]').val(size.toFixed(1));
+                }
+            });
+        } else {
+            $('input[name="disks"]').prop( "disabled",false);
+            $('input[name="disks"]').val('');
+        }
+    });
+
     $('#tmpl-edit-button-save').on('click', function() {
         var editableFields = [ 'name', 'cpus', 'memory', 'storagepool', 'disks', 'graphics'];
         var data = {};
-- 
1.8.5.3




More information about the Kimchi-devel mailing list