[Kimchi-devel] [PATCH] Filter template names with slash "/" and remove 'optional' from cdrom

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Wed Mar 11 19:26:55 UTC 2015


Thanks Aline.
Please, ignore this patch. I 'am sending another.

Rodrigo

On 03/06/2015 12:03 PM, Aline Manera wrote:
>
>
> On 05/03/2015 23:53, Rodrigo Trujillo wrote:
>> Users are allowed to create or update template names with "slash", this
>> generates an error when he tries to create a guest with that template
>> because the template name is used as URL. Actually, API.json already
>> prohibits, the vm creation with the use of the pattern
>> "^/templates/[^/]+/?$", during the json fields validation.
>> So, this patch modifies the regular expression used to validate the
>> template names, prohibiting slashes.
>
> We should not prohibit the slashes.
> We just need to properly encode it when sending the information to the 
> API.
>
>>
>> This patch also removes the "optional" word from API.md text, once this
>> field is required to create a new template.
>
> cdrom parameter is optional as the user can create a template using a 
> img file which is handled by 'disks' parameter
>
>>
>> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
>> ---
>>   docs/API.md         | 2 +-
>>   src/kimchi/API.json | 4 ++--
>>   2 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/docs/API.md b/docs/API.md
>> index 3f7925f..656ddf0 100644
>> --- a/docs/API.md
>> +++ b/docs/API.md
>> @@ -232,7 +232,7 @@ Represents a snapshot of the Virtual Machine's 
>> primary monitor.
>>             will default to a product of the topology values (see 
>> cpu_info).
>>       * memory *(optional)*: The amount of memory assigned to the VM.
>>         Default is 1024M.
>> -    * cdrom *(optional)*: A volume name or URI to an ISO image.
>> +    * cdrom: A volume name or URI to an ISO image.
>>       * storagepool *(optional)*: URI of the storagepool.
>>         Default is '/storagepools/default'
>>       * networks *(optional)*: list of networks will be assigned to 
>> the new VM.
>> diff --git a/src/kimchi/API.json b/src/kimchi/API.json
>> index 0cfa20c..a318c4e 100644
>> --- a/src/kimchi/API.json
>> +++ b/src/kimchi/API.json
>> @@ -395,7 +395,7 @@
>>                   "name": {
>>                       "description": "The name of the template",
>>                       "type": "string",
>> -                    "pattern": "^[^ ]+( +[^ ]+)*$",
>> +                    "pattern": "^[^ /]+[^/]+[^ /]+$",
>>                       "minLength": 1,
>>                       "error": "KCHTMPL0008E"
>>                   },
>> @@ -567,7 +567,7 @@
>>                   "name": {
>>                       "description": "The name of the template",
>>                       "type": "string",
>> -                    "pattern": "^[^ ]+( +[^ ]+)*$",
>> +                    "pattern": "^[^ /]+[^/]+[^ /]+$",
>>                       "minLength": 1,
>>                       "error": "KCHTMPL0008E"
>>                   },
>




More information about the Kimchi-devel mailing list