diff options
author | DUVAL Thomas <thomas.duval@orange.com> | 2016-06-09 09:11:50 +0200 |
---|---|---|
committer | DUVAL Thomas <thomas.duval@orange.com> | 2016-06-09 09:11:50 +0200 |
commit | 2e7b4f2027a1147ca28301e4f88adf8274b39a1f (patch) | |
tree | 8b8d94001ebe6cc34106cf813b538911a8d66d9a /keystone-moon/keystone/endpoint_policy/backends | |
parent | a33bdcb627102a01244630a54cb4b5066b385a6a (diff) |
Update Keystone core to Mitaka.
Change-Id: Ia10d6add16f4a9d25d1f42d420661c46332e69db
Diffstat (limited to 'keystone-moon/keystone/endpoint_policy/backends')
-rw-r--r-- | keystone-moon/keystone/endpoint_policy/backends/sql.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/keystone-moon/keystone/endpoint_policy/backends/sql.py b/keystone-moon/keystone/endpoint_policy/backends/sql.py index 484444f1..aacbb083 100644 --- a/keystone-moon/keystone/endpoint_policy/backends/sql.py +++ b/keystone-moon/keystone/endpoint_policy/backends/sql.py @@ -32,7 +32,7 @@ class PolicyAssociation(sql.ModelBase, sql.ModelDictMixin): service_id = sql.Column(sql.String(64), nullable=True) region_id = sql.Column(sql.String(64), nullable=True) __table_args__ = (sql.UniqueConstraint('endpoint_id', 'service_id', - 'region_id'), {}) + 'region_id'),) def to_dict(self): """Returns the model's attributes as a dictionary. @@ -51,7 +51,7 @@ class EndpointPolicy(object): def create_policy_association(self, policy_id, endpoint_id=None, service_id=None, region_id=None): - with sql.transaction() as session: + with sql.session_for_write() as session: try: # See if there is already a row for this association, and if # so, update it with the new policy_id @@ -79,14 +79,14 @@ class EndpointPolicy(object): # NOTE(henry-nash): Getting a single value to save object # management overhead. - with sql.transaction() as session: + with sql.session_for_read() as session: if session.query(PolicyAssociation.id).filter( sql_constraints).distinct().count() == 0: raise exception.PolicyAssociationNotFound() def delete_policy_association(self, policy_id, endpoint_id=None, service_id=None, region_id=None): - with sql.transaction() as session: + with sql.session_for_write() as session: query = session.query(PolicyAssociation) query = query.filter_by(policy_id=policy_id) query = query.filter_by(endpoint_id=endpoint_id) @@ -102,7 +102,7 @@ class EndpointPolicy(object): PolicyAssociation.region_id == region_id) try: - with sql.transaction() as session: + with sql.session_for_read() as session: policy_id = session.query(PolicyAssociation.policy_id).filter( sql_constraints).distinct().one() return {'policy_id': policy_id} @@ -110,31 +110,31 @@ class EndpointPolicy(object): raise exception.PolicyAssociationNotFound() def list_associations_for_policy(self, policy_id): - with sql.transaction() as session: + with sql.session_for_read() as session: query = session.query(PolicyAssociation) query = query.filter_by(policy_id=policy_id) return [ref.to_dict() for ref in query.all()] def delete_association_by_endpoint(self, endpoint_id): - with sql.transaction() as session: + with sql.session_for_write() as session: query = session.query(PolicyAssociation) query = query.filter_by(endpoint_id=endpoint_id) query.delete() def delete_association_by_service(self, service_id): - with sql.transaction() as session: + with sql.session_for_write() as session: query = session.query(PolicyAssociation) query = query.filter_by(service_id=service_id) query.delete() def delete_association_by_region(self, region_id): - with sql.transaction() as session: + with sql.session_for_write() as session: query = session.query(PolicyAssociation) query = query.filter_by(region_id=region_id) query.delete() def delete_association_by_policy(self, policy_id): - with sql.transaction() as session: + with sql.session_for_write() as session: query = session.query(PolicyAssociation) query = query.filter_by(policy_id=policy_id) query.delete() |