[Kimchi-devel] [PATCHv1 5/5] Storage volume upload: Adding progress to task message

Aline Manera alinefm at linux.vnet.ibm.com
Mon Sep 1 16:28:16 UTC 2014


Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>

On 09/01/2014 08:50 AM, lvroyce0210 at gmail.com wrote:
> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>
> Periodically update current written bytes to task message
> so that UI can query the latest progress of volume uploading.
>
> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
> ---
>   src/kimchi/model/storagevolumes.py | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/kimchi/model/storagevolumes.py b/src/kimchi/model/storagevolumes.py
> index 44279a2..e5f0b24 100644
> --- a/src/kimchi/model/storagevolumes.py
> +++ b/src/kimchi/model/storagevolumes.py
> @@ -79,13 +79,18 @@ class StorageVolumesModel(object):
>               raise InvalidParameter('KCHVOL0001E', {'name': params['name']})
>
>           upload_file = params['file']
> +        pool = StoragePoolModel.get_storagepool(pool_name, self.conn)
>           try:
> +            size = 0
>               f = open(file_path, 'wb')
> +            pool.refresh()
>               while True:
>                   data = upload_file.file.read(8192)
>                   if not data:
>                           break
> +                size += len(data)
>                   f.write(data)
> +                cb(size, True)
>               f.close()
>           except Exception as e:
>               raise OperationFailed('KCHVOL0007E',
> @@ -94,9 +99,7 @@ class StorageVolumesModel(object):
>                                      'err': e.message})
>
>           # Refresh to make sure volume can be found in following lookup
> -        pool = StoragePoolModel.get_storagepool(pool_name, self.conn)
>           pool.refresh()
> -        cb('', True)
>
>       def _create_volume_with_capacity(self, cb, params):
>           pool_name = params.pop('pool')




More information about the Kimchi-devel mailing list