From 0ae598b1a7a92755fd0fcc2685816414fb6f47b0 Mon Sep 17 00:00:00 2001 From: Rohan Rhishikesh Kanade Date: Wed, 27 Feb 2013 11:19:21 -0800 Subject: Return 409 on creating/importing same name keypair * Removed the DB look up on creating and importing a keypair. * Added unique constraint on user_id and name columns of key_pairs table. Fixes LP: #1086333. Change-Id: I2fd4697f9269d2be13bd977e65ba4ca4a27b9ac6 --- nova/compute/api.py | 8 -------- 1 file changed, 8 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/api.py b/nova/compute/api.py index 15cd52e82..4061867ad 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -2710,13 +2710,6 @@ class KeypairAPI(base.Base): msg = _('Keypair name must be between 1 and 255 characters long') raise exception.InvalidKeypair(explanation=msg) - # NOTE: check for existing keypairs of same name - try: - self.db.key_pair_get(context, user_id, key_name) - raise exception.KeyPairExists(key_name=key_name) - except exception.NotFound: - pass - def import_key_pair(self, context, user_id, key_name, public_key): """Import a key pair using an existing public key.""" self._validate_keypair_name(context, user_id, key_name) @@ -2759,7 +2752,6 @@ class KeypairAPI(base.Base): 'public_key': public_key, 'private_key': private_key} self.db.key_pair_create(context, keypair) - return keypair def delete_key_pair(self, context, user_id, key_name): -- cgit