[CORD-2715] making sure we are not deleting object with must-exist key set to true, as they are included for reference
Change-Id: I07587e6f57b4558554712d67cd21f161c4fe8df5
diff --git a/src/tosca/parser.py b/src/tosca/parser.py
index 854ff00..9166dd2 100644
--- a/src/tosca/parser.py
+++ b/src/tosca/parser.py
@@ -222,9 +222,15 @@
model = self.populate_dependencies(model, recipe.requirements, self.saved_model_by_name)
# [] save, update or delete
- if self.delete and not model.is_new:
+ reference_only = False
+ if 'must-exist' in data:
+ reference_only = True
+
+ if self.delete and not model.is_new and not reference_only:
+ print "[XOS-Tosca] Deleting model %s[%s]" % (class_name, model.id)
model.delete()
elif not self.delete:
+ print "[XOS-Tosca] Saving model %s[%s]" % (class_name, model.id)
model.save()
self.saved_model_by_name[recipe.name] = model
@@ -247,6 +253,7 @@
exception_msg = e._state.details
raise Exception(exception_msg)
except Exception, e:
+ print e
raise Exception(e)