]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove calls to policy.check and policy.enforce from plugin code
authorSalvatore Orlando <salv.orlando@gmail.com>
Wed, 21 Aug 2013 09:47:19 +0000 (02:47 -0700)
committerSalvatore Orlando <salv.orlando@gmail.com>
Wed, 21 Aug 2013 12:37:38 +0000 (05:37 -0700)
Completes blueprint make-authz-orthogonal

This patch removes a few explicit policy checks recently added to
the plumgrid and cisco plugins.
They are not necessary as the same checks are already performed
by the policy engine.

Change-Id: Ie99f5fa6ad4a9568b050827bc479a62dd40e18ac

neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py
neutron/plugins/plumgrid/plumgrid_plugin/plumgrid_plugin.py

index 4f1f56c038582a2fe64a8981fa3beac0ad508fe5..5af9b2ea5675cd8e40ecde32b9c0957175ea4c1e 100644 (file)
@@ -49,7 +49,6 @@ from neutron.plugins.cisco.db import n1kv_db_v2
 from neutron.plugins.cisco.db import network_db_v2
 from neutron.plugins.cisco.extensions import n1kv_profile
 from neutron.plugins.cisco.n1kv import n1kv_client
-from neutron import policy
 
 
 LOG = logging.getLogger(__name__)
@@ -270,16 +269,6 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
         if physical_network not in self.network_vlan_ranges:
             self.network_vlan_ranges[physical_network] = []
 
-    def _check_provider_view_auth(self, context, network):
-        return policy.check(context,
-                            "extension:provider_network:view",
-                            network)
-
-    def _enforce_provider_set_auth(self, context, network):
-        return policy.enforce(context,
-                              "extension:provider_network:set",
-                              network)
-
     def _extend_network_dict_provider(self, context, network):
         """Add extended network parameters."""
         binding = n1kv_db_v2.get_network_binding(context.session,
@@ -306,9 +295,6 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
                 segmentation_id_set):
             return (None, None, None)
 
-        # Authorize before exposing plugin details to client
-        self._enforce_provider_set_auth(context, attrs)
-
         if not network_type_set:
             msg = _("provider:network_type required")
             raise q_exc.InvalidInput(error_message=msg)
@@ -366,9 +352,6 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
                 segmentation_id_set):
             return
 
-        # Authorize before exposing plugin details to client
-        self._enforce_provider_set_auth(context, attrs)
-
         # TBD : Need to handle provider network updates
         msg = _("plugin does not support updating provider attributes")
         raise q_exc.InvalidInput(error_message=msg)
index 14fff1c3d6f57fd10fc94a7d2d3d4c3792e84328..cd33b707d7f0b74584d84093818b835d127a61c7 100644 (file)
@@ -34,7 +34,6 @@ from neutron.openstack.common import importutils
 from neutron.openstack.common import log as logging
 from neutron.plugins.plumgrid.common import exceptions as plum_excep
 from neutron.plugins.plumgrid.plumgrid_plugin.plugin_ver import VERSION
-from neutron import policy
 
 LOG = logging.getLogger(__name__)
 PLUM_DRIVER = 'neutron.plugins.plumgrid.drivers.plumlib.Plumlib'
@@ -492,16 +491,12 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
         return VERSION
 
     def _port_viftype_binding(self, context, port):
-        if self._check_view_auth(context, port, self.binding_view):
-            port[portbindings.VIF_TYPE] = portbindings.VIF_TYPE_IOVISOR
-            port[portbindings.CAPABILITIES] = {
-                portbindings.CAP_PORT_FILTER:
-                'security-group' in self.supported_extension_aliases}
+        port[portbindings.VIF_TYPE] = portbindings.VIF_TYPE_IOVISOR
+        port[portbindings.CAPABILITIES] = {
+            portbindings.CAP_PORT_FILTER:
+            'security-group' in self.supported_extension_aliases}
         return port
 
-    def _check_view_auth(self, context, resource, action):
-        return policy.check(context, action, resource)
-
     def _network_admin_state(self, network):
         try:
             if network["network"].get("admin_state_up"):