Skip to content

Commit

Permalink
Add keystoneclient CredentialsManager if missing
Browse files Browse the repository at this point in the history
The keystone v3 client doesn't include the 'ec2' manager, even
though the EC2 API is included in the default pipeline.

This commit creates the ec2 manager manually if it's missing
(and necessary). It uses the same call that the client itself
should have used.

Change-Id: I83e7bfa04cde5093c10bf2bc27af5ec03da4b48e
Closes-bug: #1236326
(cherry picked from commit 7187d12)
  • Loading branch information
spearki committed Oct 11, 2013
1 parent d55d502 commit 904eebe
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions openstack_dashboard/api/keystone.py
Expand Up @@ -576,16 +576,26 @@ def get_default_role(request):
return DEFAULT_ROLE


def ec2_manager(request):
client = keystoneclient(request)
if hasattr(client, 'ec2'):
return client.ec2

# Keystoneclient 4.0 was released without the ec2 creds manager.
from keystoneclient.v2_0 import ec2
return ec2.CredentialsManager(client)


def list_ec2_credentials(request, user_id):
return keystoneclient(request).ec2.list(user_id)
return ec2_manager(request).list(user_id)


def create_ec2_credentials(request, user_id, tenant_id):
return keystoneclient(request).ec2.create(user_id, tenant_id)
return ec2_manager(request).create(user_id, tenant_id)


def get_user_ec2_credentials(request, user_id, access_token):
return keystoneclient(request).ec2.get(user_id, access_token)
return ec2_manager(request).get(user_id, access_token)


def keystone_can_edit_domain():
Expand Down

0 comments on commit 904eebe

Please sign in to comment.