コード例 #1
0
ファイル: test_policy_api.py プロジェクト: KongJustin/senlin
    def test_policy_delete_in_use(self):
        policy = db_api.policy_create(self.ctx, self.new_policy_data())
        self.assertIsNotNone(policy)

        fields = {'enabled': True, 'level': 50}
        db_api.cluster_policy_attach(self.ctx, self.cluster.id, policy.id,
                                     fields)
        self.assertRaises(exception.ResourceBusyError, db_api.policy_delete,
                          self.ctx, policy.id)

        db_api.cluster_policy_detach(self.ctx, self.cluster.id, policy.id)
        db_api.policy_delete(self.ctx, policy.id)
        policy = db_api.policy_get(self.ctx, policy.id)
        self.assertIsNone(policy)
コード例 #2
0
ファイル: test_policy_api.py プロジェクト: jonnary/senlin
    def test_policy_delete_in_use(self):
        policy = db_api.policy_create(self.ctx, self.new_policy_data())
        self.assertIsNotNone(policy)

        fields = {
            'enabled': True,
        }
        db_api.cluster_policy_attach(self.ctx, self.cluster.id, policy.id,
                                     fields)
        self.assertRaises(exception.ResourceBusyError,
                          db_api.policy_delete,
                          self.ctx, policy.id)

        db_api.cluster_policy_detach(self.ctx, self.cluster.id, policy.id)
        db_api.policy_delete(self.ctx, policy.id)
        policy = db_api.policy_get(self.ctx, policy.id)
        self.assertIsNone(policy)
コード例 #3
0
    def test_policy_attach_detach(self):
        policy = self.create_policy()

        fields = {
            'enabled': True,
        }
        db_api.cluster_policy_attach(self.ctx, self.cluster.id, policy.id,
                                     fields)
        bindings = db_api.cluster_policy_get_all(self.ctx, self.cluster.id)
        self.assertEqual(1, len(bindings))
        self.assertTrue(bindings[0].enabled)

        # This will succeed
        db_api.cluster_policy_detach(self.ctx, self.cluster.id, policy.id)
        bindings = db_api.cluster_policy_get_all(self.ctx, self.cluster.id)
        self.assertEqual(0, len(bindings))

        # This will fail silently
        res = db_api.cluster_policy_detach(self.ctx, self.cluster.id, 'BOGUS')
        self.assertIsNone(res)
コード例 #4
0
    def test_policy_attach_detach(self):
        policy = self.create_policy()

        fields = {
            'enabled': True,
        }
        db_api.cluster_policy_attach(self.ctx, self.cluster.id, policy.id,
                                     fields)
        bindings = db_api.cluster_policy_get_all(self.ctx, self.cluster.id)
        self.assertEqual(1, len(bindings))
        self.assertTrue(bindings[0].enabled)

        # This will succeed
        db_api.cluster_policy_detach(self.ctx, self.cluster.id, policy.id)
        bindings = db_api.cluster_policy_get_all(self.ctx, self.cluster.id)
        self.assertEqual(0, len(bindings))

        # This will fail silently
        res = db_api.cluster_policy_detach(self.ctx, self.cluster.id, 'BOGUS')
        self.assertIsNone(res)