[Kimchi-devel] [PATCH] [Kimchi] Issue #1050: Rename template with existing template name
archus at linux.vnet.ibm.com
archus at linux.vnet.ibm.com
Sun Oct 23 12:38:34 UTC 2016
From: Archana Singh <archus at 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 at 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)
--
2.7.4
More information about the Kimchi-devel
mailing list