Merge "Add policy validation for senlin"
This commit is contained in:
commit
d10a80cc40
|
@ -641,6 +641,18 @@ class Proxy(proxy2.BaseProxy):
|
|||
"""
|
||||
return self._update(_policy.Policy, policy, **attrs)
|
||||
|
||||
def validate_policy(self, **attrs):
|
||||
"""Validate a policy spec.
|
||||
|
||||
:param dict attrs: Keyword arguments that will be used to create a
|
||||
:class:`~openstack.cluster.v1.policy.PolicyValidate`, it is
|
||||
comprised of the properties on the Policy class.
|
||||
|
||||
:returns: The results of Policy validation.
|
||||
:rtype: :class:`~openstack.cluster.v1.policy.PolicyValidate`.
|
||||
"""
|
||||
return self._create(_policy.PolicyValidate, **attrs)
|
||||
|
||||
def cluster_policies(self, cluster, **query):
|
||||
"""Retrieve a generator of cluster-policy bindings.
|
||||
|
||||
|
|
|
@ -45,3 +45,16 @@ class Policy(resource.Resource):
|
|||
spec = resource.Body('spec', type=dict)
|
||||
#: A dictionary containing runtime data of the policy.
|
||||
data = resource.Body('data', type=dict)
|
||||
|
||||
|
||||
class PolicyValidate(Policy):
|
||||
base_path = '/policies/validate'
|
||||
|
||||
# Capabilities
|
||||
allow_list = False
|
||||
allow_get = False
|
||||
allow_create = True
|
||||
allow_delete = False
|
||||
allow_update = False
|
||||
|
||||
patch_update = False
|
||||
|
|
|
@ -63,3 +63,21 @@ class TestPolicy(testtools.TestCase):
|
|||
self.assertEqual(FAKE['data'], sot.data)
|
||||
self.assertEqual(FAKE['created_at'], sot.created_at)
|
||||
self.assertEqual(FAKE['updated_at'], sot.updated_at)
|
||||
|
||||
|
||||
class TestPolicyValidate(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestPolicyValidate, self).setUp()
|
||||
|
||||
def test_basic(self):
|
||||
sot = policy.PolicyValidate()
|
||||
self.assertEqual('policy', sot.resource_key)
|
||||
self.assertEqual('policies', sot.resources_key)
|
||||
self.assertEqual('/policies/validate', sot.base_path)
|
||||
self.assertEqual('clustering', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_create)
|
||||
self.assertFalse(sot.allow_get)
|
||||
self.assertFalse(sot.allow_update)
|
||||
self.assertFalse(sot.allow_delete)
|
||||
self.assertFalse(sot.allow_list)
|
||||
|
|
|
@ -340,6 +340,9 @@ class TestClusterProxy(test_proxy_base2.TestProxyBase):
|
|||
def test_policy_create(self):
|
||||
self.verify_create(self.proxy.create_policy, policy.Policy)
|
||||
|
||||
def test_policy_validate(self):
|
||||
self.verify_create(self.proxy.validate_policy, policy.PolicyValidate)
|
||||
|
||||
def test_policy_delete(self):
|
||||
self.verify_delete(self.proxy.delete_policy, policy.Policy, False)
|
||||
|
||||
|
|
Loading…
Reference in New Issue