diff options
author | asteroide <thomas.duval@orange.com> | 2015-11-27 10:36:00 +0100 |
---|---|---|
committer | asteroide <thomas.duval@orange.com> | 2015-11-27 10:36:00 +0100 |
commit | 094dec72ac6e3f5d3f08c0e3536b16b7b086bfee (patch) | |
tree | f4e78e0d82ba91575b3b50595e661de9de168605 | |
parent | eb4749e392e688aaa16851568c981749891462a8 (diff) |
When deleting an intra-extension, deletion may be impossible due to foreign key constraints.
Change-Id: I6a8421e80f68abdf80516f76b87f611249a1e80a
-rw-r--r-- | keystone-moon/keystone/contrib/moon/backends/sql.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/keystone-moon/keystone/contrib/moon/backends/sql.py b/keystone-moon/keystone/contrib/moon/backends/sql.py index 06071507..a2c8f5bc 100644 --- a/keystone-moon/keystone/contrib/moon/backends/sql.py +++ b/keystone-moon/keystone/contrib/moon/backends/sql.py @@ -292,12 +292,6 @@ class Rule(sql.ModelBase, sql.DictBase): __all_objects__ = ( - Subject, - Object, - Action, - SubjectCategory, - ObjectCategory, - ActionCategory, SubjectScope, ObjectScope, ActionScope, @@ -305,6 +299,12 @@ __all_objects__ = ( ObjectAssignment, ActionAssignment, SubMetaRule, + SubjectCategory, + ObjectCategory, + ActionCategory, + Subject, + Object, + Action, Rule, ) @@ -375,8 +375,8 @@ class IntraExtensionConnector(IntraExtensionDriver): for _object in __all_objects__: query = session.query(_object) query = query.filter_by(intra_extension_id=intra_extension_id) - _ref = query.first() - if _ref: + _refs = query.all() + for _ref in _refs: session.delete(_ref) session.flush() session.delete(ref) @@ -948,6 +948,8 @@ class IntraExtensionConnector(IntraExtensionDriver): intra_extension_dict = dict(ref.intra_extension) intra_extension_dict["aggregation_algorithm"] = aggregation_algorithm_id setattr(ref, "intra_extension", intra_extension_dict) + session.flush() + LOG.debug("set_aggregation_algorithm_id {}-{} {}".format(intra_extension_id, aggregation_algorithm_id, self.get_aggregation_algorithm_id(intra_extension_id))) return self.get_aggregation_algorithm_id(intra_extension_id) def del_aggregation_algorithm(self, intra_extension_id): |