2015-08-23 20:48:32 +00:00
|
|
|
---
|
|
|
|
- name: setup instance
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-snapshot"
|
|
|
|
template: "{{ test_cs_instance_template }}"
|
|
|
|
service_offering: "{{ test_cs_instance_offering_1 }}"
|
|
|
|
register: instance
|
|
|
|
- name: verify create instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|
2015-08-23 20:48:32 +00:00
|
|
|
|
|
|
|
- name: ensure no snapshot exists
|
|
|
|
cs_vmsnapshot:
|
|
|
|
name: "{{ cs_resource_prefix }}_snapshot"
|
|
|
|
vm: "{{ cs_resource_prefix }}-vm-snapshot"
|
|
|
|
state: absent
|
|
|
|
register: snap
|
|
|
|
- name: verify setup
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- snap is successful
|
2015-08-23 20:48:32 +00:00
|
|
|
|
|
|
|
- name: test fail if missing name
|
|
|
|
action: cs_vmsnapshot
|
|
|
|
register: snap
|
|
|
|
ignore_errors: true
|
|
|
|
- name: verify results of fail if missing params
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- snap is failed
|
2017-05-09 11:37:08 +00:00
|
|
|
- 'snap.msg.startswith("missing required arguments: ")'
|
2015-08-23 20:48:32 +00:00
|
|
|
|
2017-05-26 10:19:47 +00:00
|
|
|
- name: test create snapshot in check mode
|
|
|
|
cs_vmsnapshot:
|
|
|
|
name: "{{ cs_resource_prefix }}_snapshot"
|
|
|
|
vm: "{{ cs_resource_prefix }}-vm-snapshot"
|
|
|
|
snapshot_memory: yes
|
|
|
|
register: snap
|
|
|
|
check_mode: true
|
|
|
|
- name: verify test create snapshot in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- snap is changed
|
2017-05-26 10:19:47 +00:00
|
|
|
|
2015-08-23 20:48:32 +00:00
|
|
|
- name: test create snapshot
|
|
|
|
cs_vmsnapshot:
|
|
|
|
name: "{{ cs_resource_prefix }}_snapshot"
|
|
|
|
vm: "{{ cs_resource_prefix }}-vm-snapshot"
|
|
|
|
snapshot_memory: yes
|
|
|
|
register: snap
|
|
|
|
- name: verify test create snapshot
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- snap is changed
|
2015-08-23 20:48:32 +00:00
|
|
|
- snap.display_name == "{{ cs_resource_prefix }}_snapshot"
|
|
|
|
|
|
|
|
- name: test create snapshot idempotence
|
|
|
|
cs_vmsnapshot:
|
|
|
|
name: "{{ cs_resource_prefix }}_snapshot"
|
|
|
|
vm: "{{ cs_resource_prefix }}-vm-snapshot"
|
|
|
|
snapshot_memory: yes
|
|
|
|
register: snap
|
|
|
|
- name: verify test create snapshot idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- snap is not changed
|
2015-08-23 20:48:32 +00:00
|
|
|
- snap.display_name == "{{ cs_resource_prefix }}_snapshot"
|
|
|
|
|
2017-05-26 10:19:47 +00:00
|
|
|
- name: test revert snapshot in check mode
|
|
|
|
cs_vmsnapshot:
|
|
|
|
name: "{{ cs_resource_prefix }}_snapshot"
|
|
|
|
vm: "{{ cs_resource_prefix }}-vm-snapshot"
|
|
|
|
state: revert
|
|
|
|
register: snap
|
|
|
|
check_mode: true
|
|
|
|
- name: verify test revert snapshot in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- snap is changed
|
2017-05-26 10:19:47 +00:00
|
|
|
- snap.display_name == "{{ cs_resource_prefix }}_snapshot"
|
|
|
|
|
2017-08-05 08:34:17 +00:00
|
|
|
- name: test fail revert unknown snapshot
|
|
|
|
cs_vmsnapshot:
|
|
|
|
name: "{{ cs_resource_prefix }}_snapshot_unknown"
|
|
|
|
vm: "{{ cs_resource_prefix }}-vm-snapshot"
|
|
|
|
state: revert
|
|
|
|
register: snap
|
|
|
|
ignore_errors: true
|
|
|
|
- name: verify test fail revert unknown snapshot
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- snap is failed
|
2017-08-05 08:34:17 +00:00
|
|
|
- snap.msg == "snapshot not found, could not revert VM"
|
|
|
|
|
2015-08-23 20:48:32 +00:00
|
|
|
- name: test revert snapshot
|
|
|
|
cs_vmsnapshot:
|
|
|
|
name: "{{ cs_resource_prefix }}_snapshot"
|
|
|
|
vm: "{{ cs_resource_prefix }}-vm-snapshot"
|
|
|
|
state: revert
|
|
|
|
register: snap
|
|
|
|
- name: verify test revert snapshot
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- snap is changed
|
2015-08-23 20:48:32 +00:00
|
|
|
- snap.display_name == "{{ cs_resource_prefix }}_snapshot"
|
|
|
|
|
2017-05-26 10:19:47 +00:00
|
|
|
- name: test remove snapshot in check mode
|
|
|
|
cs_vmsnapshot:
|
|
|
|
name: "{{ cs_resource_prefix }}_snapshot"
|
|
|
|
vm: "{{ cs_resource_prefix }}-vm-snapshot"
|
|
|
|
state: absent
|
|
|
|
register: snap
|
|
|
|
check_mode: true
|
|
|
|
- name: verify test remove snapshot in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- snap is changed
|
2017-05-26 10:19:47 +00:00
|
|
|
- snap.display_name == "{{ cs_resource_prefix }}_snapshot"
|
|
|
|
|
2015-08-23 20:48:32 +00:00
|
|
|
- name: test remove snapshot
|
|
|
|
cs_vmsnapshot:
|
|
|
|
name: "{{ cs_resource_prefix }}_snapshot"
|
|
|
|
vm: "{{ cs_resource_prefix }}-vm-snapshot"
|
|
|
|
state: absent
|
|
|
|
register: snap
|
|
|
|
- name: verify test remove snapshot
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- snap is changed
|
2015-08-23 20:48:32 +00:00
|
|
|
- snap.display_name == "{{ cs_resource_prefix }}_snapshot"
|
|
|
|
|
|
|
|
- name: test remove snapshot idempotence
|
|
|
|
cs_vmsnapshot:
|
|
|
|
name: "{{ cs_resource_prefix }}_snapshot"
|
|
|
|
vm: "{{ cs_resource_prefix }}-vm-snapshot"
|
|
|
|
state: absent
|
|
|
|
register: snap
|
|
|
|
- name: verify test remove snapshot idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- snap is not changed
|
2015-08-23 20:48:32 +00:00
|
|
|
|
|
|
|
- name: cleanup instance
|
|
|
|
cs_instance:
|
|
|
|
name: "{{ cs_resource_prefix }}-vm-snapshot"
|
|
|
|
state: expunged
|
|
|
|
register: instance
|
|
|
|
- name: verify destroy instance
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- instance is successful
|