[Kimchi-devel] [PATCH 3/6] Debug Report Rename: Implement Back-end

Sheldon shaohef at linux.vnet.ibm.com
Wed May 21 09:35:46 UTC 2014


looks good.

Just a minor inline comment below

On 05/21/2014 05:09 PM, Hongliang Wang wrote:
> Added processing in model and controller.
>
> Signed-off-by: Hongliang Wang <hlwang at linux.vnet.ibm.com>
> ---
>   src/kimchi/control/debugreports.py |  4 +++-
>   src/kimchi/model/debugreports.py   | 13 +++++++++++++
>   2 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/src/kimchi/control/debugreports.py b/src/kimchi/control/debugreports.py
> index 3c12230..65b53a3 100644
> --- a/src/kimchi/control/debugreports.py
> +++ b/src/kimchi/control/debugreports.py
> @@ -22,7 +22,7 @@ from kimchi.control.utils import internal_redirect
>   from kimchi.control.utils import UrlSubNode
>
>
> - at UrlSubNode("debugreports", True, ['GET', 'POST'])
> + at UrlSubNode("debugreports", True, ['GET', 'PUT', 'POST'])
>   class DebugReports(AsyncCollection):
>       def __init__(self, model):
>           super(DebugReports, self).__init__(model)
> @@ -32,6 +32,8 @@ class DebugReports(AsyncCollection):
>   class DebugReport(Resource):
>       def __init__(self, model, ident):
>           super(DebugReport, self).__init__(model, ident)
> +        self.update_params = ["name"]
> +        self.uri_fmt = '/debugreports/%s'
>           self.content = DebugReportContent(model, ident)
>
>       @property
> diff --git a/src/kimchi/model/debugreports.py b/src/kimchi/model/debugreports.py
> index cd31b31..43c4fb6 100644
> --- a/src/kimchi/model/debugreports.py
> +++ b/src/kimchi/model/debugreports.py
> @@ -170,6 +170,19 @@ class DebugReportModel(object):
>           return {'uri': file_target,
>                   'ctime': ctime}
>
> +    def update(self, name, params):
> +        path = config.get_debugreports_path()
> +        file_pattern = os.path.join(path, name + '.*')
> +        try:
> +            file_source = glob.glob(file_pattern)[0]
> +        except IndexError:
> +            raise NotFoundError("KCHDR0001E", {'name': name})
> +
> +        file_target = file_source.replace(name, params['name'])
> +        shutil.move(file_source, file_target)
> +        kimchi_log.info('%s renamed to %s' % (file_source, file_target))
This is right for python string formatting.
'%s renamed to %s' % (file_source, file_target))
But we use comma for log. logger has itself string formatting.
kimchi_log.info('%s renamed to %s', file_source, file_target)
> +        return params['name']
> +
>       def delete(self, name):
>           path = config.get_debugreports_path()
>           file_pattern = os.path.join(path, name + '.*')


-- 
Thanks and best regards!

Sheldon Feng(冯少合)<shaohef at linux.vnet.ibm.com>
IBM Linux Technology Center




More information about the Kimchi-devel mailing list