add no-delete flag and test
diff --git a/xos/tosca/resources/deployment.py b/xos/tosca/resources/deployment.py
index 87b1926..152b1f9 100644
--- a/xos/tosca/resources/deployment.py
+++ b/xos/tosca/resources/deployment.py
@@ -51,6 +51,10 @@
self.postprocess_privileges(DeploymentRole, DeploymentPrivilege, rolemap, obj, "deployment")
def delete(self, obj):
+ if self.get_property("no-delete"):
+ self.info("Deployment %s is marked no-delete")
+ return
+
if obj.sites.exists():
self.info("Deployment %s has active sites; skipping delete" % obj.name)
return
diff --git a/xos/tosca/tests/deploymenttest.py b/xos/tosca/tests/deploymenttest.py
index b194b64..0156613 100644
--- a/xos/tosca/tests/deploymenttest.py
+++ b/xos/tosca/tests/deploymenttest.py
@@ -11,6 +11,7 @@
"create_deployment_two_images",
"create_deployment_privilege",
"destroy_deployment",
+ "destroy_deployment_nodelete"
]
def cleanup(self):
@@ -94,6 +95,14 @@
self.destroy(self.make_nodetemplate("testdep", "tosca.nodes.Deployment"))
self.assert_noobj(Deployment, "testdep")
+ def destroy_deployment_nodelete(self):
+ self.assert_noobj(Deployment, "testdep")
+ self.execute(self.make_nodetemplate("testdep", "tosca.nodes.Deployment"))
+ instance = self.assert_obj(Deployment, "testdep")
+ self.destroy(self.make_nodetemplate("testdep", "tosca.nodes.Deployment",
+ props={"no-delete": True}))
+ self.assert_obj(Deployment, "testdep")
+
if __name__ == "__main__":
DeploymentTest()