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

Crístian Viana vianac at linux.vnet.ibm.com
Tue Aug 26 12:50:13 UTC 2014


On 25-08-2014 04:29, Royce Lv wrote:
> 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.

Exactly. But they don't guarantee that the corresponding function (let's 
say, _create_volume_with_url) exists.

> 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.

Sure, that will avoid the problem for now, but the function "create" 
still isn't sure whether the other functions exist. It just expects so. 
It's better to raise an error if that function can't find the other 
functions rather than fail silently (by not running any function).




More information about the Kimchi-devel mailing list