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.
This patch also removes the "optional" word from API.md text, once this
field is required to create a new template.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)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"
},
--
2.1.0