diff options
| author | Ewan Mellor <ewan.mellor@citrix.com> | 2011-12-27 22:45:36 -0800 |
|---|---|---|
| committer | Ewan Mellor <ewan.mellor@citrix.com> | 2011-12-27 22:58:51 -0800 |
| commit | 3f2b53586ca804115d8cf91e43f63ec7a300e82c (patch) | |
| tree | 670a8adb58880eaf04bf64e6832e484917096cc0 | |
| parent | 08c0435aa1bad669c697de27efadda9765c50d1a (diff) | |
Bug #909255: Endpoint handling broken on SQL backend by portable-identifiers changes
When deciding whether to translate UIDs to integer IDs or vice versa, use
hasattr(api.TENANT, 'uid_to_id') or hasattr(api.TENANT, 'id_to_uid') in place
of isinstance(api.TENANT, models.Tenant). This matches the code elsewhere
(e.g. user.py) and has the effect that the IDs will be translated correctly.
Change-Id: Ia036bf310d48f8f8aa5739cb3e09d1f7364ad1a4
| -rwxr-xr-x | keystone/backends/sqlalchemy/api/endpoint_template.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/keystone/backends/sqlalchemy/api/endpoint_template.py b/keystone/backends/sqlalchemy/api/endpoint_template.py index 51594a71..a5966176 100755 --- a/keystone/backends/sqlalchemy/api/endpoint_template.py +++ b/keystone/backends/sqlalchemy/api/endpoint_template.py @@ -209,7 +209,7 @@ class EndpointTemplateAPI(api.BaseEndpointTemplateAPI): if not session: session = get_session() - if isinstance(api.TENANT, models.Tenant): + if hasattr(api.TENANT, 'uid_to_id'): tenant_id = api.TENANT.uid_to_id(tenant_id) if marker: @@ -223,7 +223,7 @@ class EndpointTemplateAPI(api.BaseEndpointTemplateAPI): filter(models.Endpoints.tenant_id == tenant_id).\ order_by(models.Endpoints.id).limit(limit).all() - if isinstance(api.TENANT, models.Tenant): + if hasattr(api.TENANT, 'id_to_uid'): for result in results: result.tenant_id = api.TENANT.id_to_uid(result.tenant_id) @@ -235,7 +235,7 @@ class EndpointTemplateAPI(api.BaseEndpointTemplateAPI): if not session: session = get_session() - if isinstance(api.TENANT, models.Tenant): + if hasattr(api.TENANT, 'uid_to_id'): tenant_id = api.TENANT.uid_to_id(tenant_id) tba = aliased(models.Endpoints) @@ -284,14 +284,14 @@ class EndpointTemplateAPI(api.BaseEndpointTemplateAPI): return (prev_page, next_page) def endpoint_add(self, values): - if isinstance(api.TENANT, models.Tenant): + if hasattr(api.TENANT, 'uid_to_id'): values.tenant_id = api.TENANT.uid_to_id(values.tenant_id) endpoints = models.Endpoints() endpoints.update(values) endpoints.save() - if isinstance(api.TENANT, models.Tenant): + if hasattr(api.TENANT, 'id_to_uid'): endpoints.tenant_id = api.TENANT.id_to_uid(endpoints.tenant_id) return endpoints @@ -303,7 +303,7 @@ class EndpointTemplateAPI(api.BaseEndpointTemplateAPI): result = session.query(models.Endpoints).\ filter_by(id=id).first() - if isinstance(api.TENANT, models.Tenant): + if hasattr(api.TENANT, 'id_to_uid'): if result: result.tenant_id = api.TENANT.id_to_uid(result.tenant_id) @@ -313,13 +313,13 @@ class EndpointTemplateAPI(api.BaseEndpointTemplateAPI): if not session: session = get_session() - if isinstance(api.TENANT, models.Tenant): + if hasattr(api.TENANT, 'uid_to_id'): tenant_id = api.TENANT.uid_to_id(tenant_id) result = session.query(models.Endpoints).\ filter_by(tenant_id=tenant_id).first() - if isinstance(api.TENANT, models.Tenant): + if hasattr(api.TENANT, 'id_to_uid'): if result: result.tenant_id = api.TENANT.id_to_uid(result.tenant_id) |
