Skip to content

Commit

Permalink
Fix AttributeError in Keypair._add_details()
Browse files Browse the repository at this point in the history
_add_details() method copies keypair attributes retrieved
from Nova to an instance of Keypair class. Trying to set
attribute 'id' fails with AttributeError, because Keypair
class has a read-only property 'id'.

We can safely omit setting of attribute 'id', because it's
just an implementation detail (the id of a table row in a
database), and keypairs for a given tenant are uniquely
identified using attribute 'name'.

Fixes bug 1223934

Change-Id: I1045730e47e9e6ad31fcdfbaefdad77e2f3b2c3e
  • Loading branch information
Roman Podolyaka committed Sep 24, 2013
1 parent 7a041f9 commit 9e8dd06
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion novaclient/v1_1/keypairs.py
Expand Up @@ -32,7 +32,15 @@ def _add_details(self, info):
dico = 'keypair' in info and \
info['keypair'] or info
for (k, v) in dico.items():
setattr(self, k, v)
# NOTE(rpodolyaka): keypair name allows us to uniquely identify
# a specific keypair, while its id attribute
# is nothing more than an implementation
# detail. We can safely omit the id attribute
# here to ensure setattr() won't raise
# AttributeError trying to set read-only
# property id
if k != 'id':
setattr(self, k, v)

@property
def id(self):
Expand Down

0 comments on commit 9e8dd06

Please sign in to comment.