Include newly-labelled HA router interfaces in network config
Neutron very recently changed the device_owner field of router interfaces on HA routers. We need to account for this when creating appliance network config, otherwise we omit HA interfaces from its network config. Change-Id: Ib41d4255f1ad3180c75f6e89ec6162dfdd0d2796 Closes-bug: #1567623
This commit is contained in:
parent
12785c941d
commit
33edf3a581
|
@ -60,6 +60,7 @@ CONF.register_opts(neutron_opts)
|
|||
# copied from Neutron source
|
||||
DEVICE_OWNER_ROUTER_MGT = "network:router_management"
|
||||
DEVICE_OWNER_ROUTER_INT = "network:router_interface"
|
||||
DEVICE_OWNER_ROUTER_HA_INT = "network:ha_router_replicated_interface"
|
||||
DEVICE_OWNER_ROUTER_GW = "network:router_gateway"
|
||||
DEVICE_OWNER_FLOATINGIP = "network:floatingip"
|
||||
DEVICE_OWNER_RUG = "network:astara"
|
||||
|
@ -202,7 +203,8 @@ class Router(object):
|
|||
|
||||
for port_dict in d.get('_interfaces', []):
|
||||
port = Port.from_dict(port_dict)
|
||||
if port.device_owner == DEVICE_OWNER_ROUTER_INT:
|
||||
int_owners = [DEVICE_OWNER_ROUTER_INT, DEVICE_OWNER_ROUTER_HA_INT]
|
||||
if port.device_owner in int_owners:
|
||||
internal_ports.append(port)
|
||||
|
||||
fips = [FloatingIP.from_dict(fip) for fip in d.get('_floatingips', [])]
|
||||
|
|
|
@ -40,6 +40,7 @@ class TestuNeutronModels(base.RugTestBase):
|
|||
|
||||
def test_router_from_dict(self):
|
||||
p = {
|
||||
'name': 'ext',
|
||||
'id': 'ext',
|
||||
'device_id': 'device_id',
|
||||
'fixed_ips': [],
|
||||
|
@ -48,6 +49,26 @@ class TestuNeutronModels(base.RugTestBase):
|
|||
'device_owner': 'network:router_gateway'
|
||||
}
|
||||
|
||||
int_p = {
|
||||
'name': 'int',
|
||||
'id': 'int',
|
||||
'device_id': 'device_id',
|
||||
'fixed_ips': [],
|
||||
'mac_address': 'aa:bb:cc:dd:ee:ee',
|
||||
'network_id': 'net_id',
|
||||
'device_owner': 'network:router_interface'
|
||||
}
|
||||
|
||||
int_ha_p = {
|
||||
'name': 'ha_int',
|
||||
'id': 'ha_int',
|
||||
'device_id': 'device_id',
|
||||
'fixed_ips': [],
|
||||
'mac_address': 'aa:bb:cc:dd:ee:ee',
|
||||
'network_id': 'net_id',
|
||||
'device_owner': 'network:ha_router_replicated_interface'
|
||||
}
|
||||
|
||||
fip = {
|
||||
'id': 'fip',
|
||||
'floating_ip_address': '9.9.9.9',
|
||||
|
@ -61,7 +82,8 @@ class TestuNeutronModels(base.RugTestBase):
|
|||
'admin_state_up': True,
|
||||
'status': 'ACTIVE',
|
||||
'ports': [p],
|
||||
'_floatingips': [fip]
|
||||
'_floatingips': [fip],
|
||||
'_interfaces': [int_p, int_ha_p],
|
||||
}
|
||||
|
||||
r = neutron.Router.from_dict(d)
|
||||
|
@ -71,6 +93,9 @@ class TestuNeutronModels(base.RugTestBase):
|
|||
self.assertEqual(r.name, 'name')
|
||||
self.assertTrue(r.admin_state_up)
|
||||
self.assertTrue(r.floating_ips) # just make sure this exists
|
||||
self.assertEqual(
|
||||
sorted([ip.id for ip in r.internal_ports]),
|
||||
['ha_int', 'int'])
|
||||
|
||||
def test_router_eq(self):
|
||||
r1 = neutron.Router(
|
||||
|
|
Loading…
Reference in New Issue