[Kimchi-devel] [WIP][PATCH 1/4] Storage volume upload: Dispatch volume create to right handler

Royce Lv lvroyce at linux.vnet.ibm.com
Mon Aug 25 07:29:08 UTC 2014


On 2014年08月22日 05:02, Crístian Viana wrote:
> On 21-08-2014 11:42, lvroyce0210 at gmail.com wrote:
>> + for p in vol_source:
>> + create_func = getattr(self, "_create_volume_with_" + p, None)
>> + if create_func and p in params:
>> + return create_func(pool_name, params)
>> +
> There needs to be a better error handling here. What if there's no 
> appropriate function (create_volume_with_XXX)? The function create 
> won't return anything and nothing will be reported. Actually, I guess 
> an error will be raised later because whoever calls the function 
> "create" expects a string in return.
Cristian,

Thanks for your comments!

This part of error handling is here:
+ vol_source = ['file', 'url', 'capacity']
+
+ if sum(1 for p in vol_source if p in params) != 1:
+ raise InvalidParameter("KCHVOL0018E", {'param': str(vol_source)})

These lines guarantee one and only one of these params are specified. 
Still I need to add a line of "def create_volume_with_url(self): pass" 
to make sure the problem you mentioned will be avoided.

>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>




More information about the Kimchi-devel mailing list