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(a)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
-@UrlSubNode("debugreports", True, ['GET', 'POST'])
+@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(a)linux.vnet.ibm.com>
IBM Linux Technology Center