summaryrefslogtreecommitdiff
path: root/tests/cloud_tests/platforms/ec2
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cloud_tests/platforms/ec2')
-rw-r--r--tests/cloud_tests/platforms/ec2/instance.py4
-rw-r--r--tests/cloud_tests/platforms/ec2/platform.py18
2 files changed, 13 insertions, 9 deletions
diff --git a/tests/cloud_tests/platforms/ec2/instance.py b/tests/cloud_tests/platforms/ec2/instance.py
index ab6037b1..d2e84047 100644
--- a/tests/cloud_tests/platforms/ec2/instance.py
+++ b/tests/cloud_tests/platforms/ec2/instance.py
@@ -49,11 +49,11 @@ class EC2Instance(Instance):
# OutputBytes comes from platform._decode_console_output_as_bytes
response = self.instance.console_output()
return response['OutputBytes']
- except KeyError:
+ except KeyError as e:
if 'Output' in response:
msg = ("'OutputBytes' did not exist in console_output() but "
"'Output' did: %s..." % response['Output'][0:128])
- raise util.PlatformError('console_log', msg)
+ raise util.PlatformError('console_log', msg) from e
return ('No Console Output [%s]' % self.instance).encode()
def destroy(self):
diff --git a/tests/cloud_tests/platforms/ec2/platform.py b/tests/cloud_tests/platforms/ec2/platform.py
index 7a3d0fe0..b61a2ffb 100644
--- a/tests/cloud_tests/platforms/ec2/platform.py
+++ b/tests/cloud_tests/platforms/ec2/platform.py
@@ -35,12 +35,14 @@ class EC2Platform(Platform):
self.ec2_resource = b3session.resource('ec2')
self.ec2_region = b3session.region_name
self.key_name = self._upload_public_key(config)
- except botocore.exceptions.NoRegionError:
+ except botocore.exceptions.NoRegionError as e:
raise RuntimeError(
- 'Please configure default region in $HOME/.aws/config')
- except botocore.exceptions.NoCredentialsError:
+ 'Please configure default region in $HOME/.aws/config'
+ ) from e
+ except botocore.exceptions.NoCredentialsError as e:
raise RuntimeError(
- 'Please configure ec2 credentials in $HOME/.aws/credentials')
+ 'Please configure ec2 credentials in $HOME/.aws/credentials'
+ ) from e
self.vpc = self._create_vpc()
self.internet_gateway = self._create_internet_gateway()
@@ -125,8 +127,10 @@ class EC2Platform(Platform):
try:
image_ami = image['id']
- except KeyError:
- raise RuntimeError('No images found for %s!' % img_conf['release'])
+ except KeyError as e:
+ raise RuntimeError(
+ 'No images found for %s!' % img_conf['release']
+ ) from e
LOG.debug('found image: %s', image_ami)
image = EC2Image(self, img_conf, image_ami)
@@ -195,7 +199,7 @@ class EC2Platform(Platform):
CidrBlock=self.ipv4_cidr,
AmazonProvidedIpv6CidrBlock=True)
except botocore.exceptions.ClientError as e:
- raise RuntimeError(e)
+ raise RuntimeError(e) from e
vpc.wait_until_available()
self._tag_resource(vpc)