Throw error if encryption is set while passing a snapshot id

This commit is contained in:
vanga 2015-07-09 20:42:54 +05:30
parent 007efe438d
commit 164043bd6d

View file

@ -692,6 +692,8 @@ def create_block_device(module, ec2, volume):
size = volume.get('volume_size', snapshot.volume_size) size = volume.get('volume_size', snapshot.volume_size)
if int(volume['iops']) > MAX_IOPS_TO_SIZE_RATIO * size: if int(volume['iops']) > MAX_IOPS_TO_SIZE_RATIO * size:
module.fail_json(msg = 'IOPS must be at most %d times greater than size' % MAX_IOPS_TO_SIZE_RATIO) module.fail_json(msg = 'IOPS must be at most %d times greater than size' % MAX_IOPS_TO_SIZE_RATIO)
if 'encrypted' in volume:
module.fail_json(msg = 'You can not set encyrption when creating a volume from a snapshot')
if 'ephemeral' in volume: if 'ephemeral' in volume:
if 'snapshot' in volume: if 'snapshot' in volume:
module.fail_json(msg = 'Cannot set both ephemeral and snapshot') module.fail_json(msg = 'Cannot set both ephemeral and snapshot')
@ -702,7 +704,6 @@ def create_block_device(module, ec2, volume):
delete_on_termination=volume.get('delete_on_termination', False), delete_on_termination=volume.get('delete_on_termination', False),
iops=volume.get('iops'), iops=volume.get('iops'),
encrypted=volume.get('encrypted', None)) encrypted=volume.get('encrypted', None))
def boto_supports_param_in_spot_request(ec2, param): def boto_supports_param_in_spot_request(ec2, param):
""" """
Check if Boto library has a <param> in its request_spot_instances() method. For example, the placement_group parameter wasn't added until 2.3.0. Check if Boto library has a <param> in its request_spot_instances() method. For example, the placement_group parameter wasn't added until 2.3.0.