Add keystone v2 keypair methods

To get KeystoneClientV2 to work with StackUser resources, the
missing methods create_stack_domain_user_keypair and
delete_stack_domain_user_keypair have been added.

StackUser._create_keypair has also been modified to tolerate
having a missing id attribute, which is what the v2 API returns.

Change-Id: I9c19c1ca49f72ff1e760e849712c8c9d5fa7541f
Closes-Bug: #1372687
This commit is contained in:
Steve Baker 2014-09-23 11:39:20 +12:00
parent 299f8a6639
commit d9eebfdbc6
2 changed files with 14 additions and 1 deletions

View File

@ -223,6 +223,13 @@ class KeystoneClientV2(object):
'''Pass through method since no project was created.'''
pass
def create_stack_domain_user_keypair(self, user_id, project_id):
return self.create_ec2_keypair(user_id)
def delete_stack_domain_user_keypair(self, user_id, project_id,
credential_id):
return self.delete_ec2_keypair(user_id, credential_id)
# ###################### #
# V3 Unsupported Methods #
# ###################### #

View File

@ -132,7 +132,13 @@ class StackUser(resource.Resource):
raise exception.Error(_("Error creating ec2 keypair for user %s") %
user_id)
else:
self.data_set('credential_id', kp.id, redact=True)
try:
credential_id = kp.id
except AttributeError:
# keystone v2 keypairs do not have an id attribute. Use the
# access key instead.
credential_id = kp.access
self.data_set('credential_id', credential_id, redact=True)
self.data_set('access_key', kp.access, redact=True)
self.data_set('secret_key', kp.secret, redact=True)
return kp