Add DHCP agent MAC address to gbp_details
The MAC address and IP list of the ports belonging to the DHCP agent responsible for a given port are added to the get_gbp_details RPC. This allows the agent to support proxying ARPs for the DHCP agent's IP, using the appropriate MAC. Change-Id: I0dc62a765b37708d0f18d71f36a0903d808e6665
This commit is contained in:
parent
c6e97a945e
commit
6477b1d2ad
|
@ -773,17 +773,20 @@ class ApicMappingDriver(api.ResourceMappingDriver,
|
|||
details['subnets'] = self._get_subnets(context,
|
||||
filters={'id': [ip['subnet_id'] for ip in port['fixed_ips']]})
|
||||
for subnet in details['subnets']:
|
||||
dhcp_ips = set()
|
||||
for port in self._get_ports(
|
||||
dhcp_ports = {}
|
||||
subnet_dhcp_ips = set()
|
||||
for dhcp_port in self._get_ports(
|
||||
context, filters={
|
||||
'network_id': [subnet['network_id']],
|
||||
'device_owner': [n_constants.DEVICE_OWNER_DHCP]}):
|
||||
dhcp_ips |= set([x['ip_address'] for x in port['fixed_ips']
|
||||
if x['subnet_id'] == subnet['id']])
|
||||
dhcp_ips = list(dhcp_ips)
|
||||
dhcp_ips = set([x['ip_address'] for x in dhcp_port['fixed_ips']
|
||||
if x['subnet_id'] == subnet['id']])
|
||||
dhcp_ports.setdefault(dhcp_port['mac_address'], list(dhcp_ips))
|
||||
subnet_dhcp_ips |= dhcp_ips
|
||||
subnet_dhcp_ips = list(subnet_dhcp_ips)
|
||||
if not subnet['dns_nameservers']:
|
||||
# Use DHCP namespace port IP
|
||||
subnet['dns_nameservers'] = dhcp_ips
|
||||
subnet['dns_nameservers'] = subnet_dhcp_ips
|
||||
# Set Default & Metadata routes if needed
|
||||
default_route = metadata_route = {}
|
||||
if subnet['ip_version'] == 4:
|
||||
|
@ -807,12 +810,20 @@ class ApicMappingDriver(api.ResourceMappingDriver,
|
|||
subnet['host_routes'].append(
|
||||
{'destination': '0.0.0.0/0',
|
||||
'nexthop': subnet['gateway_ip']})
|
||||
if not metadata_route and dhcp_ips and (
|
||||
not self.enable_metadata_opt):
|
||||
subnet['host_routes'].append(
|
||||
{'destination': dhcp.METADATA_DEFAULT_CIDR,
|
||||
'nexthop': dhcp_ips[0]})
|
||||
subnet['dhcp_server_ips'] = dhcp_ips
|
||||
# REVISIT: We need to decide if we should provide
|
||||
# host-routes for all of the DHCP agents. For now
|
||||
# use the first DHCP agent in our list for the
|
||||
# metadata host-route next-hop IPs
|
||||
if not metadata_route and dhcp_ports and (
|
||||
not self.enable_metadata_opt or
|
||||
(self.enable_metadata_opt and not default_route)):
|
||||
for ip in dhcp_ports[dhcp_ports.keys()[0]]:
|
||||
subnet['host_routes'].append(
|
||||
{'destination': dhcp.METADATA_DEFAULT_CIDR,
|
||||
'nexthop': ip})
|
||||
subnet['dhcp_server_ips'] = subnet_dhcp_ips
|
||||
if dhcp_ports:
|
||||
subnet['dhcp_server_ports'] = dhcp_ports
|
||||
|
||||
def _add_vrf_details(self, context, details):
|
||||
l3p = self.gbp_plugin.get_l3_policy(context, details['l3_policy_id'])
|
||||
|
|
Loading…
Reference in New Issue