def delete(cls, ctx, profile_id): obj = cls.load(ctx, profile_id=profile_id) cluster_id = obj.properties.get(obj.HOST_CLUSTER, None) if cluster_id: db_api.cluster_remove_dependents(ctx, cluster_id, profile_id) node_id = obj.properties.get(obj.HOST_NODE, None) if node_id: db_api.node_remove_dependents(ctx, node_id, profile_id, 'profile') super(DockerProfile, cls).delete(ctx, profile_id)
def test_cluster_remove_dependents(self): deps = {'profiles': ['profile1', 'profile2']} cluster = shared.create_cluster(self.ctx, self.profile, dependents=deps) db_api.cluster_remove_dependents(self.ctx, cluster.id, 'profile1') res = db_api.cluster_get(self.ctx, cluster.id) deps = {'profiles': ['profile2']} self.assertEqual(deps, res.dependents) db_api.cluster_remove_dependents(self.ctx, cluster.id, 'profile2') res = db_api.cluster_get(self.ctx, cluster.id) deps = {} self.assertEqual(deps, res.dependents)