---
- name: setup disk offering
  cs_disk_offering:
    name: Small
    state: absent
  register: do
- name: verify setup disk offering
  assert:
    that:
    - do is successful

- name: create disk offering in check mode
  cs_disk_offering:
    name: Small
    disk_size: 10
    storage_tags:
      - eco
      - backup
    storage_type: local
  register: do
  check_mode: true
- name: verify create disk offering in check mode
  assert:
    that:
    - do is changed

- name: create disk offering
  cs_disk_offering:
    name: Small
    disk_size: 10
    storage_tags:
      - eco
      - backup
    storage_type: local
  register: do
- name: verify create disk offering
  assert:
    that:
    - do is changed
    - do.name == "Small"
    - do.storage_tags == ['eco', 'backup']
    - do.storage_type == "local"

- name: create disk offering idempotence
  cs_disk_offering:
    name: Small
    disk_size: 10
    storage_tags:
      - eco
      - backup
    storage_type: local
  register: do
- name: verify create disk offering idempotence
  assert:
    that:
    - do is not changed
    - do.name == "Small"
    - do.storage_tags == ['eco', 'backup']
    - do.storage_type == "local"

- name: update disk offering in check mode
  cs_disk_offering:
    name: Small
    disk_size: 10
    display_text: Small 10GB
  register: do
  check_mode: true
- name: verify create update offering in check mode
  assert:
    that:
    - do is changed
    - do.name == "Small"
    - do.storage_tags == ['eco', 'backup']
    - do.storage_type == "local"

- name: update disk offering
  cs_disk_offering:
    name: Small
    disk_size: 10
    display_text: Small 10GB
  register: do
- name: verify update disk offerin
  assert:
    that:
    - do is changed
    - do.name == "Small"
    - do.display_text == "Small 10GB"
    - do.storage_tags == ['eco', 'backup']
    - do.storage_type == "local"

- name: update disk offering idempotence
  cs_disk_offering:
    name: Small
    disk_size: 10
    display_text: Small 10GB
  register: do
- name: verify update disk offering idempotence
  assert:
    that:
    - do is not changed
    - do.name == "Small"
    - do.display_text == "Small 10GB"
    - do.storage_tags == ['eco', 'backup']
    - do.storage_type == "local"

- name: remove disk offering in check mode
  cs_disk_offering:
    name: Small
    state: absent
  check_mode: true
  register: do
- name: verify remove disk offering in check mode
  assert:
    that:
    - do is changed
    - do.name == "Small"
    - do.display_text == "Small 10GB"
    - do.storage_tags == ['eco', 'backup']
    - do.storage_type == "local"

- name: remove disk offering
  cs_disk_offering:
    name: Small
    state: absent
  register: do
- name: verify remove disk offering
  assert:
    that:
    - do is changed
    - do.name == "Small"
    - do.display_text == "Small 10GB"
    - do.storage_tags == ['eco', 'backup']
    - do.storage_type == "local"

- name: remove disk offering idempotence
  cs_disk_offering:
    name: Small
    state: absent
  register: do
- name: verify remove disk offering idempotence
  assert:
    that:
    - do is not changed
