Skip to content
Snippets Groups Projects
Commit f0cb7f68 authored by Rafael Castillo's avatar Rafael Castillo Committed by Jakob Meng
Browse files

Update quota for 2.0.0

Add a test role to validate module functionality

Replace calls to the sdk cloud layer to use the proxy layer.

Update module parameters to use names matching the sdk. Keep aliases for
old values.

Remove _scrub_results, no longer necessary with proxy layer.

Move check mode outside of main flow to keep the module readable.

Refactor code to handle fields that should be ignored.

Simplify return value from _system_state_change_details.

Inline calls to fetch existing quotas.

Remove metaprogramming calls to cloud layer methods, as the proxy layer
doesn't have the same consistent API.

Remove handling for case where neutron throws exception when unsetting
quotas that aren't set. This is validated in the test role.

Ensure return values are dicts.

Replace exception handler with conditionals which allows us to drop the
dependency on keystoneauth1 library and is much more correct than
catching all exceptions and always printing the same error even on
unrelated exceptions.

Story: 2010099
Task: 45654

Change-Id: I5eda8e476a4e779382e6c63f5982504d5951501d
parent 6ab3d766
No related branches found
No related tags found
No related merge requests found
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
port port
project project
project_info project_info
quota
recordset recordset
role_assignment role_assignment
router router
......
test_project: ansible_project
quota_name_frag:
cloud: "{{ cloud }}"
name: "{{ test_project }}"
test_network_quota:
floating_ips: 5
networks: 50
ports: 300
rbac_policies: 5
routers: 5
security_group_rules: 5
security_groups: 5
subnet_pools: 5
subnets: 5
test_volume_quota:
backup_gigabytes: 500
backups: 5
gigabytes: 500
groups: 1
per_volume_gigabytes: 10
snapshots: 5
volumes: 5
test_compute_quota:
cores: 5
injected_file_content_bytes: 5
injected_file_path_bytes: 5
injected_files: 5
instances: 5
key_pairs: 5
metadata_items: 5
ram: 5
server_group_members: 5
server_groups: 5
---
- name: Create test project
openstack.cloud.project:
cloud: "{{ cloud }}"
state: present
name: "{{ test_project }}"
- name: Clear quotas before tests
openstack.cloud.quota:
cloud: "{{ cloud }}"
state: absent
name: "{{ test_project }}"
register: default_quotas
- name: Set network quota
openstack.cloud.quota: "{{ test_network_quota | combine(quota_name_frag)}}"
register: quotas
- name: Assert changed
assert:
that: quotas is changed
- name: Assert field values
assert:
that: quotas.quotas.network[item.key] == item.value
loop: "{{ test_network_quota | dict2items }}"
- name: Set network quota again
openstack.cloud.quota: "{{ test_network_quota | combine(quota_name_frag)}}"
register: quotas
- name: Assert not changed
assert:
that: quotas is not changed
- name: Set volume quotas
openstack.cloud.quota: "{{ test_volume_quota | combine(quota_name_frag)}}"
register: quotas
- name: Assert changed
assert:
that: quotas is changed
- name: Assert field values
assert:
that: quotas.quotas.volume[item.key] == item.value
loop: "{{ test_volume_quota | dict2items }}"
- name: Set volume quotas again
openstack.cloud.quota: "{{ test_volume_quota | combine(quota_name_frag)}}"
register: quotas
- name: Assert not changed
assert:
that: quotas is not changed
- name: Set compute quotas
openstack.cloud.quota: "{{ test_compute_quota | combine(quota_name_frag)}}"
register: quotas
- name: Assert changed
assert:
that: quotas is changed
- name: Assert field values
assert:
that: quotas.quotas.compute[item.key] == item.value
loop: "{{ test_compute_quota | dict2items }}"
- name: Set compute quotas again
openstack.cloud.quota: "{{ test_compute_quota | combine(quota_name_frag)}}"
register: quotas
- name: Unset all quotas
openstack.cloud.quota:
cloud: "{{ cloud }}"
name: "{{ test_project }}"
state: absent
register: quotas
- name: Assert defaults restore
assert:
that: quotas.quotas == default_quotas.quotas
- name: Set all quotas at once
openstack.cloud.quota:
"{{ [test_network_quota, test_volume_quota, test_compute_quota,
quota_name_frag] | combine }}"
register: quotas
- name: Assert changed
assert:
that: quotas is changed
- name: Assert volume values
assert:
that: quotas.quotas.volume[item.key] == item.value
loop: "{{ test_volume_quota | dict2items }}"
- name: Assert network values
assert:
that: quotas.quotas.network[item.key] == item.value
loop: "{{ test_network_quota | dict2items }}"
- name: Assert compute values
assert:
that: quotas.quotas.compute[item.key] == item.value
loop: "{{ test_compute_quota | dict2items }}"
- name: Set all quotas at once again
openstack.cloud.quota:
"{{ [test_network_quota, test_volume_quota, test_compute_quota,
quota_name_frag] | combine }}"
register: quotas
- name: Assert not changed
assert:
that: quotas is not changed
- name: Unset all quotas
openstack.cloud.quota:
cloud: "{{ cloud }}"
name: "{{ test_project }}"
state: absent
register: quotas
- name: Delete test project
openstack.cloud.project:
cloud: "{{ cloud }}"
state: absent
name: "{{ test_project }}"
...@@ -69,3 +69,4 @@ ...@@ -69,3 +69,4 @@
- role: loadbalancer - role: loadbalancer
tags: loadbalancer tags: loadbalancer
- { role: floating_ip, tags: floating_ip } - { role: floating_ip, tags: floating_ip }
- { role: quota, tags: quota }
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment