From d9eebfdbc6116f9e1442aa5d201d7e961225360a Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Tue, 23 Sep 2014 11:39:20 +1200 Subject: [PATCH] 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 --- .../heat_keystoneclient_v2/client.py | 7 +++++++ heat/engine/stack_user.py | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/contrib/heat_keystoneclient_v2/heat_keystoneclient_v2/client.py b/contrib/heat_keystoneclient_v2/heat_keystoneclient_v2/client.py index 81846c6c2..674958c98 100644 --- a/contrib/heat_keystoneclient_v2/heat_keystoneclient_v2/client.py +++ b/contrib/heat_keystoneclient_v2/heat_keystoneclient_v2/client.py @@ -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 # # ###################### # diff --git a/heat/engine/stack_user.py b/heat/engine/stack_user.py index 978888807..6994a7c05 100644 --- a/heat/engine/stack_user.py +++ b/heat/engine/stack_user.py @@ -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