Skip to content

Commit

Permalink
Fix lints for acps
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavbansal29 committed Dec 9, 2024
1 parent 66936bc commit a9b871e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 56 deletions.
38 changes: 19 additions & 19 deletions tests/integration/targets/ntnx_acps/tasks/create_acps.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
- name: Generate random name
ansible.builtin.set_fact:
random_name: "{{query('community.general.random_string',numbers=false, special=false,length=12)}}"
random_name: "{{ query('community.general.random_string', numbers=false, special=false, length=12) }}"

- name: Set acp name
ansible.builtin.set_fact:
acp1_name: "{{random_name[0]}}1"
acp2_name: "{{random_name[0]}}2"
acp3_name: "{{random_name[0]}}3"
acp4_name: "{{random_name[0]}}4"
acp5_name: "{{random_name[0]}}5"
acp1_name: "{{ random_name[0] }}1"
acp2_name: "{{ random_name[0] }}2"
acp3_name: "{{ random_name[0] }}3"
acp4_name: "{{ random_name[0] }}4"
acp5_name: "{{ random_name[0] }}5"
- name: Create min ACP
ntnx_acps:
state: present
wait: true
name: "{{acp1_name}}"
name: "{{ acp1_name }}"
role:
uuid: "{{ acp.role.uuid }}"
register: result
Expand All @@ -27,15 +27,15 @@
- result.response is defined
- result.changed == false
- result.failed == false
- result.response.spec.name == "{{acp1_name}}"
- result.response.spec.name == "{{ acp1_name }}"
fail_msg: " Unable to create Min ACP with check mode "
success_msg: " Min ACP with check mode passed"
# ##########################################################
- name: Create min ACP
ntnx_acps:
state: present
wait: true
name: "{{acp2_name}}"
name: "{{ acp2_name }}"
role:
uuid: "{{ acp.role.uuid }}"
check_mode: false
Expand All @@ -47,18 +47,18 @@
that:
- result.response is defined
- result.response.status.state == 'COMPLETE'
- result.response.spec.name == "{{acp2_name}}"
- result.response.spec.name == "{{ acp2_name }}"
fail_msg: " Unable to create Min ACP "
success_msg: " Min ACP created successfully "

- name: Set acp uuid to delete later
ansible.builtin.set_fact:
todelete: "{{ todelete + [ result.acp_uuid ] }}"
todelete: "{{ todelete + [result.acp_uuid] }}"
##########################################################
- name: Create ACP with user reference
ntnx_acps:
state: present
name: "{{acp5_name}}"
name: "{{ acp5_name }}"
role:
uuid: "{{ acp.role.uuid }}"
user_uuids:
Expand All @@ -71,20 +71,20 @@
that:
- result.response is defined
- result.response.status.state == 'COMPLETE'
- result.response.spec.name == "{{acp5_name}}"
- result.response.spec.name == "{{ acp5_name }}"
- result.response.status.resources.role_reference.uuid == "{{ acp.role.uuid }}"
- result.response.status.resources.user_reference_list.0.uuid == "{{ acp.user_uuid }}"
fail_msg: " Unable to Create ACP with user reference "
success_msg: " ACP with user reference created successfully "

- name: Set acp uuid to delete later
ansible.builtin.set_fact:
todelete: "{{ todelete + [ result.acp_uuid ] }}"
todelete: "{{ todelete + [result.acp_uuid] }}"
##########################################################
- name: Create ACP with user ad user group reference
ntnx_acps:
state: present
name: "{{acp3_name}}"
name: "{{ acp3_name }}"
role:
uuid: "{{ acp.role.uuid }}"
user_uuids:
Expand All @@ -99,7 +99,7 @@
that:
- result.response is defined
- result.response.status.state == 'COMPLETE'
- result.response.spec.name == "{{acp3_name}}"
- result.response.spec.name == "{{ acp3_name }}"
- result.response.status.resources.role_reference.uuid == "{{ acp.role.uuid }}"
- result.response.status.resources.user_reference_list.0.uuid == "{{ acp.user_uuid }}"
- result.response.status.resources.user_group_reference_list.0.uuid == "{{ acp.user_group_uuid }}"
Expand All @@ -108,12 +108,12 @@

- name: Set acp uuid to delete later
ansible.builtin.set_fact:
todelete: "{{ todelete + [ result.acp_uuid ] }}"
todelete: "{{ todelete + [result.acp_uuid] }}"
##########################################################
- name: Create ACP with all specfactions
ntnx_acps:
state: present
name: "{{acp4_name}}"
name: "{{ acp4_name }}"
role:
uuid: "{{ acp.role.uuid }}"
user_uuids:
Expand Down Expand Up @@ -179,7 +179,7 @@

- name: Set acp uuid to delete later
ansible.builtin.set_fact:
todelete: "{{ todelete + [ result.acp_uuid ] }}"
todelete: "{{ todelete + [result.acp_uuid] }}"
##########################################################
- name: Delete all created acps
ntnx_acps:
Expand Down
13 changes: 5 additions & 8 deletions tests/integration/targets/ntnx_acps/tasks/delete_acp.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
- name: Generate random name
ansible.builtin.set_fact:
random_name: "{{query('community.general.random_string',numbers=false, special=false,length=12)}}"
random_name: "{{ query('community.general.random_string', numbers=false, special=false, length=12) }}"

- name: Set acp name
ansible.builtin.set_fact:
acp1_name: "{{random_name[0]}}1"
acp1_name: "{{ random_name[0] }}1"

