On 02/24/2014 06:55 AM, huoyuxin@linux.vnet.ibm.com wrote:
From: Yu Xin Huo <huoyuxin@linux.vnet.ibm.com>

Signed-off-by: Yu Xin Huo <huoyuxin@linux.vnet.ibm.com>
---
 ui/js/src/kimchi.api.js                  |   12 +++++++++
 ui/js/src/kimchi.storage_main.js         |   38 ++++++++++++++++++++++++++++++
 ui/js/src/kimchi.storagepool_add_main.js |    2 +-
 ui/pages/i18n.html.tmpl                  |    1 +
 ui/pages/tabs/storage.html.tmpl          |   10 ++++++++
 5 files changed, 62 insertions(+), 1 deletions(-)

diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index 686141b..ee7f0d8 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -745,5 +745,17 @@ var kimchi = {
                 kimchi.message.error(data.responseJSON.reason);
             }
         });
+    },
+
+    updateStoragePool : function(name, content, suc, err) {
+        $.ajax({
+            url : kimchi.url + "storagepools/" + encodeURIComponent(name),
+            type : 'PUT',
+            contentType : 'application/json',
+            dataType : 'json',
+            data : JSON.stringify(content)

+        }).done(suc).fail(err ? err : function(data) {
+            kimchi.message.error(data.responseJSON.reason);
+        });
     }

I am not sure if this error handle is working.

I got it on console:

[04/Mar/2014:11:46:07] HTTP Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cherrypy/_cprequest.py", line 656, in respond
    response.body = self.handler()
  File "/usr/lib/python2.7/site-packages/cherrypy/lib/encoding.py", line 188, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/cherrypy/_cpdispatch.py", line 34, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/root/kimchi/src/kimchi/control/base.py", line 137, in index
    return self.update()
  File "/root/kimchi/src/kimchi/control/base.py", line 166, in update
    ident = update(*args)
  File "/root/kimchi/src/kimchi/model/storagepools.py", line 294, in update
    self._update_lvm_disks(name, params['disks'])
  File "/root/kimchi/src/kimchi/model/storagepools.py", line 267, in _update_lvm_disks
    'pool': pool_name})
OperationFailed: KCHPOOL0027E: /dev/sdb is not a valid disk/partition. Could not add it to the pool as.

And on UI:




Also when I select the text "/dev/vdb" it does not select the option - need to fix it.

We need to ask for user confirmation before updating the storage pool.
Add a new disk to a logical pool may cause loose of data.

 };
diff --git a/ui/js/src/kimchi.storage_main.js b/ui/js/src/kimchi.storage_main.js
index d65da0b..40aceb7 100644
--- a/ui/js/src/kimchi.storage_main.js
+++ b/ui/js/src/kimchi.storage_main.js
@@ -27,6 +27,7 @@ kimchi.doListStoragePools = function() {
                 value.usage = parseInt(value.allocated / value.capacity * 100) || 0;
                 value.capacity = kimchi.changetoProperUnit(value.capacity,1);
                 value.allocated = kimchi.changetoProperUnit(value.allocated,1);
+                value.enableExt = value.type==="logical" ? "" : "hide-content";
                 if ('kimchi-iso' !== value.type) {
                     listHtml += kimchi.template(storageHtml, value);
                 }
@@ -140,6 +141,10 @@ kimchi.storageBindClick = function() {
             }
         }
     });
+    $('.pool-extend').on('click', function() {
+        $("#logicalPoolExtend").dialog("option", "poolName", $(this).data('name'));
+        $("#logicalPoolExtend").dialog("open");
+    });
 }

 kimchi.doListVolumes = function(poolObj) {
@@ -170,11 +175,44 @@ kimchi.doListVolumes = function(poolObj) {
     });
 }

