2015-11-16 18:38:27 +01:00
|
|
|
---
|
|
|
|
- name: setup
|
|
|
|
cs_volume: name={{ cs_resource_prefix }}_vol state=absent
|
|
|
|
register: vol
|
|
|
|
- name: verify setup
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is successful
|
2015-11-16 18:38:27 +01:00
|
|
|
|
|
|
|
- name: setup instance 1
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ test_cs_instance_1 }}"
|
|
|
|
template: "{{ test_cs_instance_template }}"
|
|
|
|
service_offering: "{{ test_cs_instance_offering_1 }}"
|
|
|
|
register: instance
|
|
|
|
- name: verify create instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- instance is successful
|
2015-11-16 18:38:27 +01:00
|
|
|
|
|
|
|
- name: setup instance 2
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ test_cs_instance_2 }}"
|
|
|
|
template: "{{ test_cs_instance_template }}"
|
|
|
|
service_offering: "{{ test_cs_instance_offering_1 }}"
|
|
|
|
register: instance
|
|
|
|
- name: verify create instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- instance is successful
|
2015-11-16 18:38:27 +01:00
|
|
|
|
|
|
|
- name: test fail if missing name
|
|
|
|
action: cs_volume
|
|
|
|
register: vol
|
|
|
|
ignore_errors: true
|
|
|
|
- name: verify results of fail if missing name
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is failed
|
2015-11-16 18:38:27 +01:00
|
|
|
- "vol.msg == 'missing required arguments: name'"
|
|
|
|
|
2017-05-26 12:19:47 +02:00
|
|
|
- name: test create volume in check mode
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
disk_offering: "{{ test_cs_disk_offering_1 }}"
|
|
|
|
size: 20
|
|
|
|
register: vol
|
|
|
|
check_mode: true
|
|
|
|
- name: verify results test create volume in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is changed
|
2017-05-26 12:19:47 +02:00
|
|
|
|
2015-11-16 18:38:27 +01:00
|
|
|
- name: test create volume
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
disk_offering: "{{ test_cs_disk_offering_1 }}"
|
2015-12-05 15:19:43 +01:00
|
|
|
size: 20
|
2015-11-16 18:38:27 +01:00
|
|
|
register: vol
|
|
|
|
- name: verify results test create volume
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is changed
|
2015-12-05 15:19:43 +01:00
|
|
|
- vol.size == 20 * 1024 ** 3
|
2015-11-16 18:38:27 +01:00
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
|
|
|
|
- name: test create volume idempotence
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
disk_offering: "{{ test_cs_disk_offering_1 }}"
|
2015-12-05 15:19:43 +01:00
|
|
|
size: 20
|
2015-11-16 18:38:27 +01:00
|
|
|
register: vol
|
|
|
|
- name: verify results test create volume idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is not changed
|
2015-12-05 15:19:43 +01:00
|
|
|
- vol.size == 20 * 1024 ** 3
|
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
|
2017-05-26 12:19:47 +02:00
|
|
|
- name: test shrink volume in check mode
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
disk_offering: "{{ test_cs_disk_offering_1 }}"
|
|
|
|
size: 10
|
|
|
|
shrink_ok: yes
|
|
|
|
register: vol
|
|
|
|
check_mode: true
|
|
|
|
- name: verify results test create volume in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is changed
|
2017-05-26 12:19:47 +02:00
|
|
|
- vol.size == 20 * 1024 ** 3
|
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
|
2015-12-05 15:19:43 +01:00
|
|
|
- name: test shrink volume
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
disk_offering: "{{ test_cs_disk_offering_1 }}"
|
|
|
|
size: 10
|
|
|
|
shrink_ok: yes
|
|
|
|
register: vol
|
|
|
|
- name: verify results test create volume
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is changed
|
2015-12-05 15:19:43 +01:00
|
|
|
- vol.size == 10 * 1024 ** 3
|
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
|
|
|
|
- name: test shrink volume idempotence
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
disk_offering: "{{ test_cs_disk_offering_1 }}"
|
|
|
|
size: 10
|
|
|
|
shrink_ok: yes
|
|
|
|
register: vol
|
|
|
|
- name: verify results test create volume
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is not changed
|
2015-12-05 15:19:43 +01:00
|
|
|
- vol.size == 10 * 1024 ** 3
|
2015-11-16 18:38:27 +01:00
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
|
2017-05-26 12:19:47 +02:00
|
|
|
- name: test attach volume in check mode
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
vm: "{{ test_cs_instance_1 }}"
|
|
|
|
state: attached
|
|
|
|
register: vol
|
|
|
|
check_mode: true
|
|
|
|
- name: verify results test attach volume in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is changed
|
2017-05-26 12:19:47 +02:00
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
- vol.attached is not defined
|
|
|
|
|
2015-11-16 18:38:27 +01:00
|
|
|
- name: test attach volume
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
vm: "{{ test_cs_instance_1 }}"
|
|
|
|
state: attached
|
|
|
|
register: vol
|
|
|
|
- name: verify results test attach volume
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is changed
|
2015-11-16 18:38:27 +01:00
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
- vol.vm == "{{ test_cs_instance_1 }}"
|
|
|
|
- vol.attached is defined
|
|
|
|
|
|
|
|
- name: test attach volume idempotence
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
vm: "{{ test_cs_instance_1 }}"
|
|
|
|
state: attached
|
|
|
|
register: vol
|
|
|
|
- name: verify results test attach volume idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is not changed
|
2015-11-16 18:38:27 +01:00
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
- vol.vm == "{{ test_cs_instance_1 }}"
|
|
|
|
- vol.attached is defined
|
|
|
|
|
2017-05-26 12:19:47 +02:00
|
|
|
- name: test attach attached volume to another vm in check mdoe
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
vm: "{{ test_cs_instance_2 }}"
|
|
|
|
state: attached
|
|
|
|
register: vol
|
|
|
|
check_mode: true
|
|
|
|
- name: verify results test attach attached volume to another vm in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is changed
|
2017-05-26 12:19:47 +02:00
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
- vol.vm == "{{ test_cs_instance_1 }}"
|
|
|
|
- vol.attached is defined
|
|
|
|
|
2015-11-16 18:38:27 +01:00
|
|
|
- name: test attach attached volume to another vm
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
vm: "{{ test_cs_instance_2 }}"
|
|
|
|
state: attached
|
|
|
|
register: vol
|
|
|
|
- name: verify results test attach attached volume to another vm
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is changed
|
2015-11-16 18:38:27 +01:00
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
- vol.vm == "{{ test_cs_instance_2 }}"
|
|
|
|
- vol.attached is defined
|
|
|
|
|
|
|
|
- name: test attach attached volume to another vm idempotence
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
vm: "{{ test_cs_instance_2 }}"
|
|
|
|
state: attached
|
|
|
|
register: vol
|
|
|
|
- name: verify results test attach attached volume to another vm idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is not changed
|
2015-11-16 18:38:27 +01:00
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
- vol.vm == "{{ test_cs_instance_2 }}"
|
|
|
|
- vol.attached is defined
|
|
|
|
|
2017-05-26 12:19:47 +02:00
|
|
|
- name: test detach volume in check mode
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
state: detached
|
|
|
|
register: vol
|
|
|
|
check_mode: true
|
|
|
|
- name: verify results test detach volume in check mdoe
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is changed
|
2017-05-26 12:19:47 +02:00
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
- vol.attached is defined
|
|
|
|
|
2015-11-16 18:38:27 +01:00
|
|
|
- name: test detach volume
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
state: detached
|
|
|
|
register: vol
|
|
|
|
- name: verify results test detach volume
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is changed
|
2015-11-16 18:38:27 +01:00
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
- vol.attached is undefined
|
|
|
|
|
|
|
|
- name: test detach volume idempotence
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
state: detached
|
|
|
|
register: vol
|
|
|
|
- name: verify results test detach volume idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is not changed
|
2015-11-16 18:38:27 +01:00
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
- vol.attached is undefined
|
|
|
|
|
2017-05-26 12:19:47 +02:00
|
|
|
- name: test delete volume in check mode
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
state: absent
|
|
|
|
register: vol
|
|
|
|
check_mode: true
|
|
|
|
- name: verify results test create volume in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is changed
|
2017-05-26 12:19:47 +02:00
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
|
2015-11-16 18:38:27 +01:00
|
|
|
- name: test delete volume
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
state: absent
|
|
|
|
register: vol
|
|
|
|
- name: verify results test create volume
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is changed
|
2015-11-16 18:38:27 +01:00
|
|
|
- vol.name == "{{ cs_resource_prefix }}_vol"
|
|
|
|
|
|
|
|
- name: test delete volume idempotence
|
|
|
|
cs_volume:
|
|
|
|
name: "{{ cs_resource_prefix }}_vol"
|
|
|
|
state: absent
|
|
|
|
register: vol
|
|
|
|
- name: verify results test delete volume idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- vol is not changed
|
2015-11-16 18:38:27 +01:00
|
|
|
|
|
|
|
- name: cleanup instance 1
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ test_cs_instance_1 }}"
|
|
|
|
state: absent
|
|
|
|
register: instance
|
|
|
|
- name: verify create instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- instance is successful
|
2015-11-16 18:38:27 +01:00
|
|
|
|
|
|
|
- name: cleanup instance 2
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ test_cs_instance_2 }}"
|
|
|
|
state: absent
|
|
|
|
register: instance
|
|
|
|
- name: verify create instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- instance is successful
|