[Kimchi-devel] [PATCH v6 09/10] Debug Report: Update MockModel
Hongliang Wang
hlwang at linux.vnet.ibm.com
Mon Jul 14 09:45:25 UTC 2014
Added rename function in mock model.
Signed-off-by: Hongliang Wang <hlwang at linux.vnet.ibm.com>
---
src/kimchi/mockmodel.py | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index a0920e0..f4609a2 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -25,6 +25,7 @@ import disks
import glob
import ipaddr
import os
+import shutil
import psutil
import random
import string
@@ -325,7 +326,7 @@ class MockModel(object):
except IndexError:
raise NotFoundError("KCHDR0001E", {'name': name})
- ctime = os.stat(file_target).st_ctime
+ ctime = os.stat(file_target).st_mtime
ctime = time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime(ctime))
file_target = os.path.split(file_target)[-1]
file_target = os.path.join("/data/debugreports", file_target)
@@ -335,6 +336,21 @@ class MockModel(object):
def debugreportcontent_lookup(self, name):
return self.debugreport_lookup(name)
+ def debugreport_update(self, name, params):
+ path = config.get_debugreports_path()
+ file_pattern = os.path.join(path, name + '.txt')
+ 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)
+ return params['name']
+
def debugreport_delete(self, name):
path = config.get_debugreports_path()
file_pattern = os.path.join(path, name + '.txt')
--
1.8.1.4
More information about the Kimchi-devel
mailing list