Skip to content

Commit

Permalink
Add keystone v2 keypair methods
Browse files Browse the repository at this point in the history
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
  • Loading branch information
steveb committed Sep 26, 2014
1 parent 299f8a6 commit d9eebfd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Expand Up @@ -223,6 +223,13 @@ def delete_stack_domain_project(self, project_id):
'''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 #
# ###################### #
Expand Down
8 changes: 7 additions & 1 deletion heat/engine/stack_user.py
Expand Up @@ -132,7 +132,13 @@ def _create_keypair(self):
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
Expand Down

0 comments on commit d9eebfd

Please sign in to comment.