Ejemplo n.º 1
0
    def create(cls, ctx, name, spec, metadata=None):
        profile = super(DockerProfile, cls).create(ctx, name, spec, metadata)

        host_cluster = profile.properties.get(profile.HOST_CLUSTER, None)
        if host_cluster:
            db_api.cluster_add_dependents(ctx, host_cluster, profile.id)

        host_node = profile.properties.get(profile.HOST_NODE, None)
        if host_node:
            db_api.node_add_dependents(ctx, host_node, profile.id, 'profile')

        return profile
Ejemplo n.º 2
0
 def test_cluster_add_dependents(self):
     cluster = shared.create_cluster(self.ctx, self.profile)
     profile_id = 'profile1'
     db_api.cluster_add_dependents(self.ctx, cluster.id, profile_id)
     res = db_api.cluster_get(self.ctx, cluster.id)
     self.assertEqual(['profile1'], res.dependents['profiles'])
     deps = {}
     cluster = shared.create_cluster(self.ctx, self.profile,
                                     dependents=deps)
     db_api.cluster_add_dependents(self.ctx, cluster.id, profile_id)
     res = db_api.cluster_get(self.ctx, cluster.id)
     deps = {'profiles': ['profile1']}
     self.assertEqual(deps, res.dependents)
     db_api.cluster_add_dependents(self.ctx, cluster.id, 'profile2')
     res = db_api.cluster_get(self.ctx, cluster.id)
     deps = {'profiles': ['profile1', 'profile2']}
     self.assertEqual(deps, res.dependents)