Skip to content

Commit fc584d0

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Prevent router_ha_interface port from being removed via API" into stable/yoga
2 parents 2642588 + 1f9f77e commit fc584d0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

neutron/db/l3_hamode_db.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
6969
router_az_db.RouterAvailabilityZoneMixin):
7070
"""Mixin class to add high availability capability to routers."""
7171

72+
router_device_owners = (
73+
l3_dvr_db.L3_NAT_with_dvr_db_mixin.router_device_owners +
74+
(constants.DEVICE_OWNER_ROUTER_HA_INTF, ))
75+
7276
def _verify_configuration(self):
7377
self.ha_cidr = cfg.CONF.l3_ha_net_cidr
7478
try:

neutron/tests/unit/db/test_l3_hamode_db.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,18 @@ def test_update_router_ha_interface_port_ip_not_allow(self):
667667
self.admin_ctx, ports[0]['id'],
668668
port)
669669

670+
def test_delete_router_ha_interface_port(self):
671+
router = self._create_router()
672+
network = self.plugin.get_ha_network(self.admin_ctx,
673+
router['tenant_id'])
674+
binding = self.plugin.add_ha_port(
675+
self.admin_ctx, router['id'], network.network_id,
676+
router['tenant_id'])
677+
678+
self.assertRaises(n_exc.ServicePortInUse,
679+
self.core_plugin.delete_port,
680+
self.admin_ctx, binding.port_id)
681+
670682
def test_create_ha_network_tenant_binding_raises_duplicate(self):
671683
router = self._create_router()
672684
network = self.plugin.get_ha_network(self.admin_ctx,

0 commit comments

Comments
 (0)