Skip to content

Commit

Permalink
[minor_change] Add stratum attribute to aci_ntp_policy module
Browse files Browse the repository at this point in the history
  • Loading branch information
akinross authored and lhercot committed Sep 4, 2024
1 parent 240e2f9 commit 9f20f80
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions plugins/modules/aci_ntp_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
- Enable master mode. Only applicable if server_state is enabled
type: str
choices: [ disabled, enabled ]
stratum:
description:
- The NTP stratum value.
- The APIC defaults to C(8) when not provided.
- The value must be minimal C(1) and maximum C(15).
type: int
state:
description:
- Use C(present) or C(absent) for adding or removing.
Expand All @@ -68,6 +74,7 @@
link: https://developer.cisco.com/docs/apic-mim-ref/
author:
- Tim Cragg (@timcragg)
- Akini Ross (@akinross)
"""

EXAMPLES = r"""
Expand Down Expand Up @@ -231,6 +238,7 @@ def main():
server_state=dict(type="str", choices=["disabled", "enabled"]),
auth_state=dict(type="str", choices=["disabled", "enabled"]),
master_mode=dict(type="str", choices=["disabled", "enabled"]),
stratum=dict(type="int"),
state=dict(type="str", default="present", choices=["absent", "present", "query"]),
)

Expand All @@ -249,6 +257,7 @@ def main():
server_state = module.params.get("server_state")
auth_state = module.params.get("auth_state")
master_mode = module.params.get("master_mode")
stratum = module.params.get("stratum")
state = module.params.get("state")
child_classes = ["datetimeNtpProv"]

Expand All @@ -275,6 +284,7 @@ def main():
serverState=server_state,
authSt=auth_state,
masterMode=master_mode,
StratumValue=stratum,
),
)

Expand Down
10 changes: 9 additions & 1 deletion tests/integration/targets/aci_ntp_policy/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Test code for the ACI modules
# Copyright: (c) 2022, Tim Cragg (timcragg)
# Copyright: (c) 2022, Tim Cragg (@timcragg)
# Copyright: (c) 2024, Akini Ross (@akinross)
#
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)

Expand Down Expand Up @@ -66,6 +67,7 @@
- nm_add_policy.current.0.datetimePol.attributes.adminSt == 'enabled'
- nm_add_policy.current.0.datetimePol.attributes.serverState == 'disabled'
- nm_add_policy.current.0.datetimePol.attributes.authSt == 'disabled'
- nm_add_policy.current.0.datetimePol.attributes.StratumValue == '8'
- cm_add_policy_again is not changed
- nm_add_policy_again is not changed
- nm_add_policy_again.current.0.datetimePol.attributes.dn == 'uni/fabric/time-ansible_ntp_policy'
Expand All @@ -74,6 +76,7 @@
- nm_add_policy_again.current.0.datetimePol.attributes.adminSt == 'enabled'
- nm_add_policy_again.current.0.datetimePol.attributes.serverState == 'disabled'
- nm_add_policy_again.current.0.datetimePol.attributes.authSt == 'disabled'
- nm_add_policy_again.current.0.datetimePol.attributes.StratumValue == '8'

# MODIFY POLICY
- name: Modify policy (check_mode)
Expand All @@ -84,6 +87,7 @@
admin_state: enabled
server_state: enabled
auth_state: disabled
stratum: 9
state: present
check_mode: true
register: cm_modify_policy
Expand Down Expand Up @@ -115,6 +119,7 @@
- nm_modify_policy.current.0.datetimePol.attributes.adminSt == 'enabled'
- nm_modify_policy.current.0.datetimePol.attributes.serverState == 'enabled'
- nm_modify_policy.current.0.datetimePol.attributes.authSt == 'disabled'
- nm_modify_policy.current.0.datetimePol.attributes.StratumValue == '9'
- cm_modify_policy_again is not changed
- nm_modify_policy_again is not changed
- nm_modify_policy_again.current.0.datetimePol.attributes.dn == 'uni/fabric/time-ansible_ntp_policy'
Expand All @@ -123,6 +128,7 @@
- nm_modify_policy_again.current.0.datetimePol.attributes.adminSt == 'enabled'
- nm_modify_policy_again.current.0.datetimePol.attributes.serverState == 'enabled'
- nm_modify_policy_again.current.0.datetimePol.attributes.authSt == 'disabled'
- nm_modify_policy_again.current.0.datetimePol.attributes.StratumValue == '9'

# QUERY ALL POLICIES
- name: Query all policies (check_mode)
Expand Down Expand Up @@ -169,6 +175,7 @@
- nm_query_policy.current.0.datetimePol.attributes.adminSt == 'enabled'
- nm_query_policy.current.0.datetimePol.attributes.serverState == 'enabled'
- nm_query_policy.current.0.datetimePol.attributes.authSt == 'disabled'
- nm_query_policy.current.0.datetimePol.attributes.StratumValue == '9'

# REMOVE POLICY
- name: Remove policy (check_mode)
Expand Down Expand Up @@ -205,5 +212,6 @@
- nm_remove_policy.previous.0.datetimePol.attributes.adminSt == 'enabled'
- nm_remove_policy.previous.0.datetimePol.attributes.serverState == 'enabled'
- nm_remove_policy.previous.0.datetimePol.attributes.authSt == 'disabled'
- nm_remove_policy.previous.0.datetimePol.attributes.StratumValue == '9'
- cm_remove_policy_again is not changed
- nm_remove_policy_again is not changed

0 comments on commit 9f20f80

Please sign in to comment.