EC2 - Verify default block exists before tearing down

This commit is contained in:
Bert Blommers 2020-03-20 16:17:21 +00:00
parent 5b596c8a78
commit da1a2118bb

View File

@ -567,6 +567,7 @@ class Instance(TaggedEC2Resource, BotoInstance):
self.ec2_backend.attach_volume(volume.id, self.id, "/dev/sda1") self.ec2_backend.attach_volume(volume.id, self.id, "/dev/sda1")
def teardown_defaults(self): def teardown_defaults(self):
if "/dev/sda1" in self.block_device_mapping:
volume_id = self.block_device_mapping["/dev/sda1"].volume_id volume_id = self.block_device_mapping["/dev/sda1"].volume_id
self.ec2_backend.detach_volume(volume_id, self.id, "/dev/sda1") self.ec2_backend.detach_volume(volume_id, self.id, "/dev/sda1")
self.ec2_backend.delete_volume(volume_id) self.ec2_backend.delete_volume(volume_id)