[Kimchi-devel] [PATCH] storagevolume: Use default value for param 'name' when appropriate

Crístian Viana vianac at linux.vnet.ibm.com
Tue Sep 9 17:45:48 UTC 2014


On 09-09-2014 14:31, Paulo Ricardo Paz Vital wrote:
> @@ -156,13 +156,11 @@
>           },
>           "storagevolumes_create": {
>               "type": "object",
> -            "error": "KCHVOL0016E",
> Why removing the object error?

AFAIU, the field "error" on that JSON structure is raised if at least 
one of the required fields is not present. That was the case prior to 
this patch because the parameter "name" was actually required regardless 
of the storage volume creation method. We cannot say anymore that the 
parameter 'name' is always required, it now depends on the volume source 
(i.e. it's only required if the user sets the parameter 'capacity' - 
'file' and 'url' don't require it). That's why the field "error" is 
removed from here. But that error isn't gone, it's just moved to another 
file. If you take a look the rest of the patch, you'll find:

if name is None:
     if create_param in require_name_params:
         raise InvalidParameter('KCHVOL0016E')

which is the code snippet that makes the validation and raises that 
error if the parameter 'name'  is required in that specific case.

As a matter of fact, I think the field "error" on the JSON structure 
isn't a good approach because that field is supposed to be the only (or 
the "default") error during the resource's creation. However, in most of 
the times, there is not only one error when creating a resource, so 
usually we raise the errors in the Python code instead of here. But that 
would be a separate discussion :-)




More information about the Kimchi-devel mailing list