mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-05-08 22:34:12 +00:00
Updates volume for 2.0.0
Changes sdk calls to use the proxy layer where convenient. Ensures resources are converted to dict before returns. Changes the name of various parameters to match sdk attributes. Adds the old attribute names as aliases to maintain backward compatibility. Adds detailed return documentation. Removed the ability to create volumes in specific projects. Users looking to do that can use the auth parameter to specify what project is relevant Removes conditionals in tests that maintained support for ancient openstack and sdk releases. Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/854293 Change-Id: I3c4f4209f2ca6348370a45473bdb0d111b2439b6
This commit is contained in:
31
ci/roles/volume/defaults/main.yml
Normal file
31
ci/roles/volume/defaults/main.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
test_volume_image: ansible_test_volume_image
|
||||
test_volume_shared_image: ansible_test_volume_shared_image
|
||||
expected_fields:
|
||||
- attachments
|
||||
- availability_zone
|
||||
- consistency_group_id
|
||||
- created_at
|
||||
- updated_at
|
||||
- description
|
||||
- extended_replication_status
|
||||
- group_id
|
||||
- host
|
||||
- image_id
|
||||
- is_bootable
|
||||
- is_encrypted
|
||||
- migration_id
|
||||
- migration_status
|
||||
- project_id
|
||||
- replication_driver_data
|
||||
- replication_status
|
||||
- scheduler_hints
|
||||
- size
|
||||
- snapshot_id
|
||||
- source_volume_id
|
||||
- status
|
||||
- user_id
|
||||
- volume_image_metadata
|
||||
- volume_type
|
||||
- id
|
||||
- name
|
||||
- metadata
|
||||
@@ -4,15 +4,29 @@
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
size: 1
|
||||
display_name: ansible_volume
|
||||
display_description: Test volume
|
||||
name: ansible_volume
|
||||
description: Test volume
|
||||
register: vol
|
||||
|
||||
- assert:
|
||||
that: item in vol.volume
|
||||
loop: "{{ expected_fields }}"
|
||||
|
||||
- name: Create volume from existing volume
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
size: 1
|
||||
volume: "{{ vol.volume.id }}"
|
||||
name: ansible_volume1
|
||||
description: Test volume
|
||||
register: vol
|
||||
|
||||
- name: Create volume snapshot
|
||||
openstack.cloud.volume_snapshot:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
display_name: ansible_volume_snapshot
|
||||
name: ansible_volume_snapshot
|
||||
volume: ansible_volume
|
||||
register: vol_snap
|
||||
|
||||
@@ -21,23 +35,30 @@
|
||||
cloud: "{{ cloud }}"
|
||||
name: ansible_volume_snapshot
|
||||
register: snap_info
|
||||
ignore_errors: sdk_version is version('0.49', '<')
|
||||
|
||||
- name: Create volume from snapshot
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
size: 1
|
||||
snapshot: ansible_volume_snapshot
|
||||
name: ansible_volume2
|
||||
description: Test volume
|
||||
register: vol
|
||||
|
||||
- name: Create volume backup
|
||||
openstack.cloud.volume_backup:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
display_name: ansible_volume_backup
|
||||
name: ansible_volume_backup
|
||||
volume: ansible_volume
|
||||
register: vol_backup
|
||||
ignore_errors: sdk_version is version('0.49', '<')
|
||||
|
||||
- name: Get backup info
|
||||
openstack.cloud.volume_backup_info:
|
||||
cloud: "{{ cloud }}"
|
||||
name: ansible_volume_backup
|
||||
register: backup_info
|
||||
ignore_errors: sdk_version is version('0.49', '<')
|
||||
|
||||
- debug: var=vol
|
||||
|
||||
@@ -50,14 +71,14 @@
|
||||
- name: Delete volume backup
|
||||
openstack.cloud.volume_backup:
|
||||
cloud: "{{ cloud }}"
|
||||
display_name: ansible_volume_backup
|
||||
name: ansible_volume_backup
|
||||
wait: false
|
||||
state: absent
|
||||
ignore_errors: sdk_version is version(0.49, '<')
|
||||
|
||||
- name: Delete volume snapshot
|
||||
openstack.cloud.volume_snapshot:
|
||||
cloud: "{{ cloud }}"
|
||||
display_name: ansible_volume_snapshot
|
||||
name: ansible_volume_snapshot
|
||||
volume: ansible_volume
|
||||
state: absent
|
||||
|
||||
@@ -65,6 +86,71 @@
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
state: absent
|
||||
display_name: ansible_volume
|
||||
name: ansible_volume
|
||||
|
||||
- name: Clean up
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
state: absent
|
||||
name: "{{ item }}"
|
||||
loop:
|
||||
- ansible_volume1
|
||||
- ansible_volume2
|
||||
|
||||
- name: Create a test image file
|
||||
shell: mktemp
|
||||
register: tmp_file
|
||||
|
||||
- name: Fill test image file to 1MB
|
||||
shell: truncate -s 1048576 {{ tmp_file.stdout }}
|
||||
|
||||
- name: Create test image
|
||||
openstack.cloud.image:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
name: "{{ test_volume_image }}"
|
||||
filename: "{{ tmp_file.stdout }}"
|
||||
disk_format: raw
|
||||
tags: "{{ image_tags }}"
|
||||
register: returned_image
|
||||
|
||||
- name: Create volume from image
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
size: 1
|
||||
image: "{{ test_volume_image }}"
|
||||
name: ansible_volume2
|
||||
description: Test volume
|
||||
register: vol
|
||||
|
||||
- name: Delete volume from image
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
name: ansible_volume2
|
||||
state: absent
|
||||
register: vol
|
||||
|
||||
- name: Create test shared image
|
||||
openstack.cloud.image:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
name: "{{ image_name }}"
|
||||
filename: "{{ tmp_file.stdout }}"
|
||||
is_public: true
|
||||
disk_format: raw
|
||||
tags: "{{ image_tags }}"
|
||||
register: returned_image
|
||||
|
||||
- name: Delete test shared image
|
||||
openstack.cloud.image:
|
||||
cloud: "{{ cloud }}"
|
||||
state: absent
|
||||
name: "{{ image_name }}"
|
||||
filename: "{{ tmp_file.stdout }}"
|
||||
is_public: true
|
||||
disk_format: raw
|
||||
tags: "{{ image_tags }}"
|
||||
register: returned_image
|
||||
|
||||
- include_tasks: volume_info.yml
|
||||
|
||||
@@ -3,153 +3,126 @@
|
||||
cloud: "{{ cloud }}"
|
||||
details: true
|
||||
all_projects: true
|
||||
register: all_sdk
|
||||
ignore_errors: true
|
||||
|
||||
- name: Check info for all projects
|
||||
assert:
|
||||
that:
|
||||
# Rocky SDK doesn't have all_projects attribute
|
||||
- >-
|
||||
(all_sdk is failed and sdk_version is version(0.19, '<')) or
|
||||
all_sdk is success
|
||||
- name: Get info about volumes
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
all_projects: true
|
||||
register: delete
|
||||
|
||||
- name: Get info about volumes for all SDK
|
||||
- name: Clean up volumes before the test
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
state: absent
|
||||
name: "{{ vol.name }}"
|
||||
loop: "{{ delete.volumes }}"
|
||||
loop_control:
|
||||
loop_var: vol
|
||||
|
||||
- name: Create volume
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
size: 1
|
||||
name: ansible_test
|
||||
description: testci
|
||||
register: vol
|
||||
|
||||
- name: Get info about volumes
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
details: true
|
||||
register: all_sdk1
|
||||
ignore_errors: true
|
||||
all_projects: true
|
||||
register: info
|
||||
|
||||
- name: Check info for all SDK
|
||||
- name: Check info
|
||||
assert:
|
||||
that:
|
||||
- all_sdk1 is success
|
||||
- all_sdk1.volumes is defined
|
||||
- info.volumes | selectattr("description", "equalto", "testci") | list | length == 1
|
||||
- info.volumes.0.name == 'ansible_test'
|
||||
- info.volumes.0.status == 'available'
|
||||
|
||||
- name: Run tests for SDK > 0.28 (from train)
|
||||
when: sdk_version is version(0.28, '>')
|
||||
block:
|
||||
- name: Get not detailed info about volumes
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
details: false
|
||||
all_projects: true
|
||||
register: info1
|
||||
|
||||
- name: Get info about volumes
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
all_projects: true
|
||||
register: delete
|
||||
- name: Check info
|
||||
assert:
|
||||
that:
|
||||
- info1.volumes | selectattr("id", "equalto", "{{ info.volumes.0.id }}") | list | length == 1
|
||||
- info1.volumes.0.name == 'ansible_test'
|
||||
- info1.volumes.0.status == None
|
||||
|
||||
- name: Clean up volumes before the test
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
state: absent
|
||||
display_name: "{{ vol.name }}"
|
||||
loop: "{{ delete.volumes }}"
|
||||
loop_control:
|
||||
loop_var: vol
|
||||
- name: Get info about volumes with name
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
details: false
|
||||
name: ansible_test
|
||||
all_projects: true
|
||||
register: info2
|
||||
|
||||
- name: Create volume
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
state: present
|
||||
size: 1
|
||||
display_name: ansible_test
|
||||
display_description: testci
|
||||
register: vol
|
||||
- name: Check info
|
||||
assert:
|
||||
that:
|
||||
- info2.volumes | length == 1
|
||||
- info2.volumes.0.name == 'ansible_test'
|
||||
|
||||
- name: Get info about volumes
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
details: true
|
||||
all_projects: true
|
||||
register: info
|
||||
- name: Get info about volumes with non-existent name
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
details: false
|
||||
name: nothing_here
|
||||
all_projects: true
|
||||
register: info3
|
||||
|
||||
- name: Check info
|
||||
assert:
|
||||
that:
|
||||
- info.volumes | selectattr("description", "equalto", "testci") | list | length == 1
|
||||
- info.volumes.0.name == 'ansible_test'
|
||||
- info.volumes.0.status == 'available'
|
||||
- name: Check info
|
||||
assert:
|
||||
that:
|
||||
- info3.volumes | length == 0
|
||||
|
||||
- name: Get not detailed info about volumes
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
details: false
|
||||
all_projects: true
|
||||
register: info1
|
||||
- name: Get info about volumes
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
details: false
|
||||
name: ansible_test
|
||||
all_projects: true
|
||||
register: info4
|
||||
|
||||
- name: Check info
|
||||
assert:
|
||||
that:
|
||||
- info1.volumes | selectattr("id", "equalto", "{{ info.volumes.0.id }}") | list | length == 1
|
||||
- info1.volumes.0.name == 'ansible_test'
|
||||
- info1.volumes.0.status == None
|
||||
- name: Check info
|
||||
assert:
|
||||
that:
|
||||
- info4.volumes | length == 1
|
||||
- info4.volumes.0.name == 'ansible_test'
|
||||
|
||||
- name: Get info about volumes with name
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
details: false
|
||||
name: ansible_test
|
||||
all_projects: true
|
||||
register: info2
|
||||
- name: Get info about volumes not from all projects
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
details: false
|
||||
name: ansible_test
|
||||
register: info4a
|
||||
|
||||
- name: Check info
|
||||
assert:
|
||||
that:
|
||||
- info2.volumes | length == 1
|
||||
- info2.volumes.0.name == 'ansible_test'
|
||||
- name: Check info
|
||||
assert:
|
||||
that:
|
||||
- info4a.volumes | length == 1
|
||||
- info4a.volumes.0.name == 'ansible_test'
|
||||
|
||||
- name: Get info about volumes with non-existent name
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
details: false
|
||||
name: nothing_here
|
||||
all_projects: true
|
||||
register: info3
|
||||
- name: Delete volume
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
state: absent
|
||||
name: ansible_test
|
||||
|
||||
- name: Check info
|
||||
assert:
|
||||
that:
|
||||
- info3.volumes | length == 0
|
||||
- name: Get info when no volumes
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
all_projects: true
|
||||
register: info5
|
||||
|
||||
- name: Get info about volumes
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
details: false
|
||||
name: ansible_test
|
||||
all_projects: true
|
||||
register: info4
|
||||
|
||||
- name: Check info
|
||||
assert:
|
||||
that:
|
||||
- info4.volumes | length == 1
|
||||
- info4.volumes.0.name == 'ansible_test'
|
||||
|
||||
- name: Get info about volumes not from all projects
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
details: false
|
||||
name: ansible_test
|
||||
register: info4a
|
||||
|
||||
- name: Check info
|
||||
assert:
|
||||
that:
|
||||
- info4a.volumes | length == 1
|
||||
- info4a.volumes.0.name == 'ansible_test'
|
||||
|
||||
- name: Delete volume
|
||||
openstack.cloud.volume:
|
||||
cloud: "{{ cloud }}"
|
||||
state: absent
|
||||
display_name: ansible_test
|
||||
|
||||
- name: Get info when no volumes
|
||||
openstack.cloud.volume_info:
|
||||
cloud: "{{ cloud }}"
|
||||
all_projects: true
|
||||
register: info5
|
||||
|
||||
- name: Check info
|
||||
assert:
|
||||
that:
|
||||
- info5.volumes | selectattr("name", "equalto", "ansible_test") | list | length == 0
|
||||
- name: Check info
|
||||
assert:
|
||||
that:
|
||||
- info5.volumes | selectattr("name", "equalto", "ansible_test") | list | length == 0
|
||||
|
||||
Reference in New Issue
Block a user