From f50d0e8a2c8c32a92f29029389dae347c358b8be Mon Sep 17 00:00:00 2001 From: Ziad Sawalha Date: Fri, 3 Jun 2011 01:10:48 -0500 Subject: Support for listing BaseURL refs in keystone-manage --- bin/keystone-manage | 28 ++++++++++++++++++++++++++++ keystone/db/sqlalchemy/api.py | 6 ++++++ 2 files changed, 34 insertions(+) diff --git a/bin/keystone-manage b/bin/keystone-manage index 6ad73e96..496d5337 100755 --- a/bin/keystone-manage +++ b/bin/keystone-manage @@ -281,6 +281,34 @@ def Main(): except Exception as exc: print "ERROR: Failed to create BaseURLs: %s" % exc return + elif command == "list": + if len(args) == 3: + tenant = args[2] + try: + objects = db_api.baseurls_ref_get_by_tenant(tenant) + if objects == None: + raise IndexError("URLs not found") + print 'service', 'region', 'Public URL' + print '-' * 20 + for row in objects: + print row.service, row.region, row.public_url + except Exception, e: + print 'Error getting all URL refs for %s:' % \ + tenant, str(e) + return + else: + tenant = None + try: + objects = db_api.baseurls_get_all() + if objects == None: + raise IndexError("URLs not found") + print 'service', 'region', 'Public URL' + print '-' * 20 + for row in objects: + print row.service, row.region, row.public_url + except Exception, e: + print 'Error getting all BaseURLs:', str(e) + return elif object_type == "token": if command == "add": if len(args) < 6: diff --git a/keystone/db/sqlalchemy/api.py b/keystone/db/sqlalchemy/api.py index 6c3c0799..b8728077 100644 --- a/keystone/db/sqlalchemy/api.py +++ b/keystone/db/sqlalchemy/api.py @@ -1161,6 +1161,12 @@ def baseurls_ref_get(id, session=None): result = session.query(models.TenantBaseURLAssociation).filter_by(id=id).first() return result +def baseurls_ref_get_by_tenant(tenant_id, session=None): + if not session: + session = get_session() + result = session.query(models.TenantBaseURLAssociation).filter_by(tenant_id=tenant_id).first() + return result + def baseurls_ref_delete(id, session=None): if not session: session = get_session() -- cgit