Make sure volume exists before querying

This commit is contained in:
Richard Simko 2017-10-04 18:00:54 +02:00 committed by rallytime
parent 7038248820
commit f62e8ca87f
No known key found for this signature in database
GPG key ID: E8F1A4B90D0DEA19

View file

@ -1990,7 +1990,7 @@ def request_instance(vm_=None, call=None):
params[termination_key] = str(set_del_root_vol_on_destroy).lower()
# Use default volume type if not specified
if ex_blockdevicemappings and 'Ebs.VolumeType' not in ex_blockdevicemappings[dev_index]:
if ex_blockdevicemappings and dev_index < len(ex_blockdevicemappings) and 'Ebs.VolumeType' not in ex_blockdevicemappings[dev_index]:
type_key = '{0}BlockDeviceMapping.{1}.Ebs.VolumeType'.format(spot_prefix, dev_index)
params[type_key] = rd_type