From: Paulo Vital <pvital(a)linux.vnet.ibm.com>
Set correct value to volume allocation and chunk size to be transfered, as well,
as condition to stop the upload of files.
Signed-off-by: Paulo Vital <pvital(a)linux.vnet.ibm.com>
---
model/storagevolumes.py | 9 ++++++---
ui/js/src/kimchi.storagepool_add_volume_main.js | 4 ++--
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/model/storagevolumes.py b/model/storagevolumes.py
index 0c710b2..b2915e1 100644
--- a/model/storagevolumes.py
+++ b/model/storagevolumes.py
@@ -141,7 +141,7 @@ class StorageVolumesModel(object):
</target>
</volume>
"""
- params.setdefault('allocation', 0)
+ params.setdefault('allocation', params['capacity'])
params.setdefault('format', 'qcow2')
name = params['name']
@@ -166,7 +166,9 @@ class StorageVolumesModel(object):
if params.get('upload', False):
upload_volumes[vol_path] = {'lock': threading.Lock(),
- 'offset': 0, 'cb': cb}
+ 'offset': 0, 'cb': cb,
+ 'expected_vol_size':
params['capacity']
+ }
cb('ready for upload')
else:
cb('OK', True)
@@ -534,7 +536,8 @@ class StorageVolumeModel(object):
cb('%s/%s' % (offset + chunk_size, vol_capacity))
vol_data['offset'] += chunk_size
- if vol_data['offset'] == vol_capacity:
+ if (vol_data['offset'] == vol_capacity) or \
+ (vol_data['offset'] == vol_data['expected_vol_size']):
del upload_volumes[vol_path]
cb('OK', True)
diff --git a/ui/js/src/kimchi.storagepool_add_volume_main.js
b/ui/js/src/kimchi.storagepool_add_volume_main.js
index ebace9c..e5a0a19 100644
--- a/ui/js/src/kimchi.storagepool_add_volume_main.js
+++ b/ui/js/src/kimchi.storagepool_add_volume_main.js
@@ -80,7 +80,7 @@ kimchi.sp_add_volume_main = function() {
};
var uploadFile = function() {
- var chunkSize = 8 * 1024 * 1024; // 8MB
+ var chunkSize = 2 * 1024 * 1024; // 2MB
var uploaded = 0;
var blobFile = $(localFileBox)[0].files[0];
@@ -106,7 +106,7 @@ kimchi.sp_add_volume_main = function() {
formData: fd
}, function(result) {
if (uploaded < blobFile.size){
- setTimeout(doUpload, 500);
+ setTimeout(doUpload, 500);
}
}, onError);
--
2.7.4