+kimchi.initLogicalPoolExtend = function() {
+    $("#logicalPoolExtend").dialog({
+        autoOpen : false,
+        modal : true,
+        width : 600,
+        resizable : false,
+        closeText: "X",
+        open : function(){
+            $(".ui-dialog-titlebar-close", $("#logicalPoolExtend").parent()).removeAttr("title");
+            kimchi.listHostPartitions(function(data) {
+                for(var i=0;i<data.length;i++){
+                    if (data[i].type === 'part' || data[i].type === 'disk') {
+                        $('.host-partition', '#logicalPoolExtend').append(kimchi.template($('#logicalPoolExtendTmpl').html(), data[i]));
+                    }
+                }
+            });
+        },
+        beforeClose : function() { $('.host-partition', '#logicalPoolExtend').empty(); },
+        buttons : [{
+            class: "ui-button-primary",
+            text: i18n.KCHAPI6007M,
+            click: function(){
+                var devicePaths = [];
+                $("input[type='checkbox']:checked", "#logicalPoolExtend").each(function(){
+                    devicePaths.push($(this).prop('value'));
+                })
+                kimchi.updateStoragePool($("#logicalPoolExtend").dialog("option", "poolName"),{disks: devicePaths});
+            }
+        }]
+    });
+}
+
 kimchi.storage_main = function() {
     $('#storage-pool-add').on('click', function() {
         kimchi.window.open('storagepool-add.html');
     });
     kimchi.doListStoragePools();
+    kimchi.initLogicalPoolExtend();
 }

 kimchi.changeArrow = function(obj) {
diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js
index 43ff31a..beb59ed 100644
--- a/ui/js/src/kimchi.storagepool_add_main.js
+++ b/ui/js/src/kimchi.storagepool_add_main.js
@@ -53,7 +53,7 @@ kimchi.initStorageAddPage = function() {
                     listHtml += kimchi.template(deviceHtml, value);
                 }
             });
-            $('.host-partition').html(listHtml);
+            $('.host-partition', '#form-pool-add').html(listHtml);
         }
         kimchi.getStorageServers('netfs', function(data) {
             var serverContent = [];
diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl
index fe8ed5b..26ac47b 100644
--- a/ui/pages/i18n.html.tmpl
+++ b/ui/pages/i18n.html.tmpl
@@ -62,6 +62,7 @@ var i18n = {
     'KCHAPI6004M': "$_("Confirm")",
     'KCHAPI6005M': "$_("Create")",
     'KCHAPI6006M': "$_("Warning")",
+    'KCHAPI6007M': "$_("Save")",

     'KCHTMPL6001W': "$_("No iso found")",

diff --git a/ui/pages/tabs/storage.html.tmpl b/ui/pages/tabs/storage.html.tmpl
index 6930c22..d36c90e 100644
--- a/ui/pages/tabs/storage.html.tmpl
+++ b/ui/pages/tabs/storage.html.tmpl
@@ -44,6 +44,9 @@
     </div>
     <ul id="storagepoolsList" class="list-storage"></ul>
 </div>
+<div id="logicalPoolExtend" title="$_("Device path")">
+    <div class="host-partition"></div>
+</div>
 <script id="storageTmpl" type="html/text">
     <li id="{name}">
         <div class="storage-li in" data-name="{name}" data-stat="{state}">
@@ -78,6 +81,7 @@
                         <button class="button-big pool-deactivate" data-stat="{state}" data-name="{name}"><span class="text">$_("Deactivate")</span></button>
                         <button class="button-big pool-activate" data-stat="{state}" data-name="{name}"><span class="text">$_("Activate")</span></button>
                         <button class="button-big red pool-delete" data-stat="{state}" data-name="{name}"><span class="text">$_("Undefine")</span></button>
+                        <button class="button-big pool-extend {enableExt}" data-stat="{state}" data-name="{name}"><span class="text">$_("Extend")</span></button>
                     </div>
                 </div>
             </div>
@@ -110,6 +114,12 @@
             </div>
       </div>
 </script>
+<script id="logicalPoolExtendTmpl" type="html/text">
+    <div>
+        <input type="checkbox" value="{path}" name="devices">
+        <label for="{name}">{path}</label>
+    </div>
+</script>
 <script>
     kimchi.storage_main();
 </script>