diff --git a/tasks/create_per_cloud_profiles_resources.yml b/tasks/create_per_cloud_profiles_resources.yml index 2be5d5a..b8f631f 100644 --- a/tasks/create_per_cloud_profiles_resources.yml +++ b/tasks/create_per_cloud_profiles_resources.yml @@ -44,6 +44,15 @@ tags: - user_roles +- name: "Processing quotas resources for profile {{ item_profile }}" + include: create_quota.yml + with_items: "{{ profiles|selectattr('name', 'equalto', item_profile)|map(attribute='quotas')|list }}" + loop_control: + loop_var: item_quota + when: "{{ 'quotas' in profiles|selectattr('name', 'equalto', item_profile)|list|first }}" + tags: + - quotas + - name: "Processing networks resources for profile {{ item_profile }}" include: create_network.yml with_items: "{{ profiles|selectattr('name', 'equalto', item_profile)|map(attribute='networks')|list }}" diff --git a/tasks/create_per_cloud_resources.yml b/tasks/create_per_cloud_resources.yml index 7ef4ceb..b8cec5a 100644 --- a/tasks/create_per_cloud_resources.yml +++ b/tasks/create_per_cloud_resources.yml @@ -39,6 +39,14 @@ tags: - user_roles +- name: "Processing per cloud quotas" + include: create_quota.yml + with_items: "{{ item_cloud.quotas|default([]) }}" + loop_control: + loop_var: item_quota + tags: + - quotas + - name: "Processing per cloud networks" include: create_network.yml with_items: "{{ item_cloud.networks|default([]) }}" diff --git a/tasks/create_quota.yml b/tasks/create_quota.yml new file mode 100644 index 0000000..b9f7450 --- /dev/null +++ b/tasks/create_quota.yml @@ -0,0 +1,8 @@ +--- +- name: "Processing quotas for project {{ item_quota.name }}" + command: openstack quota set --"{{ item.key }}" "{{ item.value }}" "{{ item_quota.name }}" + environment: + OS_CLOUD: "{{ item_cloud.name }}" + OS_REGION_NAME: "{{ item_cloud.region_name|default('')}}" + with_dict: "{{ item_quota }}" + when: item.key != 'name' diff --git a/tests/resources.yml b/tests/resources.yml index ce5c2b2..a9acceb 100644 --- a/tests/resources.yml +++ b/tests/resources.yml @@ -34,6 +34,11 @@ clouds: - role: test_role user: test_user project: test_project + quotas: + - name: test_project + cores: 2 + ram: 4096 + ports: 10 - name: devstack servers: diff --git a/tests/test.yaml b/tests/test.yaml index a1e982c..93b374a 100644 --- a/tests/test.yaml +++ b/tests/test.yaml @@ -61,6 +61,14 @@ - name: Assert test_user has test_role role assigned assert: { that: result.stdout == 'test_role' } + - name: Querying for test_project quotas + command: openstack --os-cloud devstack-admin quota show -c cores -f value test_project + register: result + changed_when: False + + - name: Assert test_project has quotas assigned + assert: { that: result.stdout == '2' } + - name: Querying for test_server_a server command: openstack --os-cloud devstack-admin server show test_server_a register: result