From: ShaoHe Feng <shaohef(a)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(a)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