Reviewed-By: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
On 23/10/2016 10:38, archus(a)linux.vnet.ibm.com wrote:
From: Archana Singh <archus(a)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(a)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)
--
Lucio Correia
Software Engineer
IBM LTC Brazil