[Kimchi-devel] [PATCH v5 03/10] Debug Report Rename: Implement Back-end

Aline Manera alinefm at linux.vnet.ibm.com
Sun Jul 13 16:54:37 UTC 2014


Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>

On 07/11/2014 06:17 AM, 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   | 16 ++++++++++++++++
>   2 files changed, 19 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 27f1b56..10ef233 100644
> --- a/src/kimchi/model/debugreports.py
> +++ b/src/kimchi/model/debugreports.py
> @@ -174,6 +174,22 @@ 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'])
> +        if os.path.isfile(file_target):
> +            raise InvalidParameter('KCHDR0008E', {'name': params['name']})
> +
> +        shutil.move(file_source, file_target)
> +        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 + '.*')
>




More information about the Kimchi-devel mailing list