Merge "PLUMgrid plugin: Fix for delete subnet with admin context"

This commit is contained in:
Jenkins 2014-12-22 16:57:00 +00:00 committed by Gerrit Code Review
commit 2b378162f3
2 changed files with 39 additions and 1 deletions

View File

@ -356,9 +356,9 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
LOG.debug("Neutron PLUMgrid Director: delete_subnet() called") LOG.debug("Neutron PLUMgrid Director: delete_subnet() called")
# Collecting subnet info # Collecting subnet info
sub_db = self._get_subnet(context, subnet_id) sub_db = self._get_subnet(context, subnet_id)
tenant_id = self._get_tenant_id_for_create(context, subnet_id)
net_id = sub_db["network_id"] net_id = sub_db["network_id"]
net_db = self.get_network(context, net_id) net_db = self.get_network(context, net_id)
tenant_id = net_db["tenant_id"]
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
# Plugin DB - Subnet Delete # Plugin DB - Subnet Delete

View File

@ -19,6 +19,7 @@ Test cases for Neutron PLUMgrid Plug-in
import mock import mock
from oslo.utils import importutils from oslo.utils import importutils
from neutron import context
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.extensions import providernet as provider from neutron.extensions import providernet as provider
from neutron import manager from neutron import manager
@ -91,6 +92,43 @@ class TestPlumgridPluginSubnetsV2(test_plugin.TestSubnetsV2,
self.skipTest("Plugin does not support Neutron allocation process") self.skipTest("Plugin does not support Neutron allocation process")
super(TestPlumgridPluginSubnetsV2, self).setUp() super(TestPlumgridPluginSubnetsV2, self).setUp()
def test_subnet_admin_delete(self):
plugin = manager.NeutronManager.get_plugin()
admin_context = context.get_admin_context()
tenant_context = context.Context('', 'not_admin')
network1 = self._fake_network('network1')
network1_ret = plugin.create_network(tenant_context, network1)
subnet1 = self._fake_subnet(network1_ret['id'])
plugin.create_subnet(tenant_context, subnet1)
net_db = plugin.get_network(admin_context, network1_ret['id'])
self.assertEqual(network1_ret['tenant_id'], net_db["tenant_id"])
def _fake_network(self, name):
data = {'network': {'name': name,
'admin_state_up': False,
'shared': False,
'router:external': [],
'provider:network_type': None,
'provider:segmentation_id': None,
'provider:physical_network': None}}
return data
def _fake_subnet(self, net_id):
allocation_pools = [{'start': '10.0.0.2',
'end': '10.0.0.254'}]
return {'subnet': {'name': net_id,
'network_id': net_id,
'gateway_ip': '10.0.0.1',
'dns_nameservers': ['10.0.0.2'],
'host_routes': [],
'cidr': '10.0.0.0/24',
'allocation_pools': allocation_pools,
'enable_dhcp': True,
'ip_version': 4}}
class TestPlumgridPluginPortBinding(PLUMgridPluginV2TestCase, class TestPlumgridPluginPortBinding(PLUMgridPluginV2TestCase,
test_bindings.PortBindingsTestCase): test_bindings.PortBindingsTestCase):