[Kimchi-devel] [PATCH v3 3/8] Debug Report Rename: Implement Back-end
Hongliang Wang
hlwang at linux.vnet.ibm.com
Fri Jun 13 07:09:55 UTC 2014
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 7994fec..e5125c9 100644
--- a/src/kimchi/model/debugreports.py
+++ b/src/kimchi/model/debugreports.py
@@ -173,6 +173,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 ResourceAlreadyExists('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 + '.*')
--
1.8.1.4
More information about the Kimchi-devel
mailing list