Merge "Fix exception when creating object from file"
This commit is contained in:
commit
e6379e3038
@ -5,7 +5,7 @@
|
|||||||
state: present
|
state: present
|
||||||
name: ansible_container
|
name: ansible_container
|
||||||
|
|
||||||
- name: Create object
|
- name: Create object from data
|
||||||
openstack.cloud.object:
|
openstack.cloud.object:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
state: present
|
state: present
|
||||||
@ -28,6 +28,47 @@
|
|||||||
name: ansible_object
|
name: ansible_object
|
||||||
container: ansible_container
|
container: ansible_container
|
||||||
|
|
||||||
|
- name: Create object from file
|
||||||
|
block:
|
||||||
|
- name: Create temporary data file
|
||||||
|
ansible.builtin.tempfile:
|
||||||
|
register: tmp_file
|
||||||
|
|
||||||
|
- name: Populate data file
|
||||||
|
ansible.builtin.copy:
|
||||||
|
content: "this is a test"
|
||||||
|
dest: "{{ tmp_file.path }}"
|
||||||
|
|
||||||
|
- name: Create object from data file
|
||||||
|
openstack.cloud.object:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: present
|
||||||
|
name: ansible_object
|
||||||
|
filename: "{{ tmp_file.path }}"
|
||||||
|
container: ansible_container
|
||||||
|
register: object
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Remove temporary data file
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ tmp_file.path }}"
|
||||||
|
state: absent
|
||||||
|
when: tmp_file is defined and 'path' in tmp_file
|
||||||
|
|
||||||
|
- name: Assert return values of object module
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- object.object.id == "ansible_object"
|
||||||
|
# allow new fields to be introduced but prevent fields from being removed
|
||||||
|
- expected_fields|difference(object.object.keys())|length == 0
|
||||||
|
|
||||||
|
- name: Delete object
|
||||||
|
openstack.cloud.object:
|
||||||
|
cloud: "{{ cloud }}"
|
||||||
|
state: absent
|
||||||
|
name: ansible_object
|
||||||
|
container: ansible_container
|
||||||
|
|
||||||
- name: Delete container
|
- name: Delete container
|
||||||
openstack.cloud.object_container:
|
openstack.cloud.object_container:
|
||||||
cloud: "{{ cloud }}"
|
cloud: "{{ cloud }}"
|
||||||
|
@ -295,8 +295,11 @@ class ObjectModule(OpenStackModule):
|
|||||||
for k in ['data', 'filename']
|
for k in ['data', 'filename']
|
||||||
if self.params[k] is not None)
|
if self.params[k] is not None)
|
||||||
|
|
||||||
return self.conn.object_store.create_object(container_name, name,
|
object = self.conn.object_store.create_object(container_name, name,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
if not object:
|
||||||
|
object = self._find()
|
||||||
|
return object
|
||||||
|
|
||||||
def _delete(self, object):
|
def _delete(self, object):
|
||||||
container_name = self.params['container']
|
container_name = self.params['container']
|
||||||
|
Loading…
Reference in New Issue
Block a user