[PATCH 1/3] UI: add a api to get an storagevolume info

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Now we have support scsi/iscsi pool in template. We need to shoe some infomation of the storagevolume of scsi/iscsi pool in template edit page. Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- ui/js/src/kimchi.api.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js index 0c5c790..9f722cd 100644 --- a/ui/js/src/kimchi.api.js +++ b/ui/js/src/kimchi.api.js @@ -381,6 +381,18 @@ var kimchi = { }); }, + listStorageVolume : function(poolName, volumeName, suc, err) { + $.ajax({ + url : kimchi.url + 'storagepools/' + encodeURIComponent(poolName) + '/storagevolumes/' + encodeURIComponent(volumeName), + // url : kimchi.url + 'storagepools/' + encodeURIComponent(poolName) + '/storagevolumes/' + volumeName, + type : 'GET', + contentType : 'application/json', + dataType : 'json', + success : suc, + error : err + }); + }, + listIsos : function(suc, err) { kimchi.requestJSON({ url : kimchi.url + 'storagepools/kimchi_isos/storagevolumes', -- 1.8.5.3

From: ShaoHe Feng <shaohef@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@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

On 04/02/2014 11:19 AM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@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@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(''); + }
That way we will empty the "Disk size" field when changing the storage pool I'd expect to keep the same volume size there too (10G by default)
+ }); + $('#tmpl-edit-button-save').on('click', function() { var editableFields = [ 'name', 'cpus', 'memory', 'storagepool', 'disks', 'graphics']; var data = {};

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> The storage pool filed should be the combination of pool name and volume name, when the pool is iscsi/scsi. Also the disks field should be the size of the iscsi/scsi lun. Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- ui/js/src/kimchi.template_edit_main.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js index 0aaf6e5..7cf2611 100644 --- a/ui/js/src/kimchi.template_edit_main.js +++ b/ui/js/src/kimchi.template_edit_main.js @@ -29,8 +29,21 @@ kimchi.template_edit_main = function() { $('input[name="' + prop + '"]', templateEditForm).val(value); } var disks = template.disks; - $('input[name="disks"]').val(disks[0].size); - + if ('size' in disks[0]) { + $('input[name="disks"]').val(disks[0].size); + $('input[name="disks"]').prop( "disabled",false); + } else if ('volume' in disks[0]){ + $('input[name="disks"]').prop( "disabled",true); + $('input[name="storagepool"]', templateEditForm).val(template['storagepool'] + "/" + disks[0].volume); + storageArray = template['storagepool'].split("/"); + poolName = storageArray[2]; + kimchi.listStorageVolume(poolName, disks[0].volume, function(result) { + if (result) { + size = result.allocation/(1024*1024*1024); + $('input[name="disks"]').val(size.toFixed(1)); + } + }); + } var options = [{label: 'VNC', value: 'vnc'}]; kimchi.getCapabilities(function(result) { if (result.qemu_spice == true) { -- 1.8.5.3

Reviewed-by: Aline Manera <alinefm@linux.vnet.ibm.com> On 04/02/2014 11:19 AM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
The storage pool filed should be the combination of pool name and volume name, when the pool is iscsi/scsi.
Also the disks field should be the size of the iscsi/scsi lun.
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- ui/js/src/kimchi.template_edit_main.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js index 0aaf6e5..7cf2611 100644 --- a/ui/js/src/kimchi.template_edit_main.js +++ b/ui/js/src/kimchi.template_edit_main.js @@ -29,8 +29,21 @@ kimchi.template_edit_main = function() { $('input[name="' + prop + '"]', templateEditForm).val(value); } var disks = template.disks; - $('input[name="disks"]').val(disks[0].size); - + if ('size' in disks[0]) { + $('input[name="disks"]').val(disks[0].size); + $('input[name="disks"]').prop( "disabled",false); + } else if ('volume' in disks[0]){ + $('input[name="disks"]').prop( "disabled",true); + $('input[name="storagepool"]', templateEditForm).val(template['storagepool'] + "/" + disks[0].volume); + storageArray = template['storagepool'].split("/"); + poolName = storageArray[2]; + kimchi.listStorageVolume(poolName, disks[0].volume, function(result) { + if (result) { + size = result.allocation/(1024*1024*1024); + $('input[name="disks"]').val(size.toFixed(1)); + } + }); + } var options = [{label: 'VNC', value: 'vnc'}]; kimchi.getCapabilities(function(result) { if (result.qemu_spice == true) {

Reviewed-by: Aline Manera <alinefm@linux.vnet.ibm.com> On 04/02/2014 11:19 AM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Now we have support scsi/iscsi pool in template.
We need to shoe some infomation of the storagevolume of scsi/iscsi pool
typo: shoe I can fix it before applying
in template edit page.
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- ui/js/src/kimchi.api.js | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js index 0c5c790..9f722cd 100644 --- a/ui/js/src/kimchi.api.js +++ b/ui/js/src/kimchi.api.js @@ -381,6 +381,18 @@ var kimchi = { }); },
+ listStorageVolume : function(poolName, volumeName, suc, err) { + $.ajax({ + url : kimchi.url + 'storagepools/' + encodeURIComponent(poolName) + '/storagevolumes/' + encodeURIComponent(volumeName), + // url : kimchi.url + 'storagepools/' + encodeURIComponent(poolName) + '/storagevolumes/' + volumeName, + type : 'GET', + contentType : 'application/json', + dataType : 'json', + success : suc, + error : err + }); + }, + listIsos : function(suc, err) { kimchi.requestJSON({ url : kimchi.url + 'storagepools/kimchi_isos/storagevolumes',
participants (2)
-
Aline Manera
-
shaohef@linux.vnet.ibm.com