Reset the policy after loading extensions
The loading of extensions might impact how rules are interpreted in the policies; for instance, the external-net extension specifies how to convert the router:external field of a network (to a boolean). So we need to make sure that the policy is recreated afterwards. We also need to fix a unit test that assumes that the policy is loaded. Change-Id: Ifde13323b1435fc84c6cb24ab6a71de5d67f6b9f Closes-Bug: #1280738
This commit is contained in:
parent
2343e47d94
commit
3a7392af31
@ -32,6 +32,7 @@ from neutron.common import exceptions
|
|||||||
import neutron.extensions
|
import neutron.extensions
|
||||||
from neutron.manager import NeutronManager
|
from neutron.manager import NeutronManager
|
||||||
from neutron.openstack.common import log as logging
|
from neutron.openstack.common import log as logging
|
||||||
|
from neutron import policy
|
||||||
from neutron import wsgi
|
from neutron import wsgi
|
||||||
|
|
||||||
|
|
||||||
@ -401,6 +402,7 @@ class ExtensionManager(object):
|
|||||||
self.path = path
|
self.path = path
|
||||||
self.extensions = {}
|
self.extensions = {}
|
||||||
self._load_all_extensions()
|
self._load_all_extensions()
|
||||||
|
policy.reset()
|
||||||
|
|
||||||
def get_resources(self):
|
def get_resources(self):
|
||||||
"""Returns a list of ResourceExtension objects."""
|
"""Returns a list of ResourceExtension objects."""
|
||||||
|
@ -36,6 +36,7 @@ from neutron.manager import NeutronManager
|
|||||||
from neutron.openstack.common.notifier import api as notifer_api
|
from neutron.openstack.common.notifier import api as notifer_api
|
||||||
from neutron.openstack.common import policy as common_policy
|
from neutron.openstack.common import policy as common_policy
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
|
from neutron import policy
|
||||||
from neutron import quota
|
from neutron import quota
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
from neutron.tests.unit import testlib_api
|
from neutron.tests.unit import testlib_api
|
||||||
@ -1060,6 +1061,7 @@ class JSONV2TestCase(APIv2TestBase, testlib_api.WebTestCase):
|
|||||||
def test_get_keystone_strip_admin_only_attribute(self):
|
def test_get_keystone_strip_admin_only_attribute(self):
|
||||||
tenant_id = _uuid()
|
tenant_id = _uuid()
|
||||||
# Inject rule in policy engine
|
# Inject rule in policy engine
|
||||||
|
policy.init()
|
||||||
common_policy._rules['get_network:name'] = common_policy.parse_rule(
|
common_policy._rules['get_network:name'] = common_policy.parse_rule(
|
||||||
"rule:admin_only")
|
"rule:admin_only")
|
||||||
res = self._test_get(tenant_id, tenant_id, 200)
|
res = self._test_get(tenant_id, tenant_id, 200)
|
||||||
|
Loading…
Reference in New Issue
Block a user