Fix plugin(s) following upstream changes

Commit 3082949cffeefd7ef0dcc3f63f235ce597539ef3 deleted the
API method _get_tenant_id_for_create.

Commit 526d28c5dba75e517bf833b895b69b840f03c6a4 added in a use
case not relevant for NSX|V3

Change-Id: I039165be0e49e5dd58284750b08b091b120c0468
This commit is contained in:
Gary Kotton 2016-01-08 06:51:55 -08:00
parent 165e9a0d6d
commit afcf3f3232
9 changed files with 22 additions and 21 deletions

View File

@ -215,7 +215,7 @@ class NetworkGatewayMixin(networkgw.NetworkGatewayPluginBase):
def create_network_gateway(self, context, network_gateway,
validate_device_list=True):
gw_data = network_gateway[self.gateway_resource]
tenant_id = self._get_tenant_id_for_create(context, gw_data)
tenant_id = gw_data['tenant_id']
with context.session.begin(subtransactions=True):
gw_db = nsx_models.NetworkGateway(
id=gw_data.get('id', uuidutils.generate_uuid()),
@ -279,9 +279,7 @@ class NetworkGatewayMixin(networkgw.NetworkGatewayPluginBase):
'network_gateway_id': network_gateway_id})
with context.session.begin(subtransactions=True):
gw_db = self._get_network_gateway(context, network_gateway_id)
tenant_id = self._get_tenant_id_for_create(context, gw_db)
# _get_tenant_id_for_create might return None in some cases.
# This is not acceptable for the NSX plugin
tenant_id = gw_db['tenant_id']
if context.is_admin and not tenant_id:
tenant_id = context.tenant_id
# TODO(salvatore-orlando): Leverage unique constraint instead
@ -439,7 +437,7 @@ class NetworkGatewayMixin(networkgw.NetworkGatewayPluginBase):
def create_gateway_device(self, context, gateway_device,
initial_status=STATUS_UNKNOWN):
device_data = gateway_device[self.device_resource]
tenant_id = self._get_tenant_id_for_create(context, device_data)
tenant_id = device_data['tenant_id']
with context.session.begin(subtransactions=True):
device_db = nsx_models.NetworkGatewayDevice(
id=device_data.get('id', uuidutils.generate_uuid()),

View File

@ -228,7 +228,7 @@ class QoSDbMixin(qos.QueuePluginBase):
queue_to_create = queue_to_create[0]
# create the queue
tenant_id = self._get_tenant_id_for_create(context, port)
tenant_id = port['tenant_id']
if port.get(qos.RXTX_FACTOR) and queue_to_create.get('max'):
queue_to_create['max'] = int(queue_to_create['max'] *
port[qos.RXTX_FACTOR])

View File

@ -210,7 +210,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# Create in DB only - don't go to backend
def_gw_data = {'id': def_l2_gw_uuid,
'name': 'default L2 gateway service',
'devices': []}
'devices': [],
'tenant_id': ctx.tenant_id}
gw_res_name = networkgw.GATEWAY_RESOURCE_NAME.replace('-', '_')
def_network_gw = super(
NsxPluginV2, self).create_network_gateway(
@ -909,7 +910,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
def create_network(self, context, network):
net_data = network['network']
tenant_id = self._get_tenant_id_for_create(context, net_data)
tenant_id = net_data['tenant_id']
self._ensure_default_security_group(context, tenant_id)
# Process the provider network extension
provider_type = self._convert_to_transport_zones_dict(net_data)
@ -1188,7 +1189,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# they've already been processed
port['port'].pop('fixed_ips', None)
ret_port.update(port['port'])
tenant_id = self._get_tenant_id_for_create(context, ret_port)
tenant_id = ret_port['tenant_id']
self._update_extra_dhcp_opts_on_port(context, id, port, ret_port)
# populate port_security setting
@ -1361,7 +1362,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
return super(NsxPluginV2, self).get_router(context, id, fields)
def _create_lrouter(self, context, router, nexthop):
tenant_id = self._get_tenant_id_for_create(context, router)
tenant_id = router['tenant_id']
distributed = router.get('distributed')
try:
lrouter = routerlib.create_lrouter(
@ -1409,7 +1410,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# 3rd parties to specify IDs as we do with l2 plugin
r = router['router']
has_gw_info = False
tenant_id = self._get_tenant_id_for_create(context, r)
tenant_id = r['tenant_id']
# default value to set - nsx wants it (even if we don't have it)
nexthop = NSX_DEFAULT_NEXTHOP
# if external gateway info are set, then configure nexthop to
@ -1993,7 +1994,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
structures in Neutron datase.
"""
gw_data = network_gateway[networkgw.GATEWAY_RESOURCE_NAME]
tenant_id = self._get_tenant_id_for_create(context, gw_data)
tenant_id = gw_data['tenant_id']
# Ensure the default gateway in the config file is in sync with the db
self._ensure_default_network_gateway()
# Validate provided gateway device list
@ -2300,7 +2301,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
"""
s = security_group.get('security_group')
tenant_id = self._get_tenant_id_for_create(context, s)
tenant_id = s['tenant_id']
if not default_sg:
self._ensure_default_security_group(context, tenant_id)
# NOTE(salv-orlando): Pre-generating Neutron ID for security group.

View File

@ -561,7 +561,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
def create_network(self, context, network):
net_data = network['network']
tenant_id = self._get_tenant_id_for_create(context, net_data)
tenant_id = net_data['tenant_id']
self._ensure_default_security_group(context, tenant_id)
# Process the provider network extension
provider_type = self._convert_to_transport_zones_dict(net_data)

View File

@ -412,8 +412,7 @@ class NsxV3Plugin(addr_pair_db.AllowedAddressPairsMixin,
else:
is_provider_net, net_type, physical_net, vlan_id = (
self._create_network_at_the_backend(context, net_data))
tenant_id = self._get_tenant_id_for_create(
context, net_data)
tenant_id = net_data['tenant_id']
self._ensure_default_security_group(context, tenant_id)
with context.session.begin(subtransactions=True):
@ -1452,7 +1451,7 @@ class NsxV3Plugin(addr_pair_db.AllowedAddressPairsMixin,
firewall_section = None
if not default_sg:
tenant_id = self._get_tenant_id_for_create(context, secgroup)
tenant_id = secgroup['tenant_id']
self._ensure_default_security_group(context, tenant_id)
try:

View File

@ -188,10 +188,7 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
self).delete_l2_gateway_connection(context,
l2gw_connection['id'])
# Create a logical port and connect it to the bridge endpoint.
tenant_id = self._core_plugin._get_tenant_id_for_create(context,
gw_connection)
# _get_tenant_id_for_create might return None in some cases.
# This is not acceptable for the NSX plugin
tenant_id = gw_connection['tenant_id']
if context.is_admin and not tenant_id:
tenant_id = context.tenant_id
#TODO(abhiraut): Consider specifying the name of the port

View File

@ -367,6 +367,7 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxPluginV2TestCase):
ctx, {'network': {'name': 'xxx',
'admin_state_up': True,
'shared': False,
'tenant_id': ctx.tenant_id,
'port_security_enabled': True}})
plugin.update_network(ctx, net['id'],
{'network': {'name': 'yyy'}})

View File

@ -1912,6 +1912,7 @@ class TestExclusiveRouterTestCase(L3NatTest, L3NatTestCaseBase,
side_effect=[n_exc.NeutronException]):
router = {'router': {'admin_state_up': True,
'name': 'e161be1d-0d0d-4046-9823-5a593d94f72c',
'tenant_id': context.get_admin_context().tenant_id,
'router_type': 'exclusive'}}
self.assertRaises(n_exc.NeutronException,
p.create_router,
@ -2385,6 +2386,7 @@ class TestVdrTestCase(L3NatTest, L3NatTestCaseBase,
side_effect=[n_exc.NeutronException]):
router = {'router': {'admin_state_up': True,
'name': 'e161be1d-0d0d-4046-9823-5a593d94f72c',
'tenant_id': context.get_admin_context().tenant_id,
'distributed': True}}
self.assertRaises(n_exc.NeutronException,
p.create_router,

View File

@ -292,6 +292,9 @@ class TestL3NatTestCase(L3NatTest,
def test_floatingip_multi_external_one_internal(self):
self.skipTest('not supported')
def test_floatingip_same_external_and_internal(self):
self.skipTest('not supported')
def test_multiple_subnets_on_different_routers(self):
with self.network() as network:
with self.subnet(network=network) as s1,\