mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-07-25 09:14:31 +00:00
Previously the owner field was not set by module `cloud.openstack.image`, although it is specified as a module parameter. The usual approach in `ansible-collections-openstack` is to accept both names and IDs when referencing openstack resources. Therefore this commit follows the approach taken by `python-openstackclient` in [1] and introduces a `project` and a `project_domain` parameter to identify projects by name or ID and assign the ID to the `owner` attribute of the image. The `owner` parameter is left as an alias to `project` in the module. Story: 2009983 Task: 45012 [1]cf2de9af79Change-Id: I3654587df8e40d554aac5126df307961f335332c (cherry picked from commitacf64a1f72)
149 lines
3.7 KiB
YAML
149 lines
3.7 KiB
YAML
---
|
|
- 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 raw image (defaults)
|
|
openstack.cloud.image:
|
|
cloud: "{{ cloud }}"
|
|
state: present
|
|
name: "{{ image_name }}"
|
|
filename: "{{ tmp_file.stdout }}"
|
|
disk_format: raw
|
|
tags: "{{ image_tags }}"
|
|
register: image
|
|
|
|
- name: Get details of created image
|
|
openstack.cloud.image_info:
|
|
cloud: "{{ cloud }}"
|
|
image: "{{ image_name }}"
|
|
register: image_info_result
|
|
|
|
- name: Verify image info
|
|
assert:
|
|
that:
|
|
- "image_info_result.images[0].name == image_name"
|
|
- "image_info_result.images[0].tags | sort == image_tags | sort"
|
|
|
|
- name: Delete raw image (defaults)
|
|
openstack.cloud.image:
|
|
cloud: "{{ cloud }}"
|
|
state: absent
|
|
name: "{{ image_name }}"
|
|
|
|
- name: Create raw image (complex)
|
|
openstack.cloud.image:
|
|
cloud: "{{ cloud }}"
|
|
state: present
|
|
name: "{{ image_name }}"
|
|
filename: "{{ tmp_file.stdout }}"
|
|
disk_format: raw
|
|
is_public: True
|
|
min_disk: 10
|
|
min_ram: 1024
|
|
kernel: cirros-vmlinuz
|
|
ramdisk: cirros-initrd
|
|
properties:
|
|
cpu_arch: x86_64
|
|
distro: ubuntu
|
|
register: image
|
|
|
|
- name: Delete raw image (complex)
|
|
openstack.cloud.image:
|
|
cloud: "{{ cloud }}"
|
|
state: absent
|
|
name: "{{ image_name }}"
|
|
|
|
- name: Try to get details of deleted image
|
|
openstack.cloud.image_info:
|
|
cloud: "{{ cloud }}"
|
|
image: "{{ image_name }}"
|
|
register: deleted_image_info_result
|
|
|
|
- name: Verify image is deleted
|
|
assert:
|
|
that:
|
|
- not deleted_image_info_result.images
|
|
|
|
- name: Create owner project
|
|
openstack.cloud.project:
|
|
cloud: "{{ cloud }}"
|
|
state: present
|
|
name: image_owner_project
|
|
description: Project owning test image
|
|
domain_id: default
|
|
enabled: True
|
|
register: owner_project
|
|
|
|
- name: Create raw image (owner by project name)
|
|
openstack.cloud.image:
|
|
cloud: "{{ cloud }}"
|
|
state: present
|
|
name: "{{ image_name }}"
|
|
filename: "{{ tmp_file.stdout }}"
|
|
disk_format: raw
|
|
tags: "{{ image_tags }}"
|
|
project: image_owner_project
|
|
register: image
|
|
|
|
- name: Get details of created image (owner by project name)
|
|
openstack.cloud.image_info:
|
|
cloud: "{{ cloud }}"
|
|
image: "{{ image_name }}"
|
|
register: image_info_result
|
|
|
|
- name: Verify image owner (owner by project name)
|
|
assert:
|
|
that:
|
|
- image_info_result.images[0].owner == owner_project.project.id
|
|
|
|
- name: Delete raw image (owner by project name)
|
|
openstack.cloud.image:
|
|
cloud: "{{ cloud }}"
|
|
state: absent
|
|
name: "{{ image_name }}"
|
|
|
|
- name: Create raw image (owner by project name and domain name)
|
|
openstack.cloud.image:
|
|
cloud: "{{ cloud }}"
|
|
state: present
|
|
name: "{{ image_name }}"
|
|
filename: "{{ tmp_file.stdout }}"
|
|
disk_format: raw
|
|
tags: "{{ image_tags }}"
|
|
project: image_owner_project
|
|
project_domain: default
|
|
register: image
|
|
|
|
- name: Get details of created image (owner by project name and domain name)
|
|
openstack.cloud.image_info:
|
|
cloud: "{{ cloud }}"
|
|
image: "{{ image_name }}"
|
|
register: image_info_result
|
|
|
|
- name: Verify image owner (owner by project name and domain name)
|
|
assert:
|
|
that:
|
|
- image_info_result.images[0].owner == owner_project.project.id
|
|
|
|
- name: Delete raw image (owner by project name and domain name)
|
|
openstack.cloud.image:
|
|
cloud: "{{ cloud }}"
|
|
state: absent
|
|
name: "{{ image_name }}"
|
|
|
|
- name: Delete owner project
|
|
openstack.cloud.project:
|
|
cloud: "{{ cloud }}"
|
|
state: absent
|
|
name: image_owner_project
|
|
domain_id: default
|
|
|
|
- name: Delete test image file
|
|
file:
|
|
name: "{{ tmp_file.stdout }}"
|
|
state: absent
|