Merge "Fix metadata address usage"
This commit is contained in:
commit
d34eb8ffc3
@ -50,10 +50,8 @@ TCP = 'tcp'
|
||||
DNS_PORT = 53
|
||||
DHCPV4_PORT = 67
|
||||
DHCPV6_PORT = 547
|
||||
METADATA_DEFAULT_PREFIX = 16
|
||||
METADATA_DEFAULT_IP = '169.254.169.254'
|
||||
METADATA_DEFAULT_CIDR = '%s/%d' % (METADATA_DEFAULT_IP,
|
||||
METADATA_DEFAULT_PREFIX)
|
||||
METADATA_SUBNET_CIDR = '169.254.0.0/16'
|
||||
METADATA_PORT = 80
|
||||
WIN2k3_STATIC_DNS = 249
|
||||
NS_PREFIX = 'qdhcp-'
|
||||
@ -1141,11 +1139,11 @@ class Dnsmasq(DhcpLocalProcess):
|
||||
subnet_dhcp_ip = subnet_to_interface_ip.get(subnet.id)
|
||||
if subnet_dhcp_ip:
|
||||
host_routes.append(
|
||||
'%s/32,%s' % (METADATA_DEFAULT_IP, subnet_dhcp_ip)
|
||||
'%s,%s' % (constants.METADATA_CIDR, subnet_dhcp_ip)
|
||||
)
|
||||
elif not isolated_subnets[subnet.id] and gateway:
|
||||
host_routes.append(
|
||||
'%s/32,%s' % (METADATA_DEFAULT_IP, gateway)
|
||||
'%s,%s' % (constants.METADATA_CIDR, gateway)
|
||||
)
|
||||
|
||||
if subnet.ip_version == 4:
|
||||
@ -1305,7 +1303,7 @@ class Dnsmasq(DhcpLocalProcess):
|
||||
@staticmethod
|
||||
def has_metadata_subnet(subnets):
|
||||
"""Check if the subnets has a metadata subnet."""
|
||||
meta_cidr = netaddr.IPNetwork(METADATA_DEFAULT_CIDR)
|
||||
meta_cidr = netaddr.IPNetwork(METADATA_SUBNET_CIDR)
|
||||
if any(netaddr.IPNetwork(s.cidr) in meta_cidr
|
||||
for s in subnets):
|
||||
return True
|
||||
@ -1710,7 +1708,7 @@ class DeviceManager(object):
|
||||
ip_cidrs.append('%s/%s' % (gateway, net.prefixlen))
|
||||
|
||||
if self.conf.force_metadata or self.conf.enable_isolated_metadata:
|
||||
ip_cidrs.append(METADATA_DEFAULT_CIDR)
|
||||
ip_cidrs.append(constants.METADATA_CIDR)
|
||||
|
||||
self.driver.init_l3(interface_name, ip_cidrs,
|
||||
namespace=network.namespace)
|
||||
|
@ -373,7 +373,7 @@ class MetadataAgent(object):
|
||||
mac = match.group()
|
||||
ip_addresses = set(
|
||||
port.external_ids[ovn_const.OVN_CIDRS_EXT_ID_KEY].split(' '))
|
||||
ip_addresses.add(ovn_const.METADATA_DEFAULT_CIDR)
|
||||
ip_addresses.add(n_const.METADATA_CIDR)
|
||||
metadata_port = MetadataPortInfo(mac, ip_addresses)
|
||||
|
||||
# Create the VETH pair if it's not created. Also the add_veth function
|
||||
|
@ -280,10 +280,7 @@ HA_CHASSIS_GROUP_HIGHEST_PRIORITY = 32767
|
||||
|
||||
# TODO(lucasagomes): Move this to neutron-lib later.
|
||||
# Metadata constants
|
||||
METADATA_DEFAULT_PREFIX = 16
|
||||
METADATA_DEFAULT_IP = '169.254.169.254'
|
||||
METADATA_DEFAULT_CIDR = '%s/%d' % (METADATA_DEFAULT_IP,
|
||||
METADATA_DEFAULT_PREFIX)
|
||||
METADATA_PORT = 80
|
||||
|
||||
# OVN igmp options
|
||||
|
@ -1820,9 +1820,9 @@ class TestDeviceManager(base.BaseTestCase):
|
||||
|
||||
if port == fake_ipv6_port:
|
||||
expected_ips = ['2001:db8::a8bb:ccff:fedd:ee99/64',
|
||||
'169.254.169.254/16']
|
||||
const.METADATA_CIDR]
|
||||
else:
|
||||
expected_ips = ['172.9.9.9/24', '169.254.169.254/16']
|
||||
expected_ips = ['172.9.9.9/24', const.METADATA_CIDR]
|
||||
|
||||
expected = [mock.call.get_device_name(port)]
|
||||
|
||||
|
@ -2975,7 +2975,7 @@ class TestDnsmasq(TestBase):
|
||||
for alloc in FakeDhcpPort().fixed_ips]
|
||||
options, idx_map = dm._generate_opts_per_subnet()
|
||||
|
||||
contains_metadata_ip = any(['%s/32' % dhcp.METADATA_DEFAULT_IP in line
|
||||
contains_metadata_ip = any(['%s' % constants.METADATA_CIDR in line
|
||||
for line in options])
|
||||
self.assertEqual(expected_mdt_ip, contains_metadata_ip)
|
||||
|
||||
@ -3141,7 +3141,7 @@ class TestDeviceManager(TestConfBase):
|
||||
|
||||
expect_ips = ['192.168.0.6/24', 'fdca:3ba5:a17a:4ba3::2/64']
|
||||
if enable_isolated_metadata or force_metadata:
|
||||
expect_ips.append(dhcp.METADATA_DEFAULT_CIDR)
|
||||
expect_ips.append(constants.METADATA_CIDR)
|
||||
mgr.driver.init_l3.assert_called_with('ns-XXX',
|
||||
expect_ips,
|
||||
namespace='qdhcp-ns')
|
||||
|
@ -15,6 +15,7 @@
|
||||
import collections
|
||||
from unittest import mock
|
||||
|
||||
from neutron_lib import constants as n_const
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as config_fixture
|
||||
|
||||
@ -25,6 +26,7 @@ from neutron.agent.linux.ip_lib import IpNetnsCommand as ip_netns
|
||||
from neutron.agent.linux.ip_lib import IPWrapper as ip_wrap
|
||||
from neutron.agent.ovn.metadata import agent
|
||||
from neutron.agent.ovn.metadata import driver
|
||||
from neutron.common.ovn import constants as ovn_const
|
||||
from neutron.conf.agent.metadata import config as meta_conf
|
||||
from neutron.conf.agent.ovn.metadata import config as ovn_meta_conf
|
||||
from neutron.tests import base
|
||||
@ -258,13 +260,13 @@ class TestMetadataAgent(base.BaseTestCase):
|
||||
# Check that the metadata port has the IP addresses properly
|
||||
# configured and that IPv6 address has been skipped.
|
||||
expected_calls = [mock.call('10.0.0.1/23'),
|
||||
mock.call('169.254.169.254/16')]
|
||||
mock.call(n_const.METADATA_CIDR)]
|
||||
self.assertEqual(sorted(expected_calls),
|
||||
sorted(ip_addr_add.call_args_list))
|
||||
# Check that metadata proxy has been spawned
|
||||
spawn_mdp.assert_called_once_with(
|
||||
mock.ANY, 'namespace', 80, mock.ANY,
|
||||
bind_address='169.254.169.254', network_id='1')
|
||||
bind_address=ovn_const.METADATA_DEFAULT_IP, network_id='1')
|
||||
# Check that the chassis has been updated with the datapath.
|
||||
update_chassis.assert_called_once_with('1')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user