[Kimchi-devel] [V2 1/2] Fibre Channel SCSI Storage Pool UI

huoyuxin at linux.vnet.ibm.com huoyuxin at linux.vnet.ibm.com
Mon Feb 17 08:19:44 UTC 2014


From: Yu Xin Huo <huoyuxin at linux.vnet.ibm.com>

add a new type of storage pool fibre channel scsi.
if this type of storage pool is selected,
send a request to get all host PCI devices,
then list them for user selection.

Signed-off-by: Yu Xin Huo <huoyuxin at linux.vnet.ibm.com>
---
 ui/css/theme-default/storage.css         |    2 +-
 ui/js/src/kimchi.api.js                  |   14 +++++++++++++
 ui/js/src/kimchi.storagepool_add_main.js |   31 ++++++++++++++++++++++++++++-
 ui/pages/i18n.html.tmpl                  |    2 +-
 ui/pages/storagepool-add.html.tmpl       |   12 +++++++++++
 5 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/ui/css/theme-default/storage.css b/ui/css/theme-default/storage.css
index dde7f5a..a43a39a 100644
--- a/ui/css/theme-default/storage.css
+++ b/ui/css/theme-default/storage.css
@@ -548,7 +548,7 @@
 
 .storage-type-wrapper-controls > .dropdown {
     margin: 5px 0 0 1px;
-    width: 150px;
+    width: 200px;
 }
 
 .storage-type-wrapper-controls input[type="text"][disabled] {
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index 6433fe0..686141b 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -731,5 +731,19 @@ var kimchi = {
             success : suc,
             error : err
         });
+    },
+
+    getHostPCIDevices: function(suc, err) {
+        var url = kimchi.url+'host/devices?_cap=fc_host';
+        kimchi.requestJSON({
+            url : url,
+            type : 'GET',
+            contentType : 'application/json',
+            dataType : 'json',
+            success : suc,
+            error : err ? err : function(data) {
+                kimchi.message.error(data.responseJSON.reason);
+            }
+        });
     }
 };
diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js
index ac97e1a..43ff31a 100644
--- a/ui/js/src/kimchi.storagepool_add_main.js
+++ b/ui/js/src/kimchi.storagepool_add_main.js
@@ -55,7 +55,6 @@ kimchi.initStorageAddPage = function() {
             });
             $('.host-partition').html(listHtml);
         }
-        $('#poolTypeId').selectMenu("setData", options);
         kimchi.getStorageServers('netfs', function(data) {
             var serverContent = [];
             if (data.length > 0) {
@@ -101,27 +100,53 @@ kimchi.initStorageAddPage = function() {
                 });
             });
         });
+        kimchi.getHostPCIDevices(function(data){
+            if(data.length>0){
+                options.push({
+                    label : i18n.KCHPOOL6004M,
+                    value : "scsi"
+                });
+                for(var i=0;i<data.length;i++){
+                    data[i].label = data[i].name;
+                    data[i].value = data[i].name;
+                }
+                $('#scsiAdapter').selectMenu();
+                $("input", "#scsiAdapter").val(data[0].name);
+                $('#scsiAdapter').selectMenu("setData", data);
+            }
+            $('#poolTypeId').selectMenu("setData", options);
+        });
         $('#poolTypeInputId').change(function() {
             if ($(this).val() === 'dir') {
                 $('.path-section').removeClass('tmpl-html');
                 $('.logical-section').addClass('tmpl-html');
                 $('.nfs-section').addClass('tmpl-html');
                 $('.iscsi-section').addClass('tmpl-html');
+                $('.scsi-section').addClass('tmpl-html');
             } else if ($(this).val() === 'netfs') {
                 $('.path-section').addClass('tmpl-html');
                 $('.logical-section').addClass('tmpl-html');
                 $('.nfs-section').removeClass('tmpl-html');
                 $('.iscsi-section').addClass('tmpl-html');
+                $('.scsi-section').addClass('tmpl-html');
             } else if ($(this).val() === 'iscsi') {
                 $('.path-section').addClass('tmpl-html');
                 $('.logical-section').addClass('tmpl-html');
                 $('.nfs-section').addClass('tmpl-html');
                 $('.iscsi-section').removeClass('tmpl-html');
+                $('.scsi-section').addClass('tmpl-html');
             } else if ($(this).val() === 'logical') {
                 $('.path-section').addClass('tmpl-html');
                 $('.logical-section').removeClass('tmpl-html');
                 $('.nfs-section').addClass('tmpl-html');
                 $('.iscsi-section').addClass('tmpl-html');
+                $('.scsi-section').addClass('tmpl-html');
+            } else if ($(this).val() === 'scsi') {
+                $('.scsi-section').removeClass('tmpl-html');
+                $('.path-section').addClass('tmpl-html');
+                $('.logical-section').addClass('tmpl-html');
+                $('.nfs-section').addClass('tmpl-html');
+                $('.iscsi-section').addClass('tmpl-html');
             }
         });
         $('#authId').click(function() {
@@ -157,7 +182,7 @@ kimchi.validateForm = function() {
     } else if (poolType === "logical") {
         return kimchi.validateLogicalForm();
     } else {
-        return false;
+        return true;
     }
 };
 
@@ -260,6 +285,8 @@ kimchi.addPool = function(event) {
                 };
             }
             formData.source = source;
+        } else if (poolType === 'scsi'){
+            formData.source = { adapter_name: $('#scsiAdapter').selectMenu('value') };
         }
         if (poolType === 'logical') {
             var settings = {
diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl
index 098a0a9..fe8ed5b 100644
--- a/ui/pages/i18n.html.tmpl
+++ b/ui/pages/i18n.html.tmpl
@@ -93,7 +93,6 @@ var i18n = {
     'KCHDR6009M': "$_("Remove")",
     'KCHDR6010M': "$_("Download")",
 
-
     'KCHVM6001M': "$_("This will delete the virtual machine and its virtual disks. This operation cannot be undone. Would you like to continue?")",
 
     'KCHNET6001E': "$_("The VLAN id must be between 1 and 4094.")",
@@ -105,6 +104,7 @@ var i18n = {
     'KCHPOOL6001M': "$_("This will permanently delete the storage pool. Would you like to continue?")",
     'KCHPOOL6002M': "$_("This storage pool is empty.")",
     'KCHPOOL6003M': "$_("It will format your disk and you will loose any data in there, are you sure to continue? ")",
+    'KCHPOOL6004M': "$_("SCSI Fibre Channel")",
 
     'KCHPOOL6001E': "$_("The storage pool name can not be blank.")",
     'KCHPOOL6002E': "$_("The storage pool path can not be blank.")",
diff --git a/ui/pages/storagepool-add.html.tmpl b/ui/pages/storagepool-add.html.tmpl
index 9e93298..f35013b 100644
--- a/ui/pages/storagepool-add.html.tmpl
+++ b/ui/pages/storagepool-add.html.tmpl
@@ -135,6 +135,18 @@
                         </div>
                     </section>
                 </div>
+                <div class="scsi-section tmpl-html">
+                    <section class="form-section">
+                        <h2>3. $_("SCSI Adapter")</h2>
+                        <div class="storage-type-wrapper-controls">
+                        <div id="scsiAdapter">
+                            <input type="hidden"/>
+                            <span></span><span class="arrow"></span>
+                            <div><ul></ul></div>
+                        </div>
+                        </div>
+                    </section>
+                </div>
             </form>
         </div>
         <footer>
-- 
1.7.1




More information about the Kimchi-devel mailing list