[cloud] Allow ec2_lc module to use volume_type for block devices (#32421)
* Allow ec2_lc module to use volume_type for block devices Makes ec2_lc consistent with ec2, ec2_ami, ec2_vol etc. * Add deprecation message for device_type
This commit is contained in:
parent
921cc6d650
commit
7556ac91e5
2 changed files with 22 additions and 3 deletions
|
@ -833,6 +833,9 @@ def create_block_device(module, ec2, volume):
|
|||
# we add handling for either/or but not both
|
||||
if all(key in volume for key in ['device_type', 'volume_type']):
|
||||
module.fail_json(msg='device_type is a deprecated name for volume_type. Do not use both device_type and volume_type')
|
||||
if 'device_type' in volume:
|
||||
module.deprecate('device_type is deprecated for block devices - use volume_type instead',
|
||||
version=2.9)
|
||||
|
||||
# get whichever one is set, or NoneType if neither are set
|
||||
volume_type = volume.get('device_type') or volume.get('volume_type')
|
||||
|
|
|
@ -151,7 +151,7 @@ EXAMPLES = '''
|
|||
volumes:
|
||||
- device_name: /dev/sda1
|
||||
volume_size: 100
|
||||
device_type: io1
|
||||
volume_type: io1
|
||||
iops: 3000
|
||||
delete_on_termination: true
|
||||
encrypted: true
|
||||
|
@ -168,7 +168,7 @@ EXAMPLES = '''
|
|||
volumes:
|
||||
- device_name: /dev/sda1
|
||||
volume_size: 120
|
||||
device_type: io1
|
||||
volume_type: io1
|
||||
iops: 3000
|
||||
delete_on_termination: true
|
||||
|
||||
|
@ -188,11 +188,27 @@ except ImportError:
|
|||
|
||||
def create_block_device_meta(module, volume):
|
||||
MAX_IOPS_TO_SIZE_RATIO = 30
|
||||
|
||||
# device_type has been used historically to represent volume_type,
|
||||
# however ec2_vol uses volume_type, as does the BlockDeviceType, so
|
||||
# we add handling for either/or but not both
|
||||
if 'device_type' in volume:
|
||||
if 'volume_type' in volume:
|
||||
module.fail_json(msg='device_type is a deprecated name for volume_type. '
|
||||
'Do not use both device_type and volume_type')
|
||||
else:
|
||||
module.deprecate('device_type is deprecated for block devices - use volume_type instead',
|
||||
version=2.9)
|
||||
|
||||
# rewrite device_type key to volume_type
|
||||
if 'device_type' in volume:
|
||||
volume['volume_type'] = volume.pop('device_type')
|
||||
|
||||
if 'snapshot' not in volume and 'ephemeral' not in volume:
|
||||
if 'volume_size' not in volume:
|
||||
module.fail_json(msg='Size must be specified when creating a new volume or modifying the root volume')
|
||||
if 'snapshot' in volume:
|
||||
if 'device_type' in volume and volume.get('device_type') == 'io1' and 'iops' not in volume:
|
||||
if volume.get('volume_type') == 'io1' and 'iops' not in volume:
|
||||
module.fail_json(msg='io1 volumes must have an iops value set')
|
||||
if 'ephemeral' in volume:
|
||||
if 'snapshot' in volume:
|
||||
|
|
Loading…
Reference in a new issue