- name: Create ACP with all specfactions
ntnx_acps:
state: present
name: "{{acp1_name}}"
name: "{{ acp1_name }}"
role:
uuid: "{{ acp.role.uuid }}"
user_uuids:
Expand All @@ -19,15 +19,13 @@
- "{{ acp.user_group_uuid }}"
filters:
- scope_filter:
-
lhs: PROJECT
- lhs: PROJECT
operator: IN
rhs:
uuid_list:
- "{{ project.uuid }}"
entity_filter:
-
lhs: ALL
- lhs: ALL
operator: IN
rhs:
collection: ALL
Expand All @@ -51,7 +49,6 @@
fail_msg: " Unable to Create ACP all specfactions "
success_msg: " ACP with all specfactions created successfully "


- name: Delete acp
ntnx_acps:
state: absent
Expand Down
16 changes: 8 additions & 8 deletions tests/integration/targets/ntnx_acps/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
nutanix_password: "{{ password }}"
validate_certs: "{{ validate_certs }}"
block:
- name: Import create_acps.yml
ansible.builtin.import_tasks: "create_acps.yml"
- name: Import delete_acp.yml
ansible.builtin.import_tasks: "delete_acp.yml"
- name: Import update_acps.yml
ansible.builtin.import_tasks: "update_acps.yml"
- name: Import negative_scenarios.yml
ansible.builtin.import_tasks: "negative_scenarios.yml"
- name: Import create_acps.yml
ansible.builtin.import_tasks: "create_acps.yml"
- name: Import delete_acp.yml
ansible.builtin.import_tasks: "delete_acp.yml"
- name: Import update_acps.yml
ansible.builtin.import_tasks: "update_acps.yml"
- name: Import negative_scenarios.yml
ansible.builtin.import_tasks: "negative_scenarios.yml"
34 changes: 13 additions & 21 deletions tests/integration/targets/ntnx_acps/tasks/update_acps.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

- name: Setting acp name variables
ansible.builtin.set_fact:
acp_name: "{{ query('community.general.random_string', upper=false, numbers=false, special=false)[0] }}"
Expand All @@ -9,34 +8,34 @@
ntnx_acps:
state: present
wait: true
name: "{{acp_name}}"
name: "{{ acp_name }}"
role:
uuid: '{{ acp.role.uuid }}'
uuid: "{{ acp.role.uuid }}"
register: setup_acp

- name: Creation Status
ansible.builtin.assert:
that:
- setup_acp.response is defined
- setup_acp.response.status.state == 'COMPLETE'
- setup_acp.response.spec.name == "{{acp_name}}"
- setup_acp.response.spec.name == "{{ acp_name }}"
- setup_acp.response.status.resources.role_reference.uuid == "{{ acp.role.uuid }}"
fail_msg: "Unable to create ACP for update tests"
success_msg: "ACP created successfully for update tests"

- name: Set acp uuid to delete later
ansible.builtin.set_fact:
todelete: '{{ todelete + [ setup_acp["response"]["metadata"]["uuid"] ] }}'
todelete: '{{ todelete + [setup_acp["response"]["metadata"]["uuid"]] }}'

############################################# UPDATE TESTS ########################################

- name: Check idempotency
ntnx_acps:
state: present
acp_uuid: "{{ setup_acp.acp_uuid }}"
name: "{{acp_name}}"
name: "{{ acp_name }}"
role:
uuid: '{{ acp.role.uuid }}'
uuid: "{{ acp.role.uuid }}"
register: result

- name: Check idempotency status
Expand All @@ -54,19 +53,17 @@
ntnx_acps:
state: present
acp_uuid: "{{ setup_acp.acp_uuid }}"
name: "{{acp_name_updated}}"
name: "{{ acp_name_updated }}"
desc: "description after update"
filters:
- scope_filter:
-
lhs: PROJECT
- lhs: PROJECT
operator: IN
rhs:
uuid_list:
- "{{ project.uuid }}"
entity_filter:
-
lhs: ALL
- lhs: ALL
operator: IN
rhs:
collection: ALL
Expand All @@ -77,7 +74,7 @@
that:
- result.response is defined
- result.response.status.state == 'COMPLETE'
- result.response.status.name == "{{acp_name_updated}}"
- result.response.status.name == "{{ acp_name_updated }}"
- result.response.status.description == 'description after update'
- result.response.status.resources.filter_list.context_list.0.entity_filter_expression_list.0.operator == "IN"
- result.response.status.resources.filter_list.context_list.0.entity_filter_expression_list.0.left_hand_side.entity_type == "ALL"
Expand All @@ -88,26 +85,23 @@
fail_msg: "Fail: Unable to update ACP"
success_msg: "Pass: ACP with given update spec updated successfully"


########################################################################################

- name: Update name, desc and filters
ntnx_acps:
state: present
acp_uuid: "{{ setup_acp.acp_uuid }}"
name: "{{acp_name_updated}}"
name: "{{ acp_name_updated }}"
desc: "description after update"
filters:
- scope_filter:
-
lhs: PROJECT
- lhs: PROJECT
operator: IN
rhs:
uuid_list:
- "{{ project.uuid }}"
entity_filter:
-
lhs: ALL
- lhs: ALL
operator: IN
rhs:
collection: ALL
Expand All @@ -122,7 +116,6 @@
fail_msg: "Fail: ACP got updated"
success_msg: "Pass: ACP update skipped successfully due to no changes in spec"


########################################### Cleanup ###################################################

- name: Cleanup created entities
Expand All @@ -133,7 +126,6 @@
loop: "{{ todelete }}"
ignore_errors: true


- name: Check listing status
ansible.builtin.assert:
that:
Expand Down

0 comments on commit a9b871e

Please sign in to comment.