Skip to content

Commit

Permalink
[ignore] Changed the useg_subnet attribute logic in the mso_schema_si…
Browse files Browse the repository at this point in the history
…te_anp_epg_useg_attribute.py
  • Loading branch information
sajagana authored and lhercot committed Jan 17, 2024
1 parent b68e063 commit a0a129a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 23 deletions.
12 changes: 7 additions & 5 deletions plugins/modules/mso_schema_site_anp_epg_useg_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
description:
- The uSeg Subnet can only be used when the I(attribute_type) is IP.
- Use C(false) to set the custom uSeg Subnet IP address to the uSeg Attribute.
- Use C(true) to set the uSeg Subnet IP address to 0.0.0.0.
- Use C(true) to set the default uSeg Subnet IP address 0.0.0.0.
type: bool
state:
description:
Expand Down Expand Up @@ -249,11 +249,13 @@ def main():
payload = dict(name=name, displayName=name, description=description, type=EPG_U_SEG_ATTR_TYPE_MAP[attribute_type], value=value)

if attribute_type == "ip":
if useg_subnet is False:
payload["fvSubnet"] = True
else:
payload["fvSubnet"] = False
if useg_subnet:
if value != "" and value != "0.0.0.0" and value is not None:
mso.fail_json(msg="The value of uSeg subnet IP should be an empty string or 0.0.0.0, when the useg_subnet is set to true.")
payload["fvSubnet"] = useg_subnet
payload["value"] = "0.0.0.0"
else:
payload["fvSubnet"] = useg_subnet

mso.sanitize(payload, collate=True)

Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/mso_schema_template_anp_epg_useg_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ def main():
if attribute_type == "ip":
if useg_subnet:
if value != "" and value != "0.0.0.0" and value is not None:
mso.fail_json(msg="The value should be empty string or 0.0.0.0, when the useg_subnet is true.")
payload["fvSubnet"] = True
mso.fail_json(msg="The value of uSeg subnet IP should be an empty string or 0.0.0.0, when the useg_subnet is set to true.")
payload["fvSubnet"] = useg_subnet
payload["value"] = "0.0.0.0"
else:
payload["fvSubnet"] = useg_subnet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,24 +171,36 @@
ignore_errors: true
register: ans_test_uSeg_2_nt

- name: Invalid test - ans_test_uSeg_2 present - attribute_type - ip, useg_subnet - true, with value
cisco.mso.mso_schema_site_anp_epg_useg_attribute:
<<: *useg_attribute_present
name: ans_test_uSeg_2
attribute_type: ip
useg_subnet: true
value: 1.2.3.4
ignore_errors: true
register: ans_test_uSeg_2_nt1

- name: ans_test_uSeg_2 present - attribute_type - ip, useg_subnet - false, with value - check mode
cisco.mso.mso_schema_site_anp_epg_useg_attribute: &ans_test_uSeg_2_cm_present
<<: *useg_attribute_present
name: ans_test_uSeg_2
attribute_type: ip
useg_subnet: false
value: 11.22.33.44/24
value: 11.22.33.44
check_mode: true
register: ans_test_uSeg_2_cm_present

- name: ans_test_uSeg_2 present - attribute_type - ip, useg_subnet - false, with value - normal mode
cisco.mso.mso_schema_site_anp_epg_useg_attribute: &ans_test_uSeg_2_nm_present
<<: *ans_test_uSeg_2_cm_present
output_level: debug
register: ans_test_uSeg_2_nm_present

- name: ans_test_uSeg_2 present - attribute_type - ip, useg_subnet - false, with value - normal mode again
cisco.mso.mso_schema_site_anp_epg_useg_attribute:
<<: *ans_test_uSeg_2_nm_present
output_level: debug
register: ans_test_uSeg_2_nm_present_again

