router_device_owners = (
l3_db.L3_NAT_db_mixin.router_device_owners +
- (DEVICE_OWNER_DVR_INTERFACE,))
+ (DEVICE_OWNER_DVR_INTERFACE,
+ DEVICE_OWNER_DVR_SNAT,
+ DEVICE_OWNER_AGENT_GW))
extra_attributes = (
l3_attrs_db.ExtraAttributesMixin.extra_attributes + [{
'device_id': ['agent_id'],
'device_owner': [l3_const.DEVICE_OWNER_AGENT_GW]})
+ def _test_prepare_direct_delete_dvr_internal_ports(self, port):
+ with mock.patch.object(manager.NeutronManager, 'get_plugin') as gp:
+ plugin = mock.Mock()
+ gp.return_value = plugin
+ plugin.get_ports.return_value = [port]
+ plugin.assertRaises(l3.L3PortInUse,
+ plugin.delete_port,
+ self.ctx,
+ 'my_port_id')
+
+ def test_prevent_delete_floatingip_agent_gateway_port(self):
+ port = {
+ 'id': 'my_port_id',
+ 'device_owner': l3_const.DEVICE_OWNER_AGENT_GW
+ }
+ self._test_prepare_direct_delete_dvr_internal_ports(port)
+
+ def test_prevent_delete_csnat_port(self):
+ port = {
+ 'id': 'my_port_id',
+ 'device_owner': l3_const.DEVICE_OWNER_ROUTER_SNAT
+ }
+ self._test_prepare_direct_delete_dvr_internal_ports(port)
+
def test__create_gw_port_with_no_gateway(self):
router = {
'name': 'foo_router',