diff options
| author | Chuck Short <chuck.short@canonical.com> | 2013-01-03 09:04:58 -0600 |
|---|---|---|
| committer | Chuck Short <chuck.short@canonical.com> | 2013-01-18 14:08:57 -0600 |
| commit | 5cce71baaa13fc651d76b6b26a29effbf879f1b1 (patch) | |
| tree | 37bf0ca16344390b1bb3af24558751919595de19 /nova/tests | |
| parent | 7d20f1fe553b0db5883e787992413e7a0ca4f099 (diff) | |
Refactor EC2 keypairs exception
According to the following document:
http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/api-error-codes.html
The EC2 API sends specific error codes when keypair listing or
keypair generation fails, specifically the error codes are
InvalidKeyPair.Duplicate - duplicate keypair
InvalidKeyPair.Format - keypair format invalid
InvalidKeyPair.NotFound - keypair not found
ResourceLimitExceeded - keypair quota exceeded
Refactored create_key_pair and describe_key_pair so that
it throws the correct EC2 error codes according to the
public EC2 API specs.
Also removed some duplicate exceptions as well.
Fixes LP: 1072318
DocImpact
Change-Id: Ib7045e49211d9300e9cb6ca0bfe80e569d635c9b
Signed-off-by: Chuck Short <chuck.short@canonical.com>
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/api/ec2/test_cloud.py | 4 | ||||
| -rw-r--r-- | nova/tests/test_api.py | 5 |
2 files changed, 4 insertions, 5 deletions
diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py index 562473121..a00dceff1 100644 --- a/nova/tests/api/ec2/test_cloud.py +++ b/nova/tests/api/ec2/test_cloud.py @@ -1440,7 +1440,7 @@ class CloudTestCase(test.TestCase): self.assertTrue(filter(lambda k: k['keyName'] == 'test2', keys)) def test_describe_bad_key_pairs(self): - self.assertRaises(exception.EC2APIError, + self.assertRaises(exception.KeypairNotFound, self.cloud.describe_key_pairs, self.context, key_name=['DoesNotExist']) @@ -1490,7 +1490,7 @@ class CloudTestCase(test.TestCase): self.assertEqual(result['keyName'], key_name) for key_name in bad_names: - self.assertRaises(exception.EC2APIError, + self.assertRaises(exception.InvalidKeypair, self.cloud.create_key_pair, self.context, key_name) diff --git a/nova/tests/test_api.py b/nova/tests/test_api.py index 829a98334..fb2e76e45 100644 --- a/nova/tests/test_api.py +++ b/nova/tests/test_api.py @@ -309,11 +309,10 @@ class ApiEc2TestCase(test.TestCase): try: self.ec2.create_key_pair('test') except boto_exc.EC2ResponseError, e: - if e.code == 'KeyPairExists': + if e.code == 'InvalidKeyPair.Duplicate': pass else: - self.fail("Unexpected EC2ResponseError: %s " - "(expected KeyPairExists)" % e.code) + self.assertEqual('InvalidKeyPair.Duplicate', e.code) else: self.fail('Exception not raised.') |
