Merge "Fix gateway port could not retrieve for subnet"
This commit is contained in:
commit
70a0228892
@ -32,6 +32,9 @@ class DVRServerRpcApi(object):
|
||||
can be found below: DVRServerRpcCallback. For more information on changing
|
||||
rpc interfaces, see doc/source/devref/rpc_api.rst.
|
||||
"""
|
||||
# 1.0 Initial Version
|
||||
# 1.1 Support for passing 'fixed_ips' in get_subnet_for_dvr function.
|
||||
# Passing 'subnet" will be deprecated in the next release.
|
||||
|
||||
def __init__(self, topic):
|
||||
target = oslo_messaging.Target(topic=topic, version='1.0',
|
||||
@ -55,9 +58,10 @@ class DVRServerRpcApi(object):
|
||||
host=host, subnet=subnet)
|
||||
|
||||
@log_helpers.log_method_call
|
||||
def get_subnet_for_dvr(self, context, subnet):
|
||||
def get_subnet_for_dvr(self, context, subnet, fixed_ips):
|
||||
cctxt = self.client.prepare()
|
||||
return cctxt.call(context, 'get_subnet_for_dvr', subnet=subnet)
|
||||
return cctxt.call(
|
||||
context, 'get_subnet_for_dvr', subnet=subnet, fixed_ips=fixed_ips)
|
||||
|
||||
|
||||
class DVRServerRpcCallback(object):
|
||||
@ -70,8 +74,10 @@ class DVRServerRpcCallback(object):
|
||||
|
||||
# History
|
||||
# 1.0 Initial version
|
||||
# 1.1 Support for passing the 'fixed_ips" in get_subnet_for_dvr.
|
||||
# Passing subnet will be deprecated in the next release.
|
||||
|
||||
target = oslo_messaging.Target(version='1.0',
|
||||
target = oslo_messaging.Target(version='1.1',
|
||||
namespace=constants.RPC_NAMESPACE_DVR)
|
||||
|
||||
@property
|
||||
@ -96,8 +102,10 @@ class DVRServerRpcCallback(object):
|
||||
host, subnet)
|
||||
|
||||
def get_subnet_for_dvr(self, context, **kwargs):
|
||||
fixed_ips = kwargs.get('fixed_ips')
|
||||
subnet = kwargs.get('subnet')
|
||||
return self.plugin.get_subnet_for_dvr(context, subnet)
|
||||
return self.plugin.get_subnet_for_dvr(
|
||||
context, subnet, fixed_ips=fixed_ips)
|
||||
|
||||
|
||||
class DVRAgentRpcApiMixin(object):
|
||||
|
@ -162,15 +162,25 @@ class DVRDbMixin(ext_dvr.DVRMacAddressPluginBase):
|
||||
return ports_by_host
|
||||
|
||||
@log_helpers.log_method_call
|
||||
def get_subnet_for_dvr(self, context, subnet):
|
||||
def get_subnet_for_dvr(self, context, subnet, fixed_ips=None):
|
||||
if fixed_ips:
|
||||
subnet_data = fixed_ips[0]['subnet_id']
|
||||
else:
|
||||
subnet_data = subnet
|
||||
try:
|
||||
subnet_info = self.plugin.get_subnet(context, subnet)
|
||||
subnet_info = self.plugin.get_subnet(
|
||||
context, subnet_data)
|
||||
except n_exc.SubnetNotFound:
|
||||
return {}
|
||||
else:
|
||||
# retrieve the gateway port on this subnet
|
||||
filter = {'fixed_ips': {'subnet_id': [subnet],
|
||||
'ip_address': [subnet_info['gateway_ip']]}}
|
||||
if fixed_ips:
|
||||
filter = fixed_ips[0]
|
||||
else:
|
||||
filter = {'fixed_ips': {'subnet_id': [subnet],
|
||||
'ip_address':
|
||||
[subnet_info['gateway_ip']]}}
|
||||
|
||||
internal_gateway_ports = self.plugin.get_ports(
|
||||
context, filters=filter)
|
||||
if not internal_gateway_ports:
|
||||
|
@ -373,8 +373,8 @@ class OVSDVRNeutronAgent(object):
|
||||
return
|
||||
else:
|
||||
# set up LocalDVRSubnetMapping available for this subnet
|
||||
subnet_info = self.plugin_rpc.get_subnet_for_dvr(self.context,
|
||||
subnet_uuid)
|
||||
subnet_info = self.plugin_rpc.get_subnet_for_dvr(
|
||||
self.context, subnet_uuid, fixed_ips=fixed_ips)
|
||||
if not subnet_info:
|
||||
LOG.error(_LE("DVR: Unable to retrieve subnet information "
|
||||
"for subnet_id %s"), subnet_uuid)
|
||||
@ -525,8 +525,8 @@ class OVSDVRNeutronAgent(object):
|
||||
if subnet_uuid not in self.local_dvr_map:
|
||||
# no csnat ports seen on this subnet - create csnat state
|
||||
# for this subnet
|
||||
subnet_info = self.plugin_rpc.get_subnet_for_dvr(self.context,
|
||||
subnet_uuid)
|
||||
subnet_info = self.plugin_rpc.get_subnet_for_dvr(
|
||||
self.context, subnet_uuid, fixed_ips=fixed_ips)
|
||||
ldm = LocalDVRSubnetMapping(subnet_info, port.ofport)
|
||||
self.local_dvr_map[subnet_uuid] = ldm
|
||||
else:
|
||||
|
@ -47,7 +47,9 @@ class DVRServerRpcApiTestCase(base.BaseTestCase):
|
||||
host='foo_host', subnet='foo_subnet')
|
||||
|
||||
def test_get_subnet_for_dvr(self):
|
||||
self.rpc.get_subnet_for_dvr(self.ctxt, 'foo_subnet')
|
||||
self.rpc.get_subnet_for_dvr(
|
||||
self.ctxt, 'foo_subnet', fixed_ips='foo_fixed_ips')
|
||||
self.mock_cctxt.call.assert_called_with(
|
||||
self.ctxt, 'get_subnet_for_dvr',
|
||||
subnet='foo_subnet')
|
||||
subnet='foo_subnet',
|
||||
fixed_ips='foo_fixed_ips')
|
||||
|
Loading…
Reference in New Issue
Block a user