[PATCH 0/2] Fix debug report naming error

The two patch fix a problem reported by internal test team. Rodrigo Trujillo (2): Fix debug report naming problem (backend) Fix debug report naming problem (UI) src/kimchi/API.json | 13 +++++++++++++ src/kimchi/control/base.py | 1 + src/kimchi/i18n.py | 3 +++ ui/js/src/kimchi.report_add_main.js | 9 +++++++-- ui/pages/report-add.html.tmpl | 2 +- 5 files changed, 25 insertions(+), 3 deletions(-) -- 1.8.5.3

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@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, + "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."), + "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"), -- 1.8.5.3

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@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"),

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@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, + "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."), + "KCHDEBREP0002E": _("Name must be a non empty string. Only letters, digits and hyphen ('-') are allowed."), +
The debug reports messages use the code KCHDR<number> Add the new message following the next number
"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"),

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 modifies the UI html and js in order to show the right information and catch the right return error message. Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- ui/js/src/kimchi.report_add_main.js | 9 +++++++-- ui/pages/report-add.html.tmpl | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ui/js/src/kimchi.report_add_main.js b/ui/js/src/kimchi.report_add_main.js index f893d85..96d9625 100644 --- a/ui/js/src/kimchi.report_add_main.js +++ b/ui/js/src/kimchi.report_add_main.js @@ -25,8 +25,13 @@ kimchi.report_add_main = function() { result: result }); }, function(result) { - result && result['reason'] && - $('#report-error-message').text(result['reason']); + if (result['reason']) { + var errText = result['reason']; + } + else { + var errText = result['responseJSON']['reason']; + } + result && $('#report-error-message').text(errText); submitButton .text(i18n['KCHDR6006M']) .prop('disabled', false); diff --git a/ui/pages/report-add.html.tmpl b/ui/pages/report-add.html.tmpl index 2a962d4..383175f 100644 --- a/ui/pages/report-add.html.tmpl +++ b/ui/pages/report-add.html.tmpl @@ -38,7 +38,7 @@ </h2> <div class="field"> <span> - $_("The name used to identify the report. If omitted, a name will be chosen based on current time. Name can contain: letters, digits, \"-\", \"_\", or \".\".") + $_("The name used to identify the report. If omitted, a name will be chosen based on current time. Name can contain: letters, digits and hyphen (\"-\").") </span> <input type="text" class="text" id="report-name-textbox" name="name" /> <span id="report-error-message"></span> -- 1.8.5.3

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 modifies the UI html and js in order to show the right information and catch the right return error message.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- ui/js/src/kimchi.report_add_main.js | 9 +++++++-- ui/pages/report-add.html.tmpl | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/ui/js/src/kimchi.report_add_main.js b/ui/js/src/kimchi.report_add_main.js index f893d85..96d9625 100644 --- a/ui/js/src/kimchi.report_add_main.js +++ b/ui/js/src/kimchi.report_add_main.js @@ -25,8 +25,13 @@ kimchi.report_add_main = function() { result: result }); }, function(result) { - result && result['reason'] && - $('#report-error-message').text(result['reason']); + if (result['reason']) { + var errText = result['reason']; + } + else { + var errText = result['responseJSON']['reason']; + } + result && $('#report-error-message').text(errText); submitButton
We should not send a request to server with invalid data. So verify the debug report name in UI too and only request server if it is a valid one
.text(i18n['KCHDR6006M']) .prop('disabled', false); diff --git a/ui/pages/report-add.html.tmpl b/ui/pages/report-add.html.tmpl index 2a962d4..383175f 100644 --- a/ui/pages/report-add.html.tmpl +++ b/ui/pages/report-add.html.tmpl @@ -38,7 +38,7 @@ </h2> <div class="field"> <span> - $_("The name used to identify the report. If omitted, a name will be chosen based on current time. Name can contain: letters, digits, \"-\", \"_\", or \".\".") + $_("The name used to identify the report. If omitted, a name will be chosen based on current time. Name can contain: letters, digits and hyphen (\"-\").") </span> <input type="text" class="text" id="report-name-textbox" name="name" /> <span id="report-error-message"></span>
participants (2)
-
Aline Manera
-
Rodrigo Trujillo