From 00f8c5eea24059ab0b021ca041c75085b43da780 Mon Sep 17 00:00:00 2001 From: abikouo Date: Tue, 22 Jun 2021 10:02:00 +0200 Subject: [PATCH] test --- plugins/modules/ec2_vol.py | 22 +++++++++---------- .../targets/ec2_vol/tasks/tests.yml | 14 ++++++------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/plugins/modules/ec2_vol.py b/plugins/modules/ec2_vol.py index 129aaec66d8..8d209c61833 100644 --- a/plugins/modules/ec2_vol.py +++ b/plugins/modules/ec2_vol.py @@ -426,13 +426,10 @@ def update_volume(module, ec2_conn, volume): target_multi_attach = module.params.get('multi_attach') multi_attach_changed = False if target_multi_attach is not None: - if "io1" in [target_type, original_type] or "io2" in [target_type, original_type]: - original_multi_attach = volume['multi_attach_enabled'] - if target_multi_attach != original_multi_attach: - multi_attach_changed = True - req_obj['MultiAttachEnabled'] = target_multi_attach - else: - module.warn("multi_attach is supported with io1 and io2 volumes only.") + original_multi_attach = volume['multi_attach_enabled'] + if target_multi_attach != original_multi_attach: + multi_attach_changed = True + req_obj['MultiAttachEnabled'] = target_multi_attach changed = iops_changed or size_changed or type_changed or throughput_changed or multi_attach_changed @@ -489,11 +486,8 @@ def create_volume(module, ec2_conn, zone): if throughput: additional_params['Throughput'] = int(throughput) - if multi_attach is True: - if volume_type not in ("io1", "io2"): - module.warn("multi_attach is supported with io1 and io2 volumes only.") - else: - additional_params['MultiAttachEnabled'] = multi_attach + if multi_attach is not None: + additional_params['MultiAttachEnabled'] = multi_attach create_vol_response = ec2_conn.create_volume( aws_retry=True, @@ -721,6 +715,7 @@ def main(): iops = module.params.get('iops') volume_type = module.params.get('volume_type') throughput = module.params.get('throughput') + multi_attach = module.params.get('multi_attach') if state == 'list': module.deprecate( @@ -757,6 +752,9 @@ def main(): if throughput < 125 or throughput > 1000: module.fail_json(msg='Throughput values must be between 125 and 1000.') + if multi_attach is True and volume_type not in ('io1', 'io2'): + module.fail_json(msg='multi_attach is only supported for io1 and io2 volumes.') + # Set changed flag changed = False diff --git a/tests/integration/targets/ec2_vol/tasks/tests.yml b/tests/integration/targets/ec2_vol/tasks/tests.yml index 1b607c92914..a5aafd54750 100644 --- a/tests/integration/targets/ec2_vol/tasks/tests.yml +++ b/tests/integration/targets/ec2_vol/tasks/tests.yml @@ -562,11 +562,11 @@ - name: test create a new gp3 volume ec2_vol: - volume_size: 7 + volume_size: 70 zone: "{{ availability_zone }}" volume_type: gp3 throughput: 130 - iops: 300 + iops: 3001 name: "GP3-TEST-{{ resource_prefix }}" tags: ResourcePrefix: "{{ resource_prefix }}" @@ -581,11 +581,11 @@ - "'create_time' in gp3_volume.volume" - "'id' in gp3_volume.volume" - "'size' in gp3_volume.volume" - - gp3_volume.volume.size == 7 + - gp3_volume.volume.size == 70 - "'volume_type' in gp3_volume" - gp3_volume.volume_type == 'gp3' - "'iops' in gp3_volume.volume" - - gp3_volume.volume.iops == 300 + - gp3_volume.volume.iops == 3001 - "'throughput' in gp3_volume.volume" - gp3_volume.volume.throughput == 130 - "'tags' in gp3_volume.volume" @@ -628,7 +628,7 @@ - name: increase throughput ec2_vol: - volume_size: 7 + volume_size: 70 zone: "{{ availability_zone }}" volume_type: gp3 throughput: 131 @@ -647,11 +647,11 @@ - "'create_time' in gp3_volume.volume" - "'id' in gp3_volume.volume" - "'size' in gp3_volume.volume" - - gp3_volume.volume.size == 7 + - gp3_volume.volume.size == 70 - "'volume_type' in gp3_volume" - gp3_volume.volume_type == 'gp3' - "'iops' in gp3_volume.volume" - - gp3_volume.volume.iops == 300 + - gp3_volume.volume.iops == 3001 - "'throughput' in gp3_volume.volume" - gp3_volume.volume.throughput == 131