[Kimchi-devel] [PATCH 1/2] Fix debug report naming problem (backend)

Aline Manera alinefm at linux.vnet.ibm.com
Fri Feb 21 17:25:50 UTC 2014


On 02/21/2014 12:29 PM, Rodrigo Trujillo wrote:
> The tool sosreport only accepts letters, digits and hyphen in the name
> of the report, non alphanumeric characteres are removed from the file
> name and then Kimchi is not able to find the file.
>
> This patch fixes the problem in the backend, adding json schema
> verification.
>
> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
> ---
>   src/kimchi/API.json        | 13 +++++++++++++
>   src/kimchi/control/base.py |  1 +
>   src/kimchi/i18n.py         |  3 +++
>   3 files changed, 17 insertions(+)
>
> diff --git a/src/kimchi/API.json b/src/kimchi/API.json
> index d3a8e64..562864c 100644
> --- a/src/kimchi/API.json
> +++ b/src/kimchi/API.json
> @@ -29,6 +29,19 @@
>           }
>       },
>       "properties": {
> +        "debugreports_create": {
> +            "type": "object",
> +            "error": "KCHDEBREP0001E",
> +            "properties": {
> +                "name": {
> +                    "description": "The name for the debug report file.",
> +                    "type": "string",
> +                    "pattern": "^[A-Za-z0-9-]+$",

> +                    "required": true,

Why did you make the name a required parameter?

> +                    "error": "KCHDEBREP0002E"
> +                }
> +            }
> +        },
>           "storagepools_create": {
>               "type": "object",
>               "error": "KCHPOOL0026E",
> diff --git a/src/kimchi/control/base.py b/src/kimchi/control/base.py
> index e8f03ae..100f143 100644
> --- a/src/kimchi/control/base.py
> +++ b/src/kimchi/control/base.py
> @@ -306,6 +306,7 @@ class AsyncCollection(Collection):
>                                                    get_class_name(self)})
>               raise cherrypy.HTTPError(405, e.message)
>
> +        validate_params(params, self, 'create')
>           args = self.model_args + [params]
>           task = create(*args)
>           cherrypy.response.status = 202
> diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py
> index a8d2f29..8b3db9c 100644
> --- a/src/kimchi/i18n.py
> +++ b/src/kimchi/i18n.py
> @@ -49,6 +49,9 @@ messages = {
>       "KCHISCSI0001E": _("Unable to login to iSCSI host target %(portal)s. Details: %(err)s"),
>       "KCHISCSI0002E": _("Unable to login to iSCSI host %(host)s target %(target)s"),
>
> +    "KCHDEBREP0001E": _("You must give a name for the debug file report."),

Same as I commented above

> +    "KCHDEBREP0002E": _("Name must be a non empty string. Only letters, digits and hyphen ('-') are allowed."),
> +
>       "KCHISO0001E": _("Unable to find ISO file ISO %(filename)s"),
>       "KCHISO0002E": _("The ISO file %(filename)s is not bootable"),
>       "KCHISO0003E": _("The ISO file %(filename)s does not have a valid El Torito boot record"),




More information about the Kimchi-devel mailing list