This simple patch ensures usage for security group rules is
marked as dirty when a security group rule is deleted.
To this aim, the security group rule is deleted using ORM
in order to ensure the sqlalchemy even if fired.
Closes-Bug: #
1499339
Change-Id: I1e81fe03fed14ec438cea5d7675f66caeb91afd8
(cherry picked from commit
851b1b4bbbaa965f190bfacab03fd6ece80ad0ec)
raise ext_sg.SecurityGroupRuleInUse(id=id, reason=reason)
with context.session.begin(subtransactions=True):
- query = self._model_query(context, SecurityGroupRule)
- if query.filter(SecurityGroupRule.id == id).delete() == 0:
+ query = self._model_query(context, SecurityGroupRule).filter(
+ SecurityGroupRule.id == id)
+ try:
+ # As there is a filter on a primary key it is not possible for
+ # MultipleResultsFound to be raised
+ context.session.delete(query.one())
+ except exc.NoResultFound:
raise ext_sg.SecurityGroupRuleNotFound(id=id)
registry.notify(