Skip to content

Commit

Permalink
feat[dcnm_policy]: adding the functions to handle use_desc_as_key (#285)
Browse files Browse the repository at this point in the history
* adding the functions to handle use_desc_as_key

* adding doc for the new parameter

* add bulk update API enpoints for dcnm 11

* fix a pep8 error

* address comments and fix a bug when templateNmae is updated, wrong templateName is reported

* adding support for  the state query, update the document and examples
add test cases for use_desc_as_key

* fix pep8 errors

* fix yamllint error

* fix yamllint error

* address comments and update the doc
  • Loading branch information
Shangxin Du authored Jun 18, 2024
1 parent a473794 commit 35e926b
Show file tree
Hide file tree
Showing 6 changed files with 1,095 additions and 622 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
60 changes: 60 additions & 0 deletions docs/cisco.dcnm.dcnm_policy_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,26 @@ Parameters
<div>The required state of the configuration after module completion.</div>
</td>
</tr>
<tr>
<td colspan="4">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>use_desc_as_key</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
<li>yes</li>
</ul>
</td>
<td>
<div>Flag to enforce using the description parameter as the unique key for policy management.</div>
<div>When set to True, the description parameter must be unique and non-empty for each policy in the playbook. The module will also use the description to find the policy to modify or delete. If exsiting policies have the same description, the module will raise an error. If the existing policy with the matching description is using differnet template name, the module will delete the existing policy and create a new one.</div>
</td>
</tr>
</table>
<br/>

Expand Down Expand Up @@ -535,6 +555,46 @@ Examples
- switch:
- ip: "{{ ansible_switch1 }}"
# Use the description as key
# NOTE: As the description of the policy in NDFC/DCNM is not unique,
# the user must make sure no policies with the same description are created on NDFC out of the playbook.
# If the description is not unique, the module will raise an error.
## Below task will create policies with description "policy_radius" on swtich1, switch2 and switch3,
## and only create policy "feature bfd" and "feature bash-shell" on the switch1 only
- name: Create policies
cisco.dcnm.dcnm_policy:
fabric: fabric_prod
use_desc_as_key: true
config:
- name: switch_freeform
create_additional_policy: false
description: policy_radius
policy_vars:
CONF: |
radius-server host 10.1.1.2 key 7 "ljw3976!" authentication accounting
- switch:
- ip: "{{ switch1 }}"
policies:
- name: switch_freeform
create_additional_policy: false
priority: 101
description: feature bfd
policy_vars:
CONF: |
feature bfd
- name: switch_freeform
create_additional_policy: false
priority: 102
description: feature bash-shell
policy_vars:
CONF: |
feature bash-shell
- ip: "{{ switch2 }}"
- ip: "{{ switch3 }}"
Expand Down
Loading

0 comments on commit 35e926b

Please sign in to comment.