
Hi, Some tests are failing with this patch: ***** Running unit test: test_template... FAILED ====================================================================== FAIL: test_customized_network (test_template.TemplateTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "test_template.py", line 397, in test_customized_network self.assertEquals(200, resp.status) AssertionError: 200 != 500 ====================================================================== FAIL: test_customized_storagepool (test_template.TemplateTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "test_template.py", line 459, in test_customized_storagepool self.assertEquals(200, resp.status) AssertionError: 200 != 500 ====================================================================== FAIL: test_customized_tmpl (test_template.TemplateTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "test_template.py", line 212, in test_customized_tmpl self.assertEquals(200, resp.status) AssertionError: 200 != 500 ====================================================================== FAIL: test_tmpl_integrity (test_template.TemplateTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "test_template.py", line 516, in test_tmpl_integrity self.assertEquals(204, resp.status) AssertionError: 204 != 400 ---------------------------------------------------------------------- Ran 5 tests in 4.866s On 10/23/2016 10:38 AM, archus@linux.vnet.ibm.com wrote:
From: Archana Singh <archus@linux.vnet.ibm.com>
If template name is change to update and the new template name to be updated already exists then exception is raised stating name already exists.
Signed-off-by: Archana Singh <archus@linux.vnet.ibm.com> --- model/templates.py | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/model/templates.py b/model/templates.py index c3e24e1..e5663ad 100644 --- a/model/templates.py +++ b/model/templates.py @@ -231,6 +231,14 @@ class TemplateModel(object): def update(self, name, params): edit_template = self.lookup(name)
+ # If new name is not same as existing name + # and new name already exists: raise exception + with self.objstore as session: + if name != params['name'] \ + and params['name'] in session.get_list('template'): + raise InvalidOperation("KCHTMPL0001E", + {'name': params['name']}) + # Valid interfaces interfaces = params.get('interfaces', []) validate_interfaces(interfaces)