Refactored image{,_info} modules
Code of the image module has been refactored partially only. It will have to be completed in a follow up patch. Change-Id: Id2360163117db9639a0af502ab44e02cae5cebaa
This commit is contained in:
parent
1f8c9fee05
commit
cc9ca5a34b
ci
plugins/modules
@ -1,317 +1,331 @@
|
|||||||
---
|
---
|
||||||
- name: Ensure image does not exist before tests
|
- name: Test images
|
||||||
openstack.cloud.image:
|
block:
|
||||||
cloud: "{{ cloud }}"
|
- name: List all images
|
||||||
state: absent
|
openstack.cloud.image_info:
|
||||||
name: ansible_image
|
cloud: "{{ cloud }}"
|
||||||
|
register: images
|
||||||
|
|
||||||
- name: Create a test image file
|
- name: Assert existence of CirrOS image
|
||||||
shell: mktemp
|
assert:
|
||||||
register: tmp_file
|
that:
|
||||||
|
- images.images | length > 0
|
||||||
|
|
||||||
- name: Fill test image file to 1MB
|
- name: Ensure clean environment
|
||||||
shell: truncate -s 1048576 {{ tmp_file.stdout }}
|
ansible.builtin.set_fact:
|
||||||
|
tmp_file: !!null
|
||||||
|
|
||||||
- name: ensure mock kernel and ramdisk images (defaults)
|
- name: Create a test image file
|
||||||
openstack.cloud.image:
|
ansible.builtin.tempfile:
|
||||||
cloud: "{{ cloud }}"
|
register: tmp_file
|
||||||
state: present
|
|
||||||
name: "{{ item }}"
|
|
||||||
filename: "{{ tmp_file.stdout }}"
|
|
||||||
disk_format: raw
|
|
||||||
loop:
|
|
||||||
- cirros-vmlinuz
|
|
||||||
- cirros-initrd
|
|
||||||
|
|
||||||
- name: Create raw image (defaults)
|
- name: Fill test image file to 1MB
|
||||||
openstack.cloud.image:
|
community.general.filesize:
|
||||||
cloud: "{{ cloud }}"
|
path: '{{ tmp_file.path }}'
|
||||||
state: present
|
size: 1M
|
||||||
name: ansible_image
|
|
||||||
filename: "{{ tmp_file.stdout }}"
|
|
||||||
is_protected: true
|
|
||||||
disk_format: raw
|
|
||||||
tags:
|
|
||||||
- test
|
|
||||||
- ansible
|
|
||||||
register: returned_image
|
|
||||||
|
|
||||||
- debug:
|
- name: Ensure mock kernel and ramdisk images (defaults)
|
||||||
var: returned_image
|
openstack.cloud.image:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: "{{ item }}"
|
||||||
|
filename: "{{ tmp_file.path }}"
|
||||||
|
disk_format: raw
|
||||||
|
loop:
|
||||||
|
- cirros-vmlinuz
|
||||||
|
- cirros-initrd
|
||||||
|
|
||||||
- name: Assert changed
|
- name: Create raw image (defaults)
|
||||||
assert:
|
openstack.cloud.image:
|
||||||
that: returned_image is changed
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: ansible_image
|
||||||
|
filename: "{{ tmp_file.path }}"
|
||||||
|
is_protected: true
|
||||||
|
disk_format: raw
|
||||||
|
tags:
|
||||||
|
- test
|
||||||
|
- ansible
|
||||||
|
register: image
|
||||||
|
|
||||||
- name: Assert fields
|
- name: Assert changed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- item in returned_image.image
|
- image is changed
|
||||||
loop: "{{ expected_fields }}"
|
|
||||||
|
|
||||||
- name: Get details of created image
|
- name: Assert return values of image module
|
||||||
openstack.cloud.image_info:
|
assert:
|
||||||
cloud: "{{ cloud }}"
|
that:
|
||||||
image: ansible_image
|
- image is changed
|
||||||
register: image_info_result
|
- image.image.name == 'ansible_image'
|
||||||
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
|
- expected_fields|difference(image.image.keys())|length == 0
|
||||||
|
|
||||||
- name: Verify image info
|
- name: Get details of created image
|
||||||
assert:
|
openstack.cloud.image_info:
|
||||||
that:
|
cloud: "{{ cloud }}"
|
||||||
- image_info_result.images[0].name == "ansible_image"
|
image: ansible_image
|
||||||
- image_info_result.images[0].tags | sort == ['test', 'ansible'] | sort
|
register: images
|
||||||
|
|
||||||
- name: Create raw image again (defaults)
|
- name: Assert return values of image_info module
|
||||||
openstack.cloud.image:
|
assert:
|
||||||
cloud: "{{ cloud }}"
|
that:
|
||||||
state: present
|
- images.images | length > 0
|
||||||
name: ansible_image
|
- images.images.0.name == "ansible_image"
|
||||||
filename: "{{ tmp_file.stdout }}"
|
- images.images.0.tags | sort == ['test', 'ansible'] | sort
|
||||||
is_protected: true
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
disk_format: raw
|
- expected_fields|difference(images.images.0.keys())|length == 0
|
||||||
tags:
|
|
||||||
- test
|
|
||||||
- ansible
|
|
||||||
register: returned_image
|
|
||||||
|
|
||||||
- name: Assert not changed
|
- name: Create raw image again (defaults)
|
||||||
assert:
|
openstack.cloud.image:
|
||||||
that: returned_image is not changed
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: ansible_image
|
||||||
|
filename: "{{ tmp_file.path }}"
|
||||||
|
is_protected: true
|
||||||
|
disk_format: raw
|
||||||
|
tags:
|
||||||
|
- test
|
||||||
|
- ansible
|
||||||
|
register: image
|
||||||
|
|
||||||
- name: Assert fields
|
- name: Assert not changed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- item in returned_image.image
|
- image is not changed
|
||||||
loop: "{{ expected_fields }}"
|
|
||||||
|
|
||||||
- name: Update is_protected on raw image (defaults)
|
- name: Update is_protected on raw image (defaults)
|
||||||
openstack.cloud.image:
|
openstack.cloud.image:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: present
|
state: present
|
||||||
name: ansible_image
|
name: ansible_image
|
||||||
is_protected: false
|
is_protected: false
|
||||||
register: returned_image
|
register: image
|
||||||
|
|
||||||
- name: Assert changed
|
- name: Assert changed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- returned_image is changed
|
- image is changed
|
||||||
- returned_image.image.is_protected == false
|
- image.image.is_protected == false
|
||||||
|
|
||||||
- name: Assert changed
|
- name: Assert changed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- returned_image is changed
|
- image is changed
|
||||||
|
|
||||||
- name: Update visibility on raw image (defaults)
|
- name: Update visibility on raw image (defaults)
|
||||||
openstack.cloud.image:
|
openstack.cloud.image:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: present
|
state: present
|
||||||
name: ansible_image
|
name: ansible_image
|
||||||
is_public: false
|
is_public: false
|
||||||
register: returned_image
|
register: image
|
||||||
|
|
||||||
- name: Assert changed
|
- name: Assert changed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- returned_image.image.visibility == 'private'
|
- image.image.visibility == 'private'
|
||||||
|
|
||||||
- name: Update again visibility on raw image (defaults)
|
- name: Update again visibility on raw image (defaults)
|
||||||
openstack.cloud.image:
|
openstack.cloud.image:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: present
|
state: present
|
||||||
name: ansible_image
|
name: ansible_image
|
||||||
is_public: true
|
is_public: true
|
||||||
register: returned_image
|
register: image
|
||||||
|
|
||||||
- name: Assert changed
|
- name: Assert changed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- returned_image is changed
|
- image is changed
|
||||||
- returned_image.image.visibility == 'public'
|
- image.image.visibility == 'public'
|
||||||
|
|
||||||
- name: Define visibility on raw image (defaults)
|
- name: Define visibility on raw image (defaults)
|
||||||
openstack.cloud.image:
|
openstack.cloud.image:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: present
|
state: present
|
||||||
name: ansible_image
|
name: ansible_image
|
||||||
visibility: shared
|
visibility: shared
|
||||||
register: returned_image
|
register: image
|
||||||
|
|
||||||
- name: Assert changed
|
- name: Assert changed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- returned_image is changed
|
- image is changed
|
||||||
- returned_image.image.visibility == 'shared'
|
- image.image.visibility == 'shared'
|
||||||
|
|
||||||
- name: Rename raw image (defaults)
|
- name: Rename raw image (defaults)
|
||||||
openstack.cloud.image:
|
openstack.cloud.image:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: present
|
state: present
|
||||||
id: "{{ returned_image.id }}"
|
id: "{{ image.image.id }}"
|
||||||
name: 'ansible_image-changed'
|
name: 'ansible_image-changed'
|
||||||
register: returned_image
|
register: image
|
||||||
|
|
||||||
- name: Assert changed
|
- name: Assert changed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- returned_image is changed
|
- image is changed
|
||||||
- returned_image.image.name == 'ansible_image-changed'
|
- image.image.name == 'ansible_image-changed'
|
||||||
|
|
||||||
- name: Rename back raw image (defaults)
|
- name: Rename back raw image (defaults)
|
||||||
openstack.cloud.image:
|
openstack.cloud.image:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: present
|
state: present
|
||||||
id: "{{ returned_image.id }}"
|
id: "{{ image.image.id }}"
|
||||||
name: ansible_image
|
name: ansible_image
|
||||||
register: returned_image
|
register: image
|
||||||
|
|
||||||
- name: Delete raw image (defaults)
|
- name: Delete raw image (defaults)
|
||||||
openstack.cloud.image:
|
openstack.cloud.image:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: absent
|
state: absent
|
||||||
name: ansible_image
|
name: ansible_image
|
||||||
register: returned_image
|
register: image
|
||||||
|
|
||||||
- name: assert image changed
|
- name: assert image changed
|
||||||
assert:
|
assert:
|
||||||
that: returned_image is changed
|
that:
|
||||||
|
- image is changed
|
||||||
|
|
||||||
- name: Delete raw image again (defaults)
|
- name: Delete raw image again (defaults)
|
||||||
openstack.cloud.image:
|
openstack.cloud.image:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: absent
|
state: absent
|
||||||
name: ansible_image
|
name: ansible_image
|
||||||
register: returned_image
|
register: image
|
||||||
|
|
||||||
- name: assert image not changed
|
- name: assert image not changed
|
||||||
assert:
|
assert:
|
||||||
that: returned_image is not changed
|
that:
|
||||||
|
- image is not changed
|
||||||
|
|
||||||
- name: Create raw image (complex)
|
- name: Create raw image (complex)
|
||||||
openstack.cloud.image:
|
openstack.cloud.image:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: present
|
state: present
|
||||||
name: ansible_image
|
name: ansible_image
|
||||||
filename: "{{ tmp_file.stdout }}"
|
filename: "{{ tmp_file.path }}"
|
||||||
disk_format: raw
|
disk_format: raw
|
||||||
is_public: True
|
is_public: True
|
||||||
min_disk: 10
|
min_disk: 10
|
||||||
min_ram: 1024
|
min_ram: 1024
|
||||||
# TODO(rcastillo): upload cirros-vmlinuz, cirros-initrd in test setup
|
# TODO(rcastillo): upload cirros-vmlinuz, cirros-initrd in test setup
|
||||||
kernel: cirros-vmlinuz
|
kernel: cirros-vmlinuz
|
||||||
ramdisk: cirros-initrd
|
ramdisk: cirros-initrd
|
||||||
properties:
|
properties:
|
||||||
cpu_arch: x86_64
|
cpu_arch: x86_64
|
||||||
distro: ubuntu
|
distro: ubuntu
|
||||||
register: returned_image
|
register: image
|
||||||
|
|
||||||
- name: Assert visibility
|
- name: Assert visibility
|
||||||
assert:
|
assert:
|
||||||
that: returned_image.image.visibility == 'public'
|
that:
|
||||||
|
- image.image.visibility == 'public'
|
||||||
|
|
||||||
- name: Assert fields
|
- name: Delete raw image (complex)
|
||||||
assert:
|
openstack.cloud.image:
|
||||||
that:
|
cloud: "{{ cloud }}"
|
||||||
- item in returned_image.image
|
state: absent
|
||||||
loop: "{{ expected_fields }}"
|
name: ansible_image
|
||||||
|
|
||||||
- name: Delete raw image (complex)
|
- name: Try to get details of deleted image
|
||||||
openstack.cloud.image:
|
openstack.cloud.image_info:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: absent
|
image: ansible_image
|
||||||
name: ansible_image
|
register: images
|
||||||
|
|
||||||
- name: Try to get details of deleted image
|
- name: Verify image is deleted
|
||||||
openstack.cloud.image_info:
|
assert:
|
||||||
cloud: "{{ cloud }}"
|
that:
|
||||||
image: ansible_image
|
- images.images | length == 0
|
||||||
register: deleted_image_info_result
|
|
||||||
|
|
||||||
- name: Verify image is deleted
|
- name: Create owner project
|
||||||
assert:
|
openstack.cloud.project:
|
||||||
that:
|
cloud: "{{ cloud }}"
|
||||||
- not deleted_image_info_result.images
|
state: present
|
||||||
|
name: ansible_project
|
||||||
|
description: Project owning test image
|
||||||
|
domain: default
|
||||||
|
is_enabled: True
|
||||||
|
register: project
|
||||||
|
|
||||||
- name: Create owner project
|
- name: Create raw image (owner by project name)
|
||||||
openstack.cloud.project:
|
openstack.cloud.image:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: present
|
state: present
|
||||||
name: image_owner_project
|
name: ansible_image
|
||||||
description: Project owning test image
|
filename: "{{ tmp_file.path }}"
|
||||||
domain: default
|
disk_format: raw
|
||||||
is_enabled: True
|
tags:
|
||||||
register: owner_project
|
- test
|
||||||
|
- ansible
|
||||||
|
project: ansible_project
|
||||||
|
register: image
|
||||||
|
|
||||||
- name: Create raw image (owner by project name)
|
- name: Get details of created image (owner by project name)
|
||||||
openstack.cloud.image:
|
openstack.cloud.image_info:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: present
|
image: ansible_image
|
||||||
name: ansible_image
|
register: images
|
||||||
filename: "{{ tmp_file.stdout }}"
|
|
||||||
disk_format: raw
|
|
||||||
tags:
|
|
||||||
- test
|
|
||||||
- ansible
|
|
||||||
project: image_owner_project
|
|
||||||
register: returned_image
|
|
||||||
|
|
||||||
- name: Get details of created image (owner by project name)
|
- name: Verify image owner (owner by project name)
|
||||||
openstack.cloud.image_info:
|
assert:
|
||||||
cloud: "{{ cloud }}"
|
that:
|
||||||
image: ansible_image
|
- images.images.0.owner == project.project.id
|
||||||
register: image_info_result
|
|
||||||
|
|
||||||
- name: Verify image owner (owner by project name)
|
- name: Delete raw image (owner by project name)
|
||||||
assert:
|
openstack.cloud.image:
|
||||||
that:
|
cloud: "{{ cloud }}"
|
||||||
- image_info_result.images[0].owner == owner_project.project.id
|
state: absent
|
||||||
|
name: ansible_image
|
||||||
|
|
||||||
- name: Delete raw image (owner by project name)
|
- name: Create raw image (owner by project name and domain name)
|
||||||
openstack.cloud.image:
|
openstack.cloud.image:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: absent
|
state: present
|
||||||
name: ansible_image
|
name: ansible_image
|
||||||
|
filename: "{{ tmp_file.path }}"
|
||||||
|
disk_format: raw
|
||||||
|
tags:
|
||||||
|
- test
|
||||||
|
- ansible
|
||||||
|
project: ansible_project
|
||||||
|
project_domain: default
|
||||||
|
register: image
|
||||||
|
|
||||||
- name: Create raw image (owner by project name and domain name)
|
- name: Get details of created image (owner by project name and domain name)
|
||||||
openstack.cloud.image:
|
openstack.cloud.image_info:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: present
|
image: ansible_image
|
||||||
name: ansible_image
|
register: images
|
||||||
filename: "{{ tmp_file.stdout }}"
|
|
||||||
disk_format: raw
|
|
||||||
tags:
|
|
||||||
- test
|
|
||||||
- ansible
|
|
||||||
project: image_owner_project
|
|
||||||
project_domain: default
|
|
||||||
register: returned_image
|
|
||||||
|
|
||||||
- name: Get details of created image (owner by project name and domain name)
|
- name: Verify image owner (owner by project name and domain name)
|
||||||
openstack.cloud.image_info:
|
assert:
|
||||||
cloud: "{{ cloud }}"
|
that:
|
||||||
image: ansible_image
|
- images.images.0.owner == project.project.id
|
||||||
register: image_info_result
|
|
||||||
|
|
||||||
- name: Verify image owner (owner by project name and domain name)
|
- name: Delete raw image (owner by project name and domain name)
|
||||||
assert:
|
openstack.cloud.image:
|
||||||
that:
|
cloud: "{{ cloud }}"
|
||||||
- image_info_result.images[0].owner == owner_project.project.id
|
state: absent
|
||||||
|
name: ansible_image
|
||||||
|
|
||||||
- name: Delete raw image (owner by project name and domain name)
|
- name: Delete owner project
|
||||||
openstack.cloud.image:
|
openstack.cloud.project:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: absent
|
state: absent
|
||||||
name: ansible_image
|
name: ansible_project
|
||||||
|
domain: default
|
||||||
|
|
||||||
- name: Delete owner project
|
- name: Delete test image file
|
||||||
openstack.cloud.project:
|
file:
|
||||||
cloud: "{{ cloud }}"
|
name: "{{ tmp_file.path }}"
|
||||||
state: absent
|
state: absent
|
||||||
name: image_owner_project
|
|
||||||
domain: default
|
|
||||||
|
|
||||||
- name: Delete test image file
|
always:
|
||||||
file:
|
- name: Remove temporary image file
|
||||||
name: "{{ tmp_file.stdout }}"
|
ansible.builtin.file:
|
||||||
state: absent
|
path: "{{ tmp_file.path }}"
|
||||||
|
state: absent
|
||||||
|
when: tmp_file is defined and 'path' in tmp_file
|
||||||
|
@ -1,65 +0,0 @@
|
|||||||
expected_fields:
|
|
||||||
- architecture
|
|
||||||
- checksum
|
|
||||||
- container_format
|
|
||||||
- created_at
|
|
||||||
- direct_url
|
|
||||||
- disk_format
|
|
||||||
- file
|
|
||||||
- has_auto_disk_config
|
|
||||||
- hash_algo
|
|
||||||
- hash_value
|
|
||||||
- hw_cpu_cores
|
|
||||||
- hw_cpu_policy
|
|
||||||
- hw_cpu_sockets
|
|
||||||
- hw_cpu_thread_policy
|
|
||||||
- hw_cpu_threads
|
|
||||||
- hw_disk_bus
|
|
||||||
- hw_machine_type
|
|
||||||
- hw_qemu_guest_agent
|
|
||||||
- hw_rng_model
|
|
||||||
- hw_scsi_model
|
|
||||||
- hw_serial_port_count
|
|
||||||
- hw_video_model
|
|
||||||
- hw_video_ram
|
|
||||||
- hw_vif_model
|
|
||||||
- hw_watchdog_action
|
|
||||||
- hypervisor_type
|
|
||||||
- id
|
|
||||||
- instance_type_rxtx_factor
|
|
||||||
- instance_uuid
|
|
||||||
- is_hidden
|
|
||||||
- is_hw_boot_menu_enabled
|
|
||||||
- is_hw_vif_multiqueue_enabled
|
|
||||||
- is_protected
|
|
||||||
- kernel_id
|
|
||||||
- locations
|
|
||||||
- metadata
|
|
||||||
- min_disk
|
|
||||||
- min_ram
|
|
||||||
- name
|
|
||||||
- needs_config_drive
|
|
||||||
- needs_secure_boot
|
|
||||||
- os_admin_user
|
|
||||||
- os_command_line
|
|
||||||
- os_distro
|
|
||||||
- os_require_quiesce
|
|
||||||
- os_shutdown_timeout
|
|
||||||
- os_type
|
|
||||||
- os_version
|
|
||||||
- owner
|
|
||||||
- owner_id
|
|
||||||
- properties
|
|
||||||
- ramdisk_id
|
|
||||||
- schema
|
|
||||||
- size
|
|
||||||
- status
|
|
||||||
- store
|
|
||||||
- tags
|
|
||||||
- updated_at
|
|
||||||
- url
|
|
||||||
- virtual_size
|
|
||||||
- visibility
|
|
||||||
- vm_mode
|
|
||||||
- vmware_adaptertype
|
|
||||||
- vmware_ostype
|
|
@ -1,11 +0,0 @@
|
|||||||
---
|
|
||||||
- name: List all images # This will list at least the default cirros image of devstack
|
|
||||||
openstack.cloud.image_info:
|
|
||||||
cloud: "{{ cloud }}"
|
|
||||||
register: image_list_result
|
|
||||||
|
|
||||||
- name: Assert fields
|
|
||||||
assert:
|
|
||||||
that:
|
|
||||||
- item in image_list_result.images.0.keys()
|
|
||||||
loop: "{{ expected_fields }}"
|
|
@ -26,7 +26,6 @@
|
|||||||
- { role: identity_role, tags: identity_role }
|
- { role: identity_role, tags: identity_role }
|
||||||
- { role: identity_role_info, tags: identity_role_info }
|
- { role: identity_role_info, tags: identity_role_info }
|
||||||
- { role: image, tags: image }
|
- { role: image, tags: image }
|
||||||
- { role: image_info, tags: image_info }
|
|
||||||
- { role: keypair, tags: keypair }
|
- { role: keypair, tags: keypair }
|
||||||
- { role: keystone_domain, tags: keystone_domain }
|
- { role: keystone_domain, tags: keystone_domain }
|
||||||
- role: keystone_idp
|
- role: keystone_idp
|
||||||
|
@ -5,135 +5,134 @@
|
|||||||
# Copyright (c) 2013, Benno Joy <benno@ansible.com>
|
# Copyright (c) 2013, Benno Joy <benno@ansible.com>
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = r'''
|
||||||
---
|
|
||||||
module: image
|
module: image
|
||||||
short_description: Add/Delete images from OpenStack Cloud
|
short_description: Manage images of OpenStack image (Glance) service.
|
||||||
author: OpenStack Ansible SIG
|
author: OpenStack Ansible SIG
|
||||||
description:
|
description:
|
||||||
- Add or Remove images from the OpenStack Image Repository
|
- Create or delete images in OpenStack image (Glance) service.
|
||||||
options:
|
options:
|
||||||
name:
|
checksum:
|
||||||
description:
|
description:
|
||||||
- The name of the image when uploading - or the name/ID of the image if deleting
|
- The checksum of the image.
|
||||||
- If provided with the id, it can be used to change the name of existing image
|
type: str
|
||||||
required: true
|
container_format:
|
||||||
type: str
|
description:
|
||||||
id:
|
- The format of the container.
|
||||||
description:
|
- This image attribute cannot be changed.
|
||||||
- The ID of the image when uploading an image
|
- Examples are C(ami), C(aki), C(ari), C(bare), C(ovf), C(ova) or
|
||||||
- This image attribute cannot be changed.
|
C(docker).
|
||||||
type: str
|
default: bare
|
||||||
checksum:
|
type: str
|
||||||
description:
|
disk_format:
|
||||||
- The checksum of the image
|
description:
|
||||||
type: str
|
- The format of the disk that is getting uploaded.
|
||||||
disk_format:
|
- This image attribute cannot be changed.
|
||||||
description:
|
- Examples are C(ami), C(ari), C(aki), C(vhd), C(vmdk), C(raw),
|
||||||
- The format of the disk that is getting uploaded
|
C(qcow2), C(vdi), c(iso), C(vhdx) or C(ploop).
|
||||||
- This image attribute cannot be changed.
|
default: qcow2
|
||||||
default: qcow2
|
type: str
|
||||||
choices: ['ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2', 'vdi', 'iso', 'vhdx', 'ploop']
|
filename:
|
||||||
type: str
|
description:
|
||||||
container_format:
|
- The path to the file which has to be uploaded.
|
||||||
description:
|
- This image attribute cannot be changed.
|
||||||
- The format of the container
|
type: str
|
||||||
- This image attribute cannot be changed.
|
id:
|
||||||
default: bare
|
description:
|
||||||
choices: ['ami', 'aki', 'ari', 'bare', 'ovf', 'ova', 'docker']
|
- The ID of the image when uploading an image.
|
||||||
type: str
|
- This image attribute cannot be changed.
|
||||||
owner:
|
type: str
|
||||||
description:
|
is_protected:
|
||||||
- The name or ID of the project owning the image
|
description:
|
||||||
type: str
|
- Prevent image from being deleted.
|
||||||
aliases: ['project']
|
aliases: ['protected']
|
||||||
owner_domain:
|
type: bool
|
||||||
description:
|
is_public:
|
||||||
- The name or id of the domain the project owning the image belongs to
|
description:
|
||||||
- May be used to identify a unique project when providing a name to the project argument and multiple projects with such name exist
|
- Whether the image can be accessed publicly.
|
||||||
type: str
|
- Setting I(is_public) to C(true) requires admin role by default.
|
||||||
aliases: ['project_domain']
|
- I(is_public) has been deprecated. Use I(visibility) instead of
|
||||||
min_disk:
|
I(is_public).
|
||||||
description:
|
type: bool
|
||||||
- The minimum disk space (in GB) required to boot this image
|
default: false
|
||||||
type: int
|
kernel:
|
||||||
min_ram:
|
description:
|
||||||
description:
|
- The name of an existing kernel image that will be associated with this
|
||||||
- The minimum ram (in MB) required to boot this image
|
image.
|
||||||
type: int
|
type: str
|
||||||
is_public:
|
min_disk:
|
||||||
description:
|
description:
|
||||||
- Whether the image can be accessed publicly.
|
- The minimum disk space (in GB) required to boot this image.
|
||||||
Note that publicizing an image requires admin role by default.
|
type: int
|
||||||
- Use I(visibility) instead of I(is_public),
|
min_ram:
|
||||||
the latter has been deprecated.
|
description:
|
||||||
type: bool
|
- The minimum ram (in MB) required to boot this image.
|
||||||
default: false
|
type: int
|
||||||
is_protected:
|
name:
|
||||||
description:
|
description:
|
||||||
- Prevent image from being deleted
|
- The name of the image when uploading - or the name/ID of the image if
|
||||||
aliases: ['protected']
|
deleting.
|
||||||
type: bool
|
- If provided with the id, it can be used to change the name of existing
|
||||||
filename:
|
image.
|
||||||
description:
|
required: true
|
||||||
- The path to the file which has to be uploaded
|
type: str
|
||||||
- This image attribute cannot be changed.
|
owner:
|
||||||
type: str
|
description:
|
||||||
ramdisk:
|
- The name or ID of the project owning the image.
|
||||||
description:
|
type: str
|
||||||
- The name of an existing ramdisk image that will be associated with this image
|
aliases: ['project']
|
||||||
type: str
|
owner_domain:
|
||||||
kernel:
|
description:
|
||||||
description:
|
- The name or id of the domain the project owning the image belongs to.
|
||||||
- The name of an existing kernel image that will be associated with this image
|
- May be used to identify a unique project when providing a name to the
|
||||||
type: str
|
project argument and multiple projects with such name exist.
|
||||||
properties:
|
type: str
|
||||||
description:
|
aliases: ['project_domain']
|
||||||
- Additional properties to be associated with this image
|
properties:
|
||||||
default: {}
|
description:
|
||||||
type: dict
|
- Additional properties to be associated with this image.
|
||||||
state:
|
default: {}
|
||||||
description:
|
type: dict
|
||||||
- Should the resource be present or absent.
|
ramdisk:
|
||||||
choices: [present, absent]
|
description:
|
||||||
default: present
|
- The name of an existing ramdisk image that will be associated with this
|
||||||
type: str
|
image.
|
||||||
tags:
|
type: str
|
||||||
description:
|
state:
|
||||||
- List of tags to be applied to the image
|
description:
|
||||||
default: []
|
- Should the resource be present or absent.
|
||||||
type: list
|
choices: [present, absent]
|
||||||
elements: str
|
default: present
|
||||||
visibility:
|
type: str
|
||||||
description:
|
tags:
|
||||||
- The image visibility
|
description:
|
||||||
type: str
|
- List of tags to be applied to the image.
|
||||||
choices: [public, private, shared, community]
|
default: []
|
||||||
volume:
|
type: list
|
||||||
description:
|
elements: str
|
||||||
- ID of a volume to create an image from.
|
visibility:
|
||||||
- The volume must be in AVAILABLE state.
|
description:
|
||||||
- Switch to module M(openstack.cloud.volume) instead of using I(volume),
|
- The image visibility.
|
||||||
the latter has been deprecated.
|
type: str
|
||||||
type: str
|
choices: [public, private, shared, community]
|
||||||
|
volume:
|
||||||
|
description:
|
||||||
|
- ID of a volume to create an image from.
|
||||||
|
- The volume must be in AVAILABLE state.
|
||||||
|
- I(volume) has been deprecated. Use module M(openstack.cloud.volume)
|
||||||
|
instead.
|
||||||
|
type: str
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.6"
|
||||||
- "openstacksdk"
|
- "openstacksdk"
|
||||||
|
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- openstack.cloud.openstack
|
- openstack.cloud.openstack
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = r'''
|
||||||
# Upload an image from a local file named cirros-0.3.0-x86_64-disk.img
|
- name: Upload an image from a local file named cirros-0.3.0-x86_64-disk.img
|
||||||
- openstack.cloud.image:
|
openstack.cloud.image:
|
||||||
auth:
|
cloud: devstack-admin
|
||||||
auth_url: https://identity.example.com
|
|
||||||
username: admin
|
|
||||||
password: passme
|
|
||||||
project_name: admin
|
|
||||||
openstack.cloud.identity_user_domain_name: Default
|
|
||||||
openstack.cloud.project_domain_name: Default
|
|
||||||
name: cirros
|
name: cirros
|
||||||
container_format: bare
|
container_format: bare
|
||||||
disk_format: qcow2
|
disk_format: qcow2
|
||||||
@ -148,303 +147,226 @@ EXAMPLES = '''
|
|||||||
distro: ubuntu
|
distro: ubuntu
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = r'''
|
||||||
id:
|
|
||||||
description: ID of the image.
|
|
||||||
returned: On success when I(state) is 'present'.
|
|
||||||
type: str
|
|
||||||
image:
|
image:
|
||||||
description: Dictionary describing the image.
|
description: Dictionary describing the Glance image.
|
||||||
|
returned: On success when I(state) is C(present).
|
||||||
type: dict
|
type: dict
|
||||||
returned: On success when I(state) is 'present'.
|
|
||||||
contains:
|
contains:
|
||||||
id:
|
id:
|
||||||
description: Unique UUID.
|
description: Unique UUID.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
name:
|
name:
|
||||||
description: Name given to the image.
|
description: Name given to the image.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
status:
|
status:
|
||||||
description: Image status.
|
description: Image status.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
architecture:
|
architecture:
|
||||||
description: |
|
description: The CPU architecture that must be supported by
|
||||||
The CPU architecture that must be supported by the hypervisor.
|
the hypervisor.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
created_at:
|
created_at:
|
||||||
description: Image created at timestamp.
|
description: Image created at timestamp.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
container_format:
|
container_format:
|
||||||
description: Container format of the image.
|
description: Container format of the image.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
direct_url:
|
direct_url:
|
||||||
description: URL to access the image file kept in external store.
|
description: URL to access the image file kept in external store.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
min_ram:
|
min_ram:
|
||||||
description: Min amount of RAM required for this image.
|
description: Min amount of RAM required for this image.
|
||||||
returned: success
|
|
||||||
type: int
|
type: int
|
||||||
disk_format:
|
disk_format:
|
||||||
description: Disk format of the image.
|
description: Disk format of the image.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
file:
|
file:
|
||||||
description: The URL for the virtual machine image file.
|
description: The URL for the virtual machine image file.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
has_auto_disk_config:
|
has_auto_disk_config:
|
||||||
description: >
|
description: If root partition on disk is automatically resized
|
||||||
If root partition on disk is automatically resized before the instance
|
before the instance boots.
|
||||||
boots.
|
|
||||||
returned: success
|
|
||||||
type: bool
|
type: bool
|
||||||
hash_algo:
|
hash_algo:
|
||||||
description: |
|
description: The algorithm used to compute a secure hash of the
|
||||||
The algorithm used to compute a secure hash of the image data.
|
image data.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
hash_value:
|
hash_value:
|
||||||
description: >
|
description: The hexdigest of the secure hash of the image data
|
||||||
The hexdigest of the secure hash of the image data computed using the
|
computed using the algorithm whose name is the value of the
|
||||||
algorithm whose name is the value of the os_hash_algo property.
|
os_hash_algo property.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
hw_cpu_cores:
|
hw_cpu_cores:
|
||||||
description: >
|
description: Used to pin the virtual CPUs (vCPUs) of instances to
|
||||||
Used to pin the virtual CPUs (vCPUs) of instances to the host's physical
|
the host's physical CPU cores (pCPUs).
|
||||||
CPU cores (pCPUs).
|
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
hw_cpu_policy:
|
hw_cpu_policy:
|
||||||
description: The hexdigest of the secure hash of the image data.
|
description: The hexdigest of the secure hash of the image data.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
hw_cpu_sockets:
|
hw_cpu_sockets:
|
||||||
description: Preferred number of sockets to expose to the guest.
|
description: Preferred number of sockets to expose to the guest.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
hw_cpu_thread_policy:
|
hw_cpu_thread_policy:
|
||||||
description: >
|
description: Defines how hardware CPU threads in a simultaneous
|
||||||
Defines how hardware CPU threads in a simultaneous multithreading-based
|
multithreading-based (SMT) architecture be used.
|
||||||
(SMT) architecture be used.
|
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
hw_cpu_threads:
|
hw_cpu_threads:
|
||||||
description: |
|
description: The preferred number of threads to expose to the guest.
|
||||||
The preferred number of threads to expose to the guest.
|
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
hw_disk_bus:
|
hw_disk_bus:
|
||||||
description: |
|
description: Specifies the type of disk controller to attach disk
|
||||||
Specifies the type of disk controller to attach disk devices to.
|
devices to.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
hw_machine_type:
|
hw_machine_type:
|
||||||
description: |
|
description: Enables booting an ARM system using the
|
||||||
Enables booting an ARM system using the specified machine type.
|
specified machine type.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
hw_qemu_guest_agent:
|
hw_qemu_guest_agent:
|
||||||
description: >
|
description: "A string boolean, which if 'true', QEMU guest agent
|
||||||
A string boolean, which if "true", QEMU guest agent will be exposed to
|
will be exposed to the instance."
|
||||||
the instance.
|
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
hw_rng_model:
|
hw_rng_model:
|
||||||
description: Adds a random-number generator device to the image's instances.
|
description: "Adds a random-number generator device to the image's
|
||||||
returned: success
|
instances."
|
||||||
type: str
|
type: str
|
||||||
hw_scsi_model:
|
hw_scsi_model:
|
||||||
description: >
|
description: Enables the use of VirtIO SCSI (virtio-scsi) to
|
||||||
Enables the use of VirtIO SCSI (virtio-scsi) to provide block device
|
provide block device access for compute instances.
|
||||||
access for compute instances.
|
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
hw_video_model:
|
hw_video_model:
|
||||||
description: The video image driver used.
|
description: The video image driver used.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
hw_video_ram:
|
hw_video_ram:
|
||||||
description: Maximum RAM for the video image.
|
description: Maximum RAM for the video image.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
hw_vif_model:
|
hw_vif_model:
|
||||||
description: Specifies the model of virtual network interface device to use.
|
description: Specifies the model of virtual network interface device to
|
||||||
returned: success
|
use.
|
||||||
type: str
|
type: str
|
||||||
hw_watchdog_action:
|
hw_watchdog_action:
|
||||||
description: >
|
description: Enables a virtual hardware watchdog device that
|
||||||
Enables a virtual hardware watchdog device that carries out the
|
carries out the specified action if the server hangs.
|
||||||
specified action if the server hangs.
|
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
hypervisor_type:
|
hypervisor_type:
|
||||||
description: The hypervisor type.
|
description: The hypervisor type.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
instance_type_rxtx_factor:
|
instance_type_rxtx_factor:
|
||||||
description: >
|
description: Optional property allows created servers to have a
|
||||||
Optional property allows created servers to have a different bandwidth
|
different bandwidth cap than that defined in the network
|
||||||
cap than that defined in the network they are attached to.
|
they are attached to.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
instance_uuid:
|
instance_uuid:
|
||||||
description: >
|
description: For snapshot images, this is the UUID of the server
|
||||||
For snapshot images, this is the UUID of the server used to create this
|
used to create this image.
|
||||||
image.
|
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
is_hidden:
|
is_hidden:
|
||||||
description: >-
|
description: Controls whether an image is displayed in the default
|
||||||
Controls whether an image is displayed in the default image-list
|
image-list response
|
||||||
response
|
|
||||||
returned: success
|
|
||||||
type: bool
|
type: bool
|
||||||
is_hw_boot_menu_enabled:
|
is_hw_boot_menu_enabled:
|
||||||
description: Enables the BIOS bootmenu.
|
description: Enables the BIOS bootmenu.
|
||||||
returned: success
|
|
||||||
type: bool
|
type: bool
|
||||||
is_hw_vif_multiqueue_enabled:
|
is_hw_vif_multiqueue_enabled:
|
||||||
description: |
|
description: Enables the virtio-net multiqueue feature.
|
||||||
Enables the virtio-net multiqueue feature.
|
|
||||||
returned: success
|
|
||||||
type: bool
|
type: bool
|
||||||
kernel_id:
|
kernel_id:
|
||||||
description: >
|
description: The ID of an image stored in the Image service that
|
||||||
The ID of an image stored in the Image service that should be used as
|
should be used as the kernel when booting an AMI-style
|
||||||
the kernel when booting an AMI-style image.
|
image.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
locations:
|
locations:
|
||||||
description: A list of URLs to access the image file in external store.
|
description: A list of URLs to access the image file in external store.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
metadata:
|
metadata:
|
||||||
description: The location metadata.
|
description: The location metadata.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
needs_config_drive:
|
needs_config_drive:
|
||||||
description: Specifies whether the image needs a config drive.
|
description: Specifies whether the image needs a config drive.
|
||||||
returned: success
|
|
||||||
type: bool
|
type: bool
|
||||||
needs_secure_boot:
|
needs_secure_boot:
|
||||||
description: Whether Secure Boot is needed.
|
description: Whether Secure Boot is needed.
|
||||||
returned: success
|
|
||||||
type: bool
|
type: bool
|
||||||
os_admin_user:
|
os_admin_user:
|
||||||
description: The operating system admin username.
|
description: The operating system admin username.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
os_command_line:
|
os_command_line:
|
||||||
description: The kernel command line to be used by libvirt driver.
|
description: The kernel command line to be used by libvirt driver.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
os_distro:
|
os_distro:
|
||||||
description: |
|
description: The common name of the operating system distribution
|
||||||
The common name of the operating system distribution in lowercase.
|
in lowercase.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
os_require_quiesce:
|
os_require_quiesce:
|
||||||
description: |
|
description: If true, require quiesce on snapshot via
|
||||||
If true, require quiesce on snapshot via QEMU guest agent.
|
QEMU guest agent.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
os_shutdown_timeout:
|
os_shutdown_timeout:
|
||||||
description: Time for graceful shutdown.
|
description: Time for graceful shutdown.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
os_type:
|
os_type:
|
||||||
description: The operating system installed on the image.
|
description: The operating system installed on the image.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
os_version:
|
os_version:
|
||||||
description: |
|
description: The operating system version as specified by
|
||||||
The operating system version as specified by the distributor.
|
the distributor.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
owner_id:
|
owner_id:
|
||||||
description: 'The ID of the owner, or project, of the image.'
|
description: The ID of the owner, or project, of the image.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
ramdisk_id:
|
ramdisk_id:
|
||||||
description: >
|
description: The ID of image stored in the Image service that should
|
||||||
The ID of image stored in the Image service that should be used as the
|
be used as the ramdisk when booting an AMI-style image.
|
||||||
ramdisk when booting an AMI-style image.
|
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
schema:
|
schema:
|
||||||
description: URL for the schema describing a virtual machine image.
|
description: URL for the schema describing a virtual machine image.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
store:
|
store:
|
||||||
description: >
|
description: Glance will attempt to store the disk image data in the
|
||||||
Glance will attempt to store the disk image data in the backing store
|
backing store indicated by the value of the header.
|
||||||
indicated by the value of the header.
|
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
updated_at:
|
updated_at:
|
||||||
description: Image updated at timestamp.
|
description: Image updated at timestamp.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
url:
|
url:
|
||||||
description: URL to access the image file kept in external store.
|
description: URL to access the image file kept in external store.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
virtual_size:
|
virtual_size:
|
||||||
description: The virtual size of the image.
|
description: The virtual size of the image.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
vm_mode:
|
vm_mode:
|
||||||
description: The virtual machine mode.
|
description: The virtual machine mode.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
vmware_adaptertype:
|
vmware_adaptertype:
|
||||||
description: |
|
description: The virtual SCSI or IDE controller used by the
|
||||||
The virtual SCSI or IDE controller used by the hypervisor.
|
hypervisor.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
vmware_ostype:
|
vmware_ostype:
|
||||||
description: Operating system installed in the image.
|
description: Operating system installed in the image.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
filters:
|
filters:
|
||||||
description: Additional properties associated with the image.
|
description: Additional properties associated with the image.
|
||||||
returned: success
|
|
||||||
type: dict
|
type: dict
|
||||||
min_disk:
|
min_disk:
|
||||||
description: Min amount of disk space required for this image.
|
description: Min amount of disk space required for this image.
|
||||||
returned: success
|
|
||||||
type: int
|
type: int
|
||||||
is_protected:
|
is_protected:
|
||||||
description: Image protected flag.
|
description: Image protected flag.
|
||||||
returned: success
|
|
||||||
type: bool
|
type: bool
|
||||||
checksum:
|
checksum:
|
||||||
description: Checksum for the image.
|
description: Checksum for the image.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
owner:
|
owner:
|
||||||
description: Owner for the image.
|
description: Owner for the image.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
visibility:
|
visibility:
|
||||||
description: Indicates who has access to the image.
|
description: Indicates who has access to the image.
|
||||||
returned: success
|
|
||||||
type: str
|
type: str
|
||||||
size:
|
size:
|
||||||
description: Size of the image.
|
description: Size of the image.
|
||||||
returned: success
|
|
||||||
type: int
|
type: int
|
||||||
tags:
|
tags:
|
||||||
description: List of tags assigned to the image
|
description: List of tags assigned to the image
|
||||||
returned: success
|
|
||||||
type: list
|
type: list
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@ -454,26 +376,25 @@ from ansible_collections.openstack.cloud.plugins.module_utils.openstack import O
|
|||||||
class ImageModule(OpenStackModule):
|
class ImageModule(OpenStackModule):
|
||||||
|
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
name=dict(required=True),
|
|
||||||
id=dict(),
|
|
||||||
checksum=dict(),
|
checksum=dict(),
|
||||||
disk_format=dict(default='qcow2',
|
container_format=dict(default='bare'),
|
||||||
choices=['ami', 'ari', 'aki', 'vhd', 'vmdk', 'raw', 'qcow2', 'vdi', 'iso', 'vhdx', 'ploop']),
|
disk_format=dict(default='qcow2'),
|
||||||
container_format=dict(default='bare', choices=['ami', 'aki', 'ari', 'bare', 'ovf', 'ova', 'docker']),
|
filename=dict(),
|
||||||
owner=dict(aliases=['project']),
|
id=dict(),
|
||||||
owner_domain=dict(aliases=['project_domain']),
|
is_protected=dict(type='bool', aliases=['protected']),
|
||||||
|
is_public=dict(type='bool', default=False),
|
||||||
|
kernel=dict(),
|
||||||
min_disk=dict(type='int'),
|
min_disk=dict(type='int'),
|
||||||
min_ram=dict(type='int'),
|
min_ram=dict(type='int'),
|
||||||
is_public=dict(type='bool', default=False),
|
name=dict(required=True),
|
||||||
is_protected=dict(type='bool', aliases=['protected']),
|
owner=dict(aliases=['project']),
|
||||||
filename=dict(),
|
owner_domain=dict(aliases=['project_domain']),
|
||||||
ramdisk=dict(),
|
|
||||||
kernel=dict(),
|
|
||||||
properties=dict(type='dict', default={}),
|
properties=dict(type='dict', default={}),
|
||||||
volume=dict(),
|
ramdisk=dict(),
|
||||||
tags=dict(type='list', default=[], elements='str'),
|
|
||||||
state=dict(default='present', choices=['absent', 'present']),
|
state=dict(default='present', choices=['absent', 'present']),
|
||||||
|
tags=dict(type='list', default=[], elements='str'),
|
||||||
visibility=dict(choices=['public', 'private', 'shared', 'community']),
|
visibility=dict(choices=['public', 'private', 'shared', 'community']),
|
||||||
|
volume=dict(),
|
||||||
)
|
)
|
||||||
|
|
||||||
module_kwargs = dict(
|
module_kwargs = dict(
|
||||||
@ -574,15 +495,15 @@ class ImageModule(OpenStackModule):
|
|||||||
if self.params['state'] == 'present':
|
if self.params['state'] == 'present':
|
||||||
attrs = self._build_params(owner)
|
attrs = self._build_params(owner)
|
||||||
if not image:
|
if not image:
|
||||||
# self.conn.image.create_image cannot be used because
|
# self.conn.image.create_image() cannot be used because it does
|
||||||
# self.conn.create_image provides a volume parameter
|
# not provide self.conn.create_image()'s volume parameter [0].
|
||||||
# Ref.: https://opendev.org/openstack/openstacksdk/src/commit/a41d04ea197439c2f134ce3554995693933a46ac/openstack/cloud/_image.py#L306
|
# [0] https://opendev.org/openstack/openstacksdk/src/commit/
|
||||||
|
# a41d04ea197439c2f134ce3554995693933a46ac/openstack/cloud/_image.py#L306
|
||||||
image = self.conn.create_image(**attrs)
|
image = self.conn.create_image(**attrs)
|
||||||
changed = True
|
changed = True
|
||||||
if not self.params['wait']:
|
if not self.params['wait']:
|
||||||
self.exit_json(changed=changed,
|
self.exit_json(changed=changed,
|
||||||
image=self._return_value(image.id),
|
image=self._return_value(image.id))
|
||||||
id=image.id)
|
|
||||||
|
|
||||||
update_payload = self._build_update(image)
|
update_payload = self._build_update(image)
|
||||||
|
|
||||||
@ -590,8 +511,7 @@ class ImageModule(OpenStackModule):
|
|||||||
self.conn.image.update_image(image.id, **update_payload)
|
self.conn.image.update_image(image.id, **update_payload)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
self.exit_json(changed=changed, image=self._return_value(image.id),
|
self.exit_json(changed=changed, image=self._return_value(image.id))
|
||||||
id=image.id)
|
|
||||||
|
|
||||||
elif self.params['state'] == 'absent' and image is not None:
|
elif self.params['state'] == 'absent' and image is not None:
|
||||||
# self.conn.image.delete_image() does not offer a wait parameter
|
# self.conn.image.delete_image() does not offer a wait parameter
|
||||||
|
@ -4,394 +4,296 @@
|
|||||||
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = r'''
|
||||||
---
|
---
|
||||||
module: image_info
|
module: image_info
|
||||||
short_description: Retrieve information about an image within OpenStack.
|
short_description: Fetch images from OpenStack image (Glance) service.
|
||||||
author: OpenStack Ansible SIG
|
author: OpenStack Ansible SIG
|
||||||
description:
|
description:
|
||||||
- Retrieve information about a image image from OpenStack.
|
- Fetch images from OpenStack image (Glance) service.
|
||||||
options:
|
options:
|
||||||
image:
|
name:
|
||||||
description:
|
description:
|
||||||
- Name or ID of the image
|
- Name or ID of the image
|
||||||
required: false
|
type: str
|
||||||
type: str
|
aliases: ['image']
|
||||||
filters:
|
filters:
|
||||||
description:
|
description:
|
||||||
- Dict of properties of the images used for query
|
- Dict of properties of the images used for query
|
||||||
type: dict
|
type: dict
|
||||||
required: false
|
aliases: ['properties']
|
||||||
aliases: ['properties']
|
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 3.6"
|
- "python >= 3.6"
|
||||||
- "openstacksdk"
|
- "openstacksdk"
|
||||||
|
|
||||||
extends_documentation_fragment:
|
extends_documentation_fragment:
|
||||||
- openstack.cloud.openstack
|
- openstack.cloud.openstack
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = r'''
|
||||||
- name: Gather information about a previously created image named image1
|
- name: Gather previously created image named image1
|
||||||
openstack.cloud.image_info:
|
openstack.cloud.image_info:
|
||||||
auth:
|
cloud: devstack-admin
|
||||||
auth_url: https://identity.example.com
|
|
||||||
username: user
|
|
||||||
password: password
|
|
||||||
project_name: someproject
|
|
||||||
image: image1
|
image: image1
|
||||||
register: result
|
|
||||||
|
|
||||||
- name: Show openstack information
|
- name: List all images
|
||||||
debug:
|
|
||||||
msg: "{{ result.image }}"
|
|
||||||
|
|
||||||
# Show all available Openstack images
|
|
||||||
- name: Retrieve all available Openstack images
|
|
||||||
openstack.cloud.image_info:
|
openstack.cloud.image_info:
|
||||||
register: result
|
|
||||||
|
|
||||||
- name: Show images
|
- name: Retrieve and filter images
|
||||||
debug:
|
openstack.cloud.image_info:
|
||||||
msg: "{{ result.image }}"
|
|
||||||
|
|
||||||
# Show images matching requested properties
|
|
||||||
- name: Retrieve images having properties with desired values
|
|
||||||
openstack.cloud.image_facts:
|
|
||||||
filters:
|
filters:
|
||||||
some_property: some_value
|
is_protected: False
|
||||||
OtherProp: OtherVal
|
|
||||||
|
|
||||||
- name: Show images
|
|
||||||
debug:
|
|
||||||
msg: "{{ result.image }}"
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = r'''
|
||||||
images:
|
images:
|
||||||
description: has all the openstack information about the image
|
description: List of dictionaries describing matching images.
|
||||||
returned: always, but can be null
|
returned: always
|
||||||
type: complex
|
type: list
|
||||||
contains:
|
elements: dict
|
||||||
id:
|
contains:
|
||||||
description: Unique UUID.
|
id:
|
||||||
returned: success
|
description: Unique UUID.
|
||||||
type: str
|
type: str
|
||||||
name:
|
name:
|
||||||
description: Name given to the image.
|
description: Name given to the image.
|
||||||
returned: success
|
type: str
|
||||||
type: str
|
status:
|
||||||
status:
|
description: Image status.
|
||||||
description: Image status.
|
type: str
|
||||||
returned: success
|
architecture:
|
||||||
type: str
|
description: The CPU architecture that must be supported by
|
||||||
architecture:
|
the hypervisor.
|
||||||
description: >
|
type: str
|
||||||
The CPU architecture that must be supported by
|
created_at:
|
||||||
the hypervisor.
|
description: Image created at timestamp.
|
||||||
returned: success
|
type: str
|
||||||
type: str
|
container_format:
|
||||||
created_at:
|
description: Container format of the image.
|
||||||
description: Image created at timestamp.
|
type: str
|
||||||
returned: success
|
direct_url:
|
||||||
type: str
|
description: URL to access the image file kept in external store.
|
||||||
container_format:
|
type: str
|
||||||
description: Container format of the image.
|
min_ram:
|
||||||
returned: success
|
description: Min amount of RAM required for this image.
|
||||||
type: str
|
type: int
|
||||||
direct_url:
|
disk_format:
|
||||||
description: URL to access the image file kept in external store.
|
description: Disk format of the image.
|
||||||
returned: success
|
type: str
|
||||||
type: str
|
file:
|
||||||
min_ram:
|
description: The URL for the virtual machine image file.
|
||||||
description: Min amount of RAM required for this image.
|
type: str
|
||||||
returned: success
|
has_auto_disk_config:
|
||||||
type: int
|
description: If root partition on disk is automatically resized
|
||||||
disk_format:
|
before the instance boots.
|
||||||
description: Disk format of the image.
|
type: bool
|
||||||
returned: success
|
hash_algo:
|
||||||
type: str
|
description: The algorithm used to compute a secure hash of the
|
||||||
file:
|
image data.
|
||||||
description: The URL for the virtual machine image file.
|
type: str
|
||||||
returned: success
|
hash_value:
|
||||||
type: str
|
description: The hexdigest of the secure hash of the image data
|
||||||
has_auto_disk_config:
|
computed using the algorithm whose name is the value of the
|
||||||
description: >
|
os_hash_algo property.
|
||||||
If root partition on disk is automatically resized
|
type: str
|
||||||
before the instance boots.
|
hw_cpu_cores:
|
||||||
returned: success
|
description: Used to pin the virtual CPUs (vCPUs) of instances to
|
||||||
type: bool
|
the host's physical CPU cores (pCPUs).
|
||||||
hash_algo:
|
type: str
|
||||||
description: >
|
hw_cpu_policy:
|
||||||
The algorithm used to compute a secure hash of the
|
description: The hexdigest of the secure hash of the image data.
|
||||||
image data.
|
type: str
|
||||||
returned: success
|
hw_cpu_sockets:
|
||||||
type: str
|
description: Preferred number of sockets to expose to the guest.
|
||||||
hash_value:
|
type: str
|
||||||
description: >
|
hw_cpu_thread_policy:
|
||||||
The hexdigest of the secure hash of the image data
|
description: Defines how hardware CPU threads in a simultaneous
|
||||||
computed using the algorithm whose name is the value of the os_hash_algo property.
|
multithreading-based (SMT) architecture be used.
|
||||||
returned: success
|
type: str
|
||||||
type: str
|
hw_cpu_threads:
|
||||||
hw_cpu_cores:
|
description: The preferred number of threads to expose to the guest.
|
||||||
description: >
|
type: str
|
||||||
Used to pin the virtual CPUs (vCPUs) of instances to
|
hw_disk_bus:
|
||||||
the host's physical CPU cores (pCPUs).
|
description: Specifies the type of disk controller to attach disk
|
||||||
returned: success
|
devices to.
|
||||||
type: str
|
type: str
|
||||||
hw_cpu_policy:
|
hw_machine_type:
|
||||||
description: The hexdigest of the secure hash of the image data.
|
description: Enables booting an ARM system using the
|
||||||
returned: success
|
specified machine type.
|
||||||
type: str
|
type: str
|
||||||
hw_cpu_sockets:
|
hw_qemu_guest_agent:
|
||||||
description: Preferred number of sockets to expose to the guest.
|
description: "A string boolean, which if 'true', QEMU guest agent
|
||||||
returned: success
|
will be exposed to the instance."
|
||||||
type: str
|
type: str
|
||||||
hw_cpu_thread_policy:
|
hw_rng_model:
|
||||||
description: >
|
description: "Adds a random-number generator device to the image's
|
||||||
Defines how hardware CPU threads in a simultaneous
|
instances."
|
||||||
multithreading-based (SMT) architecture be used.
|
type: str
|
||||||
returned: success
|
hw_scsi_model:
|
||||||
type: str
|
description: Enables the use of VirtIO SCSI (virtio-scsi) to
|
||||||
hw_cpu_threads:
|
provide block device access for compute instances.
|
||||||
description: >
|
type: str
|
||||||
The preferred number of threads to expose to the guest.
|
hw_video_model:
|
||||||
returned: success
|
description: The video image driver used.
|
||||||
type: str
|
type: str
|
||||||
hw_disk_bus:
|
hw_video_ram:
|
||||||
description: >
|
description: Maximum RAM for the video image.
|
||||||
Specifies the type of disk controller to attach disk
|
type: str
|
||||||
devices to.
|
hw_vif_model:
|
||||||
returned: success
|
description: Specifies the model of virtual network interface device to
|
||||||
type: str
|
use.
|
||||||
hw_machine_type:
|
type: str
|
||||||
description: >
|
hw_watchdog_action:
|
||||||
Enables booting an ARM system using the
|
description: Enables a virtual hardware watchdog device that
|
||||||
specified machine type.
|
carries out the specified action if the server hangs.
|
||||||
returned: success
|
type: str
|
||||||
type: str
|
hypervisor_type:
|
||||||
hw_qemu_guest_agent:
|
description: The hypervisor type.
|
||||||
description: >
|
type: str
|
||||||
A string boolean, which if "true", QEMU guest agent
|
instance_type_rxtx_factor:
|
||||||
will be exposed to the instance.
|
description: Optional property allows created servers to have a
|
||||||
returned: success
|
different bandwidth cap than that defined in the network
|
||||||
type: str
|
they are attached to.
|
||||||
hw_rng_model:
|
type: str
|
||||||
description: Adds a random-number generator device to the image's instances.
|
instance_uuid:
|
||||||
returned: success
|
description: For snapshot images, this is the UUID of the server
|
||||||
type: str
|
used to create this image.
|
||||||
hw_scsi_model:
|
type: str
|
||||||
description: >
|
is_hidden:
|
||||||
Enables the use of VirtIO SCSI (virtio-scsi) to
|
description: Controls whether an image is displayed in the default
|
||||||
provide block device access for compute instances.
|
image-list response
|
||||||
returned: success
|
type: bool
|
||||||
type: str
|
is_hw_boot_menu_enabled:
|
||||||
hw_video_model:
|
description: Enables the BIOS bootmenu.
|
||||||
description: The video image driver used.
|
type: bool
|
||||||
returned: success
|
is_hw_vif_multiqueue_enabled:
|
||||||
type: str
|
description: Enables the virtio-net multiqueue feature.
|
||||||
hw_video_ram:
|
type: bool
|
||||||
description: Maximum RAM for the video image.
|
kernel_id:
|
||||||
returned: success
|
description: The ID of an image stored in the Image service that
|
||||||
type: str
|
should be used as the kernel when booting an AMI-style
|
||||||
hw_vif_model:
|
image.
|
||||||
description: Specifies the model of virtual network interface device to use.
|
type: str
|
||||||
returned: success
|
locations:
|
||||||
type: str
|
description: A list of URLs to access the image file in external store.
|
||||||
hw_watchdog_action:
|
type: str
|
||||||
description: >
|
metadata:
|
||||||
Enables a virtual hardware watchdog device that
|
description: The location metadata.
|
||||||
carries out the specified action if the server hangs.
|
type: str
|
||||||
returned: success
|
needs_config_drive:
|
||||||
type: str
|
description: Specifies whether the image needs a config drive.
|
||||||
hypervisor_type:
|
type: bool
|
||||||
description: The hypervisor type.
|
needs_secure_boot:
|
||||||
returned: success
|
description: Whether Secure Boot is needed.
|
||||||
type: str
|
type: bool
|
||||||
instance_type_rxtx_factor:
|
os_admin_user:
|
||||||
description: >
|
description: The operating system admin username.
|
||||||
Optional property allows created servers to have a
|
type: str
|
||||||
different bandwidth cap than that defined in the network they are attached to.
|
os_command_line:
|
||||||
returned: success
|
description: The kernel command line to be used by libvirt driver.
|
||||||
type: str
|
type: str
|
||||||
instance_uuid:
|
os_distro:
|
||||||
description: >
|
description: The common name of the operating system distribution
|
||||||
For snapshot images, this is the UUID of the server
|
in lowercase.
|
||||||
used to create this image.
|
type: str
|
||||||
returned: success
|
os_require_quiesce:
|
||||||
type: str
|
description: If true, require quiesce on snapshot via
|
||||||
is_hidden:
|
QEMU guest agent.
|
||||||
description: Controls whether an image is displayed in the default image-list response
|
type: str
|
||||||
returned: success
|
os_shutdown_timeout:
|
||||||
type: bool
|
description: Time for graceful shutdown.
|
||||||
is_hw_boot_menu_enabled:
|
type: str
|
||||||
description: Enables the BIOS bootmenu.
|
os_type:
|
||||||
returned: success
|
description: The operating system installed on the image.
|
||||||
type: bool
|
type: str
|
||||||
is_hw_vif_multiqueue_enabled:
|
os_version:
|
||||||
description: >
|
description: The operating system version as specified by
|
||||||
Enables the virtio-net multiqueue
|
the distributor.
|
||||||
feature.
|
type: str
|
||||||
returned: success
|
owner_id:
|
||||||
type: bool
|
description: The ID of the owner, or project, of the image.
|
||||||
kernel_id:
|
type: str
|
||||||
description: >
|
ramdisk_id:
|
||||||
The ID of an image stored in the Image service that
|
description: The ID of image stored in the Image service that should
|
||||||
should be used as the kernel when booting an AMI-style image.
|
be used as the ramdisk when booting an AMI-style image.
|
||||||
returned: success
|
type: str
|
||||||
type: str
|
schema:
|
||||||
locations:
|
description: URL for the schema describing a virtual machine image.
|
||||||
description: A list of URLs to access the image file in external store.
|
type: str
|
||||||
returned: success
|
store:
|
||||||
type: str
|
description: Glance will attempt to store the disk image data in the
|
||||||
metadata:
|
backing store indicated by the value of the header.
|
||||||
description: The location metadata.
|
type: str
|
||||||
returned: success
|
updated_at:
|
||||||
type: str
|
description: Image updated at timestamp.
|
||||||
needs_config_drive:
|
type: str
|
||||||
description: Specifies whether the image needs a config drive.
|
url:
|
||||||
returned: success
|
description: URL to access the image file kept in external store.
|
||||||
type: bool
|
type: str
|
||||||
needs_secure_boot:
|
virtual_size:
|
||||||
description: Whether Secure Boot is needed.
|
description: The virtual size of the image.
|
||||||
returned: success
|
type: str
|
||||||
type: bool
|
vm_mode:
|
||||||
os_admin_user:
|
description: The virtual machine mode.
|
||||||
description: The operating system admin username.
|
type: str
|
||||||
returned: success
|
vmware_adaptertype:
|
||||||
type: str
|
description: The virtual SCSI or IDE controller used by the
|
||||||
os_command_line:
|
hypervisor.
|
||||||
description: The kernel command line to be used by libvirt driver.
|
type: str
|
||||||
returned: success
|
vmware_ostype:
|
||||||
type: str
|
description: Operating system installed in the image.
|
||||||
os_distro:
|
type: str
|
||||||
description: >
|
filters:
|
||||||
The common name of the operating system distribution
|
description: Additional properties associated with the image.
|
||||||
in lowercase.
|
type: dict
|
||||||
returned: success
|
min_disk:
|
||||||
type: str
|
description: Min amount of disk space required for this image.
|
||||||
os_require_quiesce:
|
type: int
|
||||||
description: >
|
is_protected:
|
||||||
If true, require quiesce on snapshot via
|
description: Image protected flag.
|
||||||
QEMU guest agent.
|
type: bool
|
||||||
returned: success
|
checksum:
|
||||||
type: str
|
description: Checksum for the image.
|
||||||
os_shutdown_timeout:
|
type: str
|
||||||
description: Time for graceful shutdown.
|
owner:
|
||||||
returned: success
|
description: Owner for the image.
|
||||||
type: str
|
type: str
|
||||||
os_type:
|
visibility:
|
||||||
description: The operating system installed on the image.
|
description: Indicates who has access to the image.
|
||||||
returned: success
|
type: str
|
||||||
type: str
|
size:
|
||||||
os_version:
|
description: Size of the image.
|
||||||
description: >
|
type: int
|
||||||
The operating system version as specified by
|
tags:
|
||||||
the distributor.
|
description: List of tags assigned to the image
|
||||||
returned: success
|
type: list
|
||||||
type: str
|
|
||||||
owner_id:
|
|
||||||
description: The ID of the owner, or project, of the image.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
ramdisk_id:
|
|
||||||
description: >
|
|
||||||
The ID of image stored in the Image service that
|
|
||||||
should be used as the ramdisk when booting an AMI-style image.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
schema:
|
|
||||||
description: URL for the schema describing a virtual machine image.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
store:
|
|
||||||
description: >
|
|
||||||
Glance will attempt to store the disk
|
|
||||||
image data in the backing store indicated by the value of the
|
|
||||||
header.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
updated_at:
|
|
||||||
description: Image updated at timestamp.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
url:
|
|
||||||
description: URL to access the image file kept in external store.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
virtual_size:
|
|
||||||
description: The virtual size of the image.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
vm_mode:
|
|
||||||
description: The virtual machine mode.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
vmware_adaptertype:
|
|
||||||
description: >
|
|
||||||
The virtual SCSI or IDE controller used by the
|
|
||||||
hypervisor.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
vmware_ostype:
|
|
||||||
description: Operating system installed in the image.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
filters:
|
|
||||||
description: Additional properties associated with the image.
|
|
||||||
returned: success
|
|
||||||
type: dict
|
|
||||||
min_disk:
|
|
||||||
description: Min amount of disk space required for this image.
|
|
||||||
returned: success
|
|
||||||
type: int
|
|
||||||
is_protected:
|
|
||||||
description: Image protected flag.
|
|
||||||
returned: success
|
|
||||||
type: bool
|
|
||||||
checksum:
|
|
||||||
description: Checksum for the image.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
owner:
|
|
||||||
description: Owner for the image.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
visibility:
|
|
||||||
description: Indicates who has access to the image.
|
|
||||||
returned: success
|
|
||||||
type: str
|
|
||||||
size:
|
|
||||||
description: Size of the image.
|
|
||||||
returned: success
|
|
||||||
type: int
|
|
||||||
tags:
|
|
||||||
description: List of tags assigned to the image
|
|
||||||
returned: success
|
|
||||||
type: list
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
|
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import OpenStackModule
|
||||||
|
|
||||||
|
|
||||||
class ImageInfoModule(OpenStackModule):
|
class ImageInfoModule(OpenStackModule):
|
||||||
|
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
image=dict(),
|
|
||||||
filters=dict(type='dict', aliases=['properties']),
|
filters=dict(type='dict', aliases=['properties']),
|
||||||
|
name=dict(aliases=['image']),
|
||||||
)
|
)
|
||||||
|
|
||||||
module_kwargs = dict(
|
module_kwargs = dict(
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
args = {
|
kwargs = dict((k, self.params[k])
|
||||||
'name_or_id': self.params['image'],
|
for k in ['filters']
|
||||||
'filters': self.params['filters'],
|
if self.params[k] is not None)
|
||||||
}
|
|
||||||
args = {k: v for k, v in args.items() if v is not None}
|
name_or_id = self.params['name']
|
||||||
images = [image.to_dict(computed=False) for image in
|
if name_or_id is not None:
|
||||||
self.conn.search_images(**args)]
|
kwargs['name_or_id'] = name_or_id
|
||||||
self.exit(changed=False, images=images)
|
|
||||||
|
self.exit(changed=False,
|
||||||
|
images=[i.to_dict(computed=False)
|
||||||
|
for i in self.conn.search_images(**kwargs)])
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user