[Kimchi-devel] [PATCH] UI: template edit page support scsi lun

shaohef at linux.vnet.ibm.com shaohef at linux.vnet.ibm.com
Tue Mar 25 17:38:57 UTC 2014


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

User can choose a volume of scsi/iscsi pool from the template edit page.

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

diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js
index 58f4506..b7d6cb6 100644
--- a/ui/js/src/kimchi.template_edit_main.js
+++ b/ui/js/src/kimchi.template_edit_main.js
@@ -32,19 +32,39 @@ kimchi.template_edit_main = function() {
         $('input[name="disks"]').val(disks[0].size);
         var options = [{label: 'VNC', value: 'vnc'}, {label: 'Spice', value: 'spice'}];
         kimchi.select('template-edit-graphics-list', options);
+        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')) {
-                        options.push({
-                            label: storagePool.name,
-                            value: '/storagepools/' + storagePool.name
-                        });
+                        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
+                            });
+                        }
                     }
                 });
             }
-            kimchi.select('template-edit-storagePool-list', options);
+            if ($.isEmptyObject(scsipools)) {
+                kimchi.select('template-edit-storagePool-list', options);
+            }
         });
         kimchi.listNetworks(function(result) {
             if(result && result.length > 0) {
@@ -91,6 +111,14 @@ kimchi.template_edit_main = function() {
         });
         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 */
+            delete data["disks"][0].size;
+            data["disks"][0].volume = storageArray.pop();
+            data['storagepool'] = storageArray.join("/");
+        }
         var networks = templateEditForm.serializeObject().networks;
         if (networks instanceof Array) {
             data.networks = networks;
-- 
1.8.5.3




More information about the Kimchi-devel mailing list