[Kimchi-devel] [PATCH] [Kimchi] Github #934: fix storage pool name in template-edit.html.tmpl

dhbarboza82 at gmail.com dhbarboza82 at gmail.com
Fri Jun 3 18:28:46 UTC 2016


From: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>

A curious behavior was happening in ui/pages/template-edit.html.tmpl.
As reported in Github issue #934, Kimchi was having trouble editing
templates in which the storage pool had spaces in the name.

Considering a storage pool name 'this is a storage pool', which
is a valid storage pool name in libvirt and Kimchi backend,
this is how the edit template HTML was being rendered when
editing a template with this pool:

<input class="template-storage-name" value="this" is=""
a="" storage="" pool="" type="text" style="display:none">

If no changes are made in the template storage pool, the
UI tries to update the template object with a storage pool
named "this", failing a backend check and raising a
storage pool not found error.

However, if any change is made in the storage pool select box,
the JS logic would set the input value properly and dodge
this malformed input tag.

This patch solves this issue by adding double quote around
the storage name element, so value="{storageName}" instead
of value={storageName}. This is how the input tag is
generated after this change:

<input class="template-storage-name" value="this is a storage pool"
type="text" style="display:none">

And the UI will always retrieve the right storage pool
name when editing a template, even if the name has spaces.

Signed-off-by: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>
---
 ui/pages/template-edit.html.tmpl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/pages/template-edit.html.tmpl b/ui/pages/template-edit.html.tmpl
index c880ef4..2d7deed 100644
--- a/ui/pages/template-edit.html.tmpl
+++ b/ui/pages/template-edit.html.tmpl
@@ -175,7 +175,7 @@
 <script id="template-storage-pool-tmpl" type="text/html">
     <div id="storageRow{storageIndex}" class='item'>
         <span class="template-storage-cell storage-pool">
-            <input class="template-storage-name" value={storageName} type="text" style="display:none" />
+            <input class="template-storage-name" value="{storageName}" type="text" style="display:none" />
             <select id="selectStorageName-{storageIndex}" class="selectStorageName"></select>
         </span>
         <span class="template-storage-cell type">
-- 
2.5.5




More information about the Kimchi-devel mailing list