Reviewed-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
On 07/10/2014 12:31 PM, Hongliang Wang wrote:
We'll generate a report name if name field is left blank in real
case,
though not in mock model. Added it in mock model to keep consistent.
Signed-off-by: Hongliang Wang <hlwang(a)linux.vnet.ibm.com>
---
src/kimchi/mockmodel.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index a0920e0..be78ce8 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -346,7 +346,13 @@ class MockModel(object):
os.remove(file_target)
def debugreports_create(self, params):
- ident = params['name']
+ ident = params.get('name').strip()
+ # Generate a name with time and millisec precision, if necessary
+ if ident is None or ident == "":
+ ident = 'report-' + str(int(time.time() * 1000))
+ else:
+ if ident in self.debugreports_get_list():
+ raise InvalidParameter("KCHDR0008E", {"name":
ident})
taskid = self._gen_debugreport_file(ident)
return self.task_lookup(taskid)