From 89f91daa49c201ef12717dbd4876639581036bbe Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Fri, 4 Jan 2013 11:28:26 -0500 Subject: Handle directory conflicts with html output. When calling html_report() if the output path already exists instead of rewriting the files in the directory html_report throws OSError: [Errno 17] File exists which leads to a 500 return to the api call. This commit avoids this issue by checking if the directory exists beforehand and returning a 400 with an error message instead. Change-Id: I061534c9ce9977692a7fc98187c4797b2ed60ab2 --- nova/api/openstack/compute/contrib/coverage_ext.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nova/api/openstack/compute/contrib/coverage_ext.py b/nova/api/openstack/compute/contrib/coverage_ext.py index 7ad549d4c..e451111a4 100644 --- a/nova/api/openstack/compute/contrib/coverage_ext.py +++ b/nova/api/openstack/compute/contrib/coverage_ext.py @@ -203,6 +203,9 @@ class CoverageController(object): if xml: self.coverInst.xml_report(outfile=path) elif html: + if os.path.isdir(path): + msg = _("Directory conflict: %s already exists") + raise exc.HTTPBadRequest(explanation=msg) self.coverInst.html_report(directory=path) else: output = open(path, 'w') -- cgit