When create keypair with the same name at the same time, create two keypair.
nova keypair-list
+----------+------------------------------------------------------+
| Name | Fingerprint |
+----------+------------------------------------------------------+
| keypair1 | d3:b0:8e:46:a8:90:90:67:c9:c8:b3:b3:b0:dd:fa:f6 |
| keypair1 | f2:5d:80:08:14:35:1e:98:d7:f9:75:67:64:3e:0e:ae |
+----------+------------------------------------------------------+
When keypair delete with the specified name, delete other one.
nova keypair-delete keypair1
nova keypair-list
+----------+------------------------------------------------------+
| Name | Fingerprint |
+----------+------------------------------------------------------+
| keypair1 | d3:b0:8e:46:a8:90:90:67:c9:c8:b3:b3:b0:dd:fa:f6 |
+----------+------------------------------------------------------+
If set name unique key, can not be create keypair with the keypair name that has been deleted.
When run create keypair at the same time, keypair with the same name should not create.
To fix this issue, I have added uniqueness constraint on name and user_id columns of key_pairs table (and removed the extra DB look-up prior to the creation of key pair). However, I am facing a strange issue in SQLAlchemy, due to which, I get a TypeError instead of IntegrityError (sample stack trace http:// paste.openstack .org/show/ 28497/ ) on creating a same named keypair for a user.
This can be overcome by replacing the 'raise' statement by 'raise exc' in _flush( ) method of /usr/local/ lib/python2. 7/dist- packages/ sqlalchemy/ orm/session. py.
IMO, this requires a fix in SQLAlchemy session. Can someone please confirm this.
NOTE: Code branch 'master', SQLAlchemy version 0.7.9