- name: Assertions check for add ans_test_uSeg_1 and ans_test_uSeg_2 object
Expand All @@ -199,38 +211,39 @@
- ans_test_uSeg_1.current.name == "ans_test_uSeg_1"
- ans_test_uSeg_1.current.type == "ip"
- ans_test_uSeg_1.current.value == "0.0.0.0"
- ans_test_uSeg_1.current.fvSubnet == false
- ans_test_uSeg_1.current.fvSubnet == true
- ans_test_uSeg_1.current.description == "ans_test_uSeg_1"
- ans_test_uSeg_2_nt is not changed
- ans_test_uSeg_2_nt.msg == "useg_subnet is False but all of the following are missing{{':'}} value"
- ans_test_uSeg_2_nt1 is not changed
- ans_test_uSeg_2_nt1.msg == "The value of uSeg subnet IP should be an empty string or 0.0.0.0, when the useg_subnet is set to true."
- ans_test_uSeg_2_cm_present is changed
- ans_test_uSeg_2_cm_present.current != {}
- ans_test_uSeg_2_cm_present.previous == {}
- ans_test_uSeg_2_cm_present.current.name == "ans_test_uSeg_2"
- ans_test_uSeg_2_cm_present.current.type == "ip"
- ans_test_uSeg_2_cm_present.current.value == "11.22.33.44/24"
- ans_test_uSeg_2_cm_present.current.fvSubnet == true
- ans_test_uSeg_2_cm_present.current.value == "11.22.33.44"
- ans_test_uSeg_2_cm_present.current.fvSubnet == false
- ans_test_uSeg_2_cm_present.current.description == "uSeg Attr object created using Ansible"
- ans_test_uSeg_2_nm_present is changed
- ans_test_uSeg_2_nm_present.current != {}
- ans_test_uSeg_2_nm_present.previous == {}
- ans_test_uSeg_2_nm_present.current.name == "ans_test_uSeg_2"
- ans_test_uSeg_2_nm_present.current.type == "ip"
- ans_test_uSeg_2_nm_present.current.value == "11.22.33.44/24"
- ans_test_uSeg_2_nm_present.current.fvSubnet == true
- ans_test_uSeg_2_nm_present.current.value == "11.22.33.44"
- ans_test_uSeg_2_nm_present.sent.fvSubnet == false
- ans_test_uSeg_2_nm_present.current.description == "uSeg Attr object created using Ansible"
- ans_test_uSeg_2_nm_present_again is not changed
- ans_test_uSeg_2_nm_present_again.current != {}
- ans_test_uSeg_2_nm_present_again.previous != {}
- ans_test_uSeg_2_nm_present_again.current.name == "ans_test_uSeg_2"
- ans_test_uSeg_2_nm_present_again.current.type == "ip"
- ans_test_uSeg_2_nm_present_again.current.value == "11.22.33.44/24"
- ans_test_uSeg_2_nm_present_again.current.fvSubnet == true
- ans_test_uSeg_2_nm_present_again.current.value == "11.22.33.44"
- ans_test_uSeg_2_nm_present_again.sent.fvSubnet == false
- ans_test_uSeg_2_nm_present_again.current.description == "uSeg Attr object created using Ansible"
- ans_test_uSeg_2_nm_present_again.previous.name == "ans_test_uSeg_2"
- ans_test_uSeg_2_nm_present_again.previous.type == "ip"
- ans_test_uSeg_2_nm_present_again.previous.value == "11.22.33.44/24"
- ans_test_uSeg_2_nm_present_again.previous.fvSubnet == true
- ans_test_uSeg_2_nm_present_again.previous.value == "11.22.33.44"
- ans_test_uSeg_2_nm_present_again.previous.description == "uSeg Attr object created using Ansible"

- name: Invalid test - ans_test_uSeg_3 present - attribute_type - mac and without value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
- ans_test_uSeg_1_nt is not changed
- ans_test_uSeg_1_nt.msg == "state is present but all of the following are missing{{':'}} name, type"
- ans_test_uSeg_1_nt1 is not changed
- ans_test_uSeg_1_nt1.msg == "The value should be empty string or 0.0.0.0, when the useg_subnet is true."
- ans_test_uSeg_1_nt1.msg == "The value of uSeg subnet IP should be an empty string or 0.0.0.0, when the useg_subnet is set to true."

- name: ans_test_uSeg_1 present - attribute_type - ip, useg_subnet - true, without value
cisco.mso.mso_schema_template_anp_epg_useg_attribute:
Expand Down Expand Up @@ -135,7 +135,7 @@
name: ans_test_uSeg_2
attribute_type: ip
useg_subnet: false
value: 11.22.33.44/24
value: 11.22.33.44
check_mode: true
register: ans_test_uSeg_2_cm_present

Expand Down Expand Up @@ -168,27 +168,27 @@
- ans_test_uSeg_2_cm_present.previous == {}
- ans_test_uSeg_2_cm_present.current.name == "ans_test_uSeg_2"
- ans_test_uSeg_2_cm_present.current.type == "ip"
- ans_test_uSeg_2_cm_present.current.value == "11.22.33.44/24"
- ans_test_uSeg_2_cm_present.current.value == "11.22.33.44"
- ans_test_uSeg_2_cm_present.current.description == "uSeg Attr object created using Ansible"
- ans_test_uSeg_2_nm_present is changed
- ans_test_uSeg_2_nm_present.current != {}
- ans_test_uSeg_2_nm_present.previous == {}
- ans_test_uSeg_2_nm_present.current.name == "ans_test_uSeg_2"
- ans_test_uSeg_2_nm_present.current.type == "ip"
- ans_test_uSeg_2_nm_present.current.value == "11.22.33.44/24"
- ans_test_uSeg_2_nm_present.current.value == "11.22.33.44"
- ans_test_uSeg_2_nm_present.sent.fvSubnet == false
- ans_test_uSeg_2_nm_present.current.description == "uSeg Attr object created using Ansible"
- ans_test_uSeg_2_nm_present_again is not changed
- ans_test_uSeg_2_nm_present_again.current != {}
- ans_test_uSeg_2_nm_present_again.previous != {}
- ans_test_uSeg_2_nm_present_again.current.name == "ans_test_uSeg_2"
- ans_test_uSeg_2_nm_present_again.current.type == "ip"
- ans_test_uSeg_2_nm_present_again.current.value == "11.22.33.44/24"
- ans_test_uSeg_2_nm_present_again.current.value == "11.22.33.44"
- ans_test_uSeg_2_nm_present_again.sent.fvSubnet == false
- ans_test_uSeg_2_nm_present_again.current.description == "uSeg Attr object created using Ansible"
- ans_test_uSeg_2_nm_present_again.previous.name == "ans_test_uSeg_2"
- ans_test_uSeg_2_nm_present_again.previous.type == "ip"
- ans_test_uSeg_2_nm_present_again.previous.value == "11.22.33.44/24"
- ans_test_uSeg_2_nm_present_again.previous.value == "11.22.33.44"
- ans_test_uSeg_2_nm_present_again.previous.description == "uSeg Attr object created using Ansible"

- name: Invalid test - ans_test_uSeg_3 present - attribute_type - mac and without value
Expand Down

0 comments on commit a0a129a

Please sign in to comment.