Fix MeteringLabel model to not clear router's tenant id on deletion
foreign_keys parameter of orm.relationship should point to local columns. Currently for MeteringLabel it points to Router.tenant_id column which causes routers tenant_id clearing on label deletion. Closes-Bug: #1249188 Change-Id: Iccc0daf4f6edd537fd7f9e4b2fc4be094543ca5d
This commit is contained in:
parent
53f6416ddc
commit
ac40c6c177
@ -52,7 +52,8 @@ class MeteringLabel(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
|
||||
routers = orm.relationship(
|
||||
l3_db.Router,
|
||||
primaryjoin="MeteringLabel.tenant_id==Router.tenant_id",
|
||||
foreign_keys='Router.tenant_id')
|
||||
foreign_keys='MeteringLabel.tenant_id',
|
||||
uselist=True)
|
||||
|
||||
|
||||
class MeteringDbMixin(metering.MeteringPluginBase,
|
||||
|
@ -248,6 +248,18 @@ class TestMeteringPlugin(test_db_plugin.NeutronDbPluginV2TestCase,
|
||||
expected_del,
|
||||
topic=self.topic)
|
||||
|
||||
def test_delete_metering_label_does_not_clear_router_tenant_id(self):
|
||||
tenant_id = '654f6b9d-0f36-4ae5-bd1b-01616794ca60'
|
||||
with self.metering_label(tenant_id=tenant_id,
|
||||
no_delete=True) as metering_label:
|
||||
with self.router(tenant_id=tenant_id, set_context=True) as r:
|
||||
router = self._show('routers', r['router']['id'])
|
||||
self.assertEqual(tenant_id, router['router']['tenant_id'])
|
||||
metering_label_id = metering_label['metering_label']['id']
|
||||
self._delete('metering-labels', metering_label_id, 204)
|
||||
router = self._show('routers', r['router']['id'])
|
||||
self.assertEqual(tenant_id, router['router']['tenant_id'])
|
||||
|
||||
|
||||
class TestRouteIntPlugin(l3_agentschedulers_db.L3AgentSchedulerDbMixin,
|
||||
test_l3_plugin.TestL3NatIntPlugin):
|
||||
|
Loading…
Reference in New Issue
Block a user