[Kimchi-devel] [PATCH][Kimchi] Improve checking of cpu_info API (json schema)

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Thu Apr 14 17:12:02 UTC 2016


This patch adds a checking, retricting parameters expected in
"cpu_info" and in "cpu_info: {topology }.
Only defined parameters are allowed and new error messages are displayed
if parameters do not fit requirement.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 API.json | 8 ++++++--
 i18n.py  | 2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/API.json b/API.json
index ff505b1..590bc52 100644
--- a/API.json
+++ b/API.json
@@ -62,9 +62,13 @@
                             "minimum": 1,
                             "error": "KCHTMPL0026E"
                         }
-                    }
+                    },
+                    "additionalProperties": false,
+                    "error": "KCHCPUINF0009E"
                 }
-            }
+            },
+            "additionalProperties": false,
+            "error": "KCHCPUINF0008E"
         },
         "memory": {
             "description": "Current memory and maximum memory values",
diff --git a/i18n.py b/i18n.py
index 12b70fa..6491f72 100644
--- a/i18n.py
+++ b/i18n.py
@@ -325,6 +325,8 @@ messages = {
     "KCHCPUINF0005E": _("When CPU topology is defined, vCPUs must be a multiple of a product of cores and threads."),
     "KCHCPUINF0006E": _("The number of threads is too large for this system."),
     "KCHCPUINF0007E": _("When CPU topology is specified, sockets, cores and threads are required paramaters."),
+    "KCHCPUINF0008E": _("Parameter 'cpu_info' expects an object with fields among: 'vcpus', 'maxvcpus', 'topology'."),
+    "KCHCPUINF0009E": _("Parameter 'topology' expects an object with fields among: 'sockets', 'cores', 'threads'."),
 
     "KCHLVMS0001E": _("Invalid volume group name parameter: %(name)s."),
 
-- 
2.1.0




More information about the Kimchi-devel mailing list