Skip to content

dcnm_image_policy v2: Ready for review #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 240 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
240 commits
Select commit Hold shift + click to select a range
32080e5
ApiEndpoints(): endpoints for common controller operations
allenrobel May 9, 2024
293b1ca
ControllerFeatures(): Retrieve feature information from the controller
allenrobel May 9, 2024
fed0bb4
FabricTypes(): add fabric_type to feature mapping
allenrobel May 9, 2024
9a95506
Verify controller feature is enabled for fabric_type
allenrobel May 9, 2024
d470cb8
Remove debug message
allenrobel May 9, 2024
939a698
FabricDelete().register_result(): fabric_name needs to be upper-case
allenrobel May 9, 2024
9ad7d0b
dcnm_fabric IT: Add dcnm_fabric_merged_basic_ipfm
allenrobel May 9, 2024
dd1540a
dcnm_fabric IT: Add dcnm_tests.yaml with approprate vars
allenrobel May 9, 2024
6f55123
dcnm_fabric IT: Add notes regarding controller config
allenrobel May 9, 2024
0abea3f
Update unit tests to reflect addition of IPFM fabric type
allenrobel May 9, 2024
1dd1f8f
Standardize API endpoint definition and access
allenrobel May 9, 2024
9e50bae
dcnm_fabric IT: Add dcnm_fabric_merged_save_deploy_ipfm
allenrobel May 9, 2024
037d2d3
dcnm_fabric IT: Add dcnm_fabric_replaced_save_deploy_ipfm
allenrobel May 9, 2024
99f57ed
ControllerFeatures(): run thru black and isort
allenrobel May 9, 2024
5c320f8
Run api endpoint classes thru black, isort, pylint
allenrobel May 9, 2024
6448f70
ControllerFeatures(): Add unit tests, 100% coverage
allenrobel May 9, 2024
78dbc9b
dcnm_fabric: Update docs with IPFM fabric parameters
allenrobel May 9, 2024
a21888a
dcnm_fabric: fix PEP8 and doc errors
allenrobel May 9, 2024
f2bd8d7
Add EXTRA_CONF_LEAF param in EXAMPLES section
allenrobel May 9, 2024
a4e4410
Merge branch 'develop' of https://github.com/CiscoDevNet/ansible-dcnm…
allenrobel May 10, 2024
749954a
Merge branch 'develop' of https://github.com/CiscoDevNet/ansible-dcnm…
allenrobel May 11, 2024
0b77513
dcnm_endpoints: Initial lan-fabric endpoints
allenrobel May 11, 2024
132ce6f
Subclasses can define mandatory properties, more
allenrobel May 11, 2024
cf6f58f
Rename classes and files
allenrobel May 12, 2024
2a113fb
Fabrics: Refactor, update docstrings, add endpoints.
allenrobel May 12, 2024
f25db96
Consistent docstring structure.
allenrobel May 12, 2024
5fb4e11
Rename v1_common (V1Common) to common_v1 (CommonV1)
allenrobel May 13, 2024
dca6e43
dcnm_endpoints: Add stagingmanagement, imagemanagement
allenrobel May 13, 2024
b09f62f
dcnm_endpoints: Add ImageMgmt endpoints
allenrobel May 14, 2024
96f46bf
image_mgmt.py rename to image_mgnt.py to parallel NDFC
allenrobel May 14, 2024
690e4b2
Rename staging_management classes
allenrobel May 14, 2024
3f7b991
dcnm_endpoints: Add policy_mgnt endpoint classes
allenrobel May 14, 2024
a75f838
dcnm_endpoints: Add UT, more...
allenrobel May 14, 2024
c9716a7
dcnm_endpoints: Add UT for Fabrics, more...
allenrobel May 14, 2024
f8b61ec
dcnm_endpoints: docstring consistency across classes
allenrobel May 14, 2024
f1c2825
dcnm_endpoints: Add endpoints + UT, more...
allenrobel May 14, 2024
b112bc0
dcnm_endpoints: Add configtemplate endpoints + UT
allenrobel May 15, 2024
020efc7
Fix PEP8 issues, import error
allenrobel May 15, 2024
74f892e
Fix PEP8 no line at end of file, and f-string issue
allenrobel May 15, 2024
7ea3a0e
Fabrics().EpFabrics() new endpoint
allenrobel May 15, 2024
b7a5521
FabricDetails(): Leverage EpFabrics() endpoint class
allenrobel May 15, 2024
5d9de5b
FabricDetails(): run through black, isort, pylint
allenrobel May 15, 2024
7265095
FabricConfigDeploy(): Use EpFabricConfigDeploy() endpoint class
allenrobel May 15, 2024
9cb0e3e
FabricConfigSave(): Use EpFabricConfigSave() endpoint class
allenrobel May 15, 2024
470046e
FabricCreateCommon(): Use EpFabricCreate()
allenrobel May 15, 2024
ee58cbe
FabricDelete: use EpFabricDelete() class
allenrobel May 15, 2024
0c266ef
FabricSummary: Use EpFabricSummary(), more...
allenrobel May 16, 2024
1354646
FabricReplacedCommon: use EpFabricUpdate(), more...
allenrobel May 16, 2024
ff4b372
Fabrics(): Remove EpFabricSummary()
allenrobel May 16, 2024
73f2c89
Align api.v1.* with NDFC REST API documentation
allenrobel May 17, 2024
bfd3cae
Fix empy-init errors
allenrobel May 17, 2024
5401a36
TemplateGetAll(): use EpTemplates()
allenrobel May 17, 2024
14252cb
TemplateGet(): use EpTemplate()
allenrobel May 17, 2024
57c0916
ControllerVersion(): Use EpVersion
allenrobel May 17, 2024
52a877f
FabricUpdateCommon(): Use EpFabricUpdate()
allenrobel May 17, 2024
384c2e2
dcnm_fabric: Remove ApiEndpoints() class
allenrobel May 17, 2024
2c67232
Remove RestSend and Results import requirement
allenrobel May 17, 2024
6322426
dcnm_fabric: IPFM, update FabricTypes() unit tests for IPFM.
allenrobel May 18, 2024
419b3e2
FabricReplacedCommon().update_replaced_payload(): Simplify logic
allenrobel May 19, 2024
4869ff5
FabricReplacedCommon().update_replaced_payload(): Further logic simpl…
allenrobel May 19, 2024
ed595ff
FabricReplacedCommon().update_replaced_payload(): docstring update
allenrobel May 19, 2024
fede623
Merge branch 'develop' of https://github.com/CiscoDevNet/ansible-dcnm…
allenrobel May 20, 2024
9045026
EpFabricConfigDeploy(): add switch_id property
allenrobel May 20, 2024
50bb8af
Remove files associated with unpublished NDFC REST API path
allenrobel May 21, 2024
b199354
dcnm_maintenance_mode: Initial commit
allenrobel May 22, 2024
9032000
dcnm_maintenance_mode: Add to test/sanity/ignore-*
allenrobel May 22, 2024
417ca97
Fix PEP8 errors, more...
allenrobel May 22, 2024
43278a4
Modify diff to indicate what mode was entered.
allenrobel May 22, 2024
552a8b5
SwitchDetails(): add maintenance_mode property
allenrobel May 22, 2024
c5705d1
SwitchDetails(): compare values using lower()
allenrobel May 22, 2024
44f04ed
MaintenanceMode(): implement config-deploy
allenrobel May 22, 2024
993b1bf
Use SwitchDetails().maintenance_mode property
allenrobel May 23, 2024
2f281a9
RestSend(): improve docstrings
allenrobel May 23, 2024
b8a51d0
Handle "inconsistent" and "migration" states.
allenrobel May 23, 2024
c92ecd9
Handle non-existent switch case.
allenrobel May 23, 2024
9147c09
General error handling improvements, more...
allenrobel May 23, 2024
8f788c0
Implement query state.
allenrobel May 23, 2024
b34e006
Bulk per-fabric config-deploy
allenrobel May 24, 2024
cb7fbdf
MaintenanceMode().change_system_mode() simplify, more...
allenrobel May 24, 2024
49c0e43
Error handling, and query state content.
allenrobel May 24, 2024
89c9e41
Handle read-only fabrics, more...
allenrobel May 25, 2024
4d3361f
Query(): Update deployment_disabled for read-only fabrics.
allenrobel May 25, 2024
446c2d6
SwitchDetails(): Improve docstrings
allenrobel May 26, 2024
18ff32f
SwitchDetails(): Fix PEP8 whitespace in blank line
allenrobel May 26, 2024
e2e5425
api: Add unit tests
allenrobel May 26, 2024
ac7c290
Fix PEP8 errors, more...
allenrobel May 26, 2024
23f0d24
Rename api unit test files to reflect the endpoint path
allenrobel May 26, 2024
65361e1
MaintenanceMode(): Various cleanup, more...
allenrobel May 26, 2024
e3cc0ad
Harden error handling
allenrobel May 27, 2024
843ff7a
MaintenanceMode: initial unit tests
allenrobel May 27, 2024
9f43e85
test_maintenance_mode_00120: update, more...
allenrobel May 27, 2024
2dfaa49
Deprecate common classes requiring AnsibleModule
allenrobel May 28, 2024
e29cad6
Fix PEP8 errors, more...
allenrobel May 28, 2024
d6c9b68
dcnm_maintenance_mode: remove deprecated imports
allenrobel May 28, 2024
beaf8f9
Want().want: Fix type hint
allenrobel May 28, 2024
5fa9442
MaintenanceMode: Add type hints, more...
allenrobel May 28, 2024
ed9c225
MaintenanceModeInfo: new class, more...
allenrobel May 29, 2024
6c51d45
RestSend() v2. New class, more...
allenrobel May 30, 2024
3143e44
Remove unused imports
allenrobel May 30, 2024
bf7439c
Abstract response handling
allenrobel May 30, 2024
4ef99a7
ResultHandler(): Update unit tests
allenrobel May 30, 2024
73969c2
RestSend() v2: Update usage sections of docstring
allenrobel May 30, 2024
d597bcb
Hardening and docstring updates
allenrobel May 31, 2024
6ab0702
MockSender(): mock the Sender() class
allenrobel May 31, 2024
2c64941
MaintenanceMode(): add/update unit tests.
allenrobel Jun 1, 2024
8bfdaf4
Log() version 2. Simplify usage.
allenrobel Jun 1, 2024
642ed0b
Log() v2: 96% unit test coverage
allenrobel Jun 2, 2024
00f7761
Log() v2: Error handling improvements.
allenrobel Jun 2, 2024
ce0ad91
MaintenanceMode(): Add unit test
allenrobel Jun 2, 2024
36a4bae
MaintenanceMode: Add unit test
allenrobel Jun 2, 2024
8f2492f
dcnm_maintenance_mode: Hardening
allenrobel Jun 2, 2024
f98b099
Log() v2: Fix class docstring issues.
allenrobel Jun 2, 2024
b879c75
Fix Results() update to remove duplicate result and response
allenrobel Jun 3, 2024
83101d8
FabricDetails(): Backout last commit (only for FabricDetails)
allenrobel Jun 3, 2024
8bfacca
Results().did_anything_change(): return False if state == query
allenrobel Jun 3, 2024
3777b7a
Results(): raise TypeError instead of ValueError
allenrobel Jun 4, 2024
eb2b406
MaintenanceMode: use RestSend() v2, more...
allenrobel Jun 4, 2024
260f56f
FabricDetails() v2: 49% unit test coverage.
allenrobel Jun 4, 2024
f197d57
Use class decorators to remove duplicated code
allenrobel Jun 4, 2024
eeb51b2
Fix several item assignments
allenrobel Jun 4, 2024
c17625c
SwitchDetails(): inject rest_send and results with class decorators
allenrobel Jun 4, 2024
4fdfe76
FabricDetails() v2: inject rest_send and results with class decorators
allenrobel Jun 4, 2024
3d06c63
FabricDetails() v2: Fix PEP8 too many blank lines
allenrobel Jun 4, 2024
6879cd4
MaintenanceModeInfo(): Move to maintenance_mode_info.py
allenrobel Jun 4, 2024
4d668c0
Common(): inject rest_send with class decorator
allenrobel Jun 4, 2024
410a56b
MaintenanceMode: 94% unit test coverage
allenrobel Jun 5, 2024
9fd40cd
FabricDetails() v2: Hardening.
allenrobel Jun 5, 2024
73a331f
FabricDetails() v2: More hardening.
allenrobel Jun 5, 2024
15c315f
MaintenanceMode(): 100% unit test coverage
allenrobel Jun 5, 2024
199ff66
MaintenanceModeInfo: 49% unit test coverage
allenrobel Jun 5, 2024
97a275a
Forgot to add the mocks in the last commit.
allenrobel Jun 5, 2024
f9af68b
MockSwitchDetails(): Remove pylint not-callable
allenrobel Jun 5, 2024
1817fcd
Mock*(): Remove pylint disable= statements
allenrobel Jun 5, 2024
80fd9a6
MaintenanceModeInfo(): 64% unit test coverage, more...
allenrobel Jun 6, 2024
5883109
MaintenanceModeInfo: 81% unit test coverage.
allenrobel Jun 6, 2024
31907dc
sender_file.py Sender(): New class to simulate controller responses
allenrobel Jun 6, 2024
8ffbd72
MockSender(): Remove
allenrobel Jun 6, 2024
75312df
RestSend(), FabricDetails(): Update docstrings
allenrobel Jun 7, 2024
341e1f7
MockFabricDetailsByName: Mock exceptions only.
allenrobel Jun 7, 2024
ce1865e
MaintenanceModeInfo: 81% unit test coverage
allenrobel Jun 7, 2024
2ff5730
MaintenanceModeInfo: Fix fabric_read_only property assignment
allenrobel Jun 7, 2024
d6f8582
MaintenanceModeInfo().__init__(): initialize self._filter, more...
allenrobel Jun 7, 2024
1974b21
MaintenanceModeInfo: 89% unit test coverage
allenrobel Jun 7, 2024
c1ce7e9
MaintenanceModeInfo: 94% unit test coverage
allenrobel Jun 7, 2024
86d0a12
MaintenanceModeInfo: 100% unit test coverage.
allenrobel Jun 7, 2024
e723018
FabricDetails() v2: 43% unit test coverage.
allenrobel Jun 8, 2024
ba2b645
FabricDetails() v2: unit test coverage 47%
allenrobel Jun 9, 2024
cb67b83
FabricDetails: 76% unit test coverage
allenrobel Jun 10, 2024
6eb494f
FabricDetails: 78% unit test coverage
allenrobel Jun 10, 2024
d62e096
FabricDetails: 79% unit test coverage
allenrobel Jun 11, 2024
6ad4605
FabricDetailsByName: 81% unit test coverage
allenrobel Jun 11, 2024
0676d8b
Merge branch 'develop' of https://github.com/CiscoDevNet/ansible-dcnm…
allenrobel Jun 11, 2024
33aa105
Update sanity/ignore-2.[15,16].txt
allenrobel Jun 11, 2024
403ab55
fabric_details_v2.py: 84% unit test coverage
allenrobel Jun 11, 2024
6a40128
fabric_details_v2.py: 87% unit test coverage
allenrobel Jun 11, 2024
22459f5
fabric_details_v2.py: 95% unit test coverage
allenrobel Jun 11, 2024
8e66375
fabric_details_v2.py: 100% unit test coverage
allenrobel Jun 11, 2024
7abe421
sender_dcnm.py: 66% unit test coverage.
allenrobel Jun 12, 2024
6cc6dc4
sender_dcnm.py: 100% unit test coverage.
allenrobel Jun 12, 2024
94eec02
sender_file.py: 100% unit test coverage.
allenrobel Jun 12, 2024
305ca3d
Remove duplicate ResponseGenerator class
allenrobel Jun 12, 2024
69ea494
RestSend() v2: 73% unit test coverage
allenrobel Jun 12, 2024
92190d2
RestSend() v2: 81% unit test coverage
allenrobel Jun 12, 2024
48c5547
RestSend().commit(): Catch and re-raise exceptions
allenrobel Jun 13, 2024
f7a520d
RestSend() v2: 83% unit test coverage.
allenrobel Jun 13, 2024
b0eb953
RestSend() v2: 84% unit test coverage.
allenrobel Jun 13, 2024
a297e40
RestSend() v2: 88% unit test coverage.
allenrobel Jun 13, 2024
a8199d9
RestSend() v2: 89% unit test coverage, more...
allenrobel Jun 13, 2024
198c314
RestSend v2: 90% unit test coverage.
allenrobel Jun 13, 2024
76ee63b
sender_file.py: Add ability to simulate exceptions
allenrobel Jun 13, 2024
1f9be34
RestSend() v2: 92% unit test coverage.
allenrobel Jun 13, 2024
b3ece9f
RestSend().send_interval: Need to check for bool
allenrobel Jun 13, 2024
ccfe2da
Fix invalid escape.
allenrobel Jun 13, 2024
3cbe528
RestSend() v2: 93% unit test coverage.
allenrobel Jun 13, 2024
8c81d70
Add "implements" property to several classes.
allenrobel Jun 13, 2024
60b2e0c
RestSend() v2: property assignment modifications
allenrobel Jun 13, 2024
b62097c
RestSend().commit_normal_mode(): remove unneeded try-except
allenrobel Jun 13, 2024
498f198
RestSend() v2: 95% unit test coverage.
allenrobel Jun 13, 2024
4504d15
RestSend() remove unneeded method
allenrobel Jun 13, 2024
81bf531
RestSend() v2: 96% unit test coverage.
allenrobel Jun 14, 2024
bb2d513
RestSend() v2: 99% unit test coverage.
allenrobel Jun 14, 2024
fafffbf
SwitchDetails(): 75% unit test coverage.
allenrobel Jun 14, 2024
9cb64dc
SwitchDetails(): Fix potential KeyError on non-200 response
allenrobel Jun 14, 2024
a898985
SwitchDetails(): 85% unit test coverage.
allenrobel Jun 14, 2024
ce271c0
Merge branch 'develop' of https://github.com/CiscoDevNet/ansible-dcnm…
allenrobel Jun 14, 2024
d3efe3e
SwitchDetails(): 91% unit test coverage.
allenrobel Jun 14, 2024
c7b62ec
SwitchDetails(): 93% unit test coverage.
allenrobel Jun 14, 2024
c87ce87
SwitchDetails(): 94% unit test coverage.
allenrobel Jun 15, 2024
04670ad
SwitchDetails(): 99% unit test coverage.
allenrobel Jun 15, 2024
525299a
Initial integration test
allenrobel Jun 18, 2024
0114e4e
MaintenanceMode(): Fix deploy endpoint
allenrobel Jun 19, 2024
0908992
dcnm_maintenance_mode: inconsistent mode, change handling.
allenrobel Jun 19, 2024
70bb3bf
Merge branch 'develop' of https://github.com/CiscoDevNet/ansible-dcnm…
allenrobel Jun 20, 2024
336102b
Add wait_for_mode_change playbook parameter
allenrobel Jun 21, 2024
b533db8
Fix validate-modules DOCUMENTATION error.
allenrobel Jun 21, 2024
b9cd831
Same fix as last commit, but for switch-level.
allenrobel Jun 21, 2024
7a0ed4a
Merged().get_need(): Update docstring
allenrobel Jun 21, 2024
699eba1
MaintenanceMode: Add unit tests, wait_for_mode_change
allenrobel Jun 21, 2024
032c776
dcnm_maintenance_mode.py: 47% unit test coverage, more...
allenrobel Jun 21, 2024
e636a9c
Fix missing import
allenrobel Jun 21, 2024
cda2a56
dcnm_maintenance_mode.py: 49% unit test coverage
allenrobel Jun 21, 2024
8ecc190
Fix PEP8 trailing-whitespace
allenrobel Jun 22, 2024
c50f707
dcnm_maintenance_mode.py: 53% unit test coverage.
allenrobel Jun 22, 2024
4d8b373
Fix pylint no-method-argument in MockMergeDicts()
allenrobel Jun 22, 2024
24766e9
dcnm_maintenance_mode.py: 77% unit test coverage.
allenrobel Jun 24, 2024
e82752e
dcnm_maintenance_mode.py: 87% unit test coverage.
allenrobel Jun 24, 2024
20e267e
dcnm_maintenance_mode.py: 88% unit test coverage.
allenrobel Jun 24, 2024
00df43a
dcnm_maintenance_mode.py: 88% unit test coverage.
allenrobel Jun 24, 2024
69b65c7
dcnm_maintenance_mode.py: 93% unit test coverage.
allenrobel Jun 24, 2024
b8c0b41
Complete integration tests.
allenrobel Jun 24, 2024
251eb8b
dcnm_maintenance_mode: IT: Add README.md
allenrobel Jun 24, 2024
2edcb74
Merge branch 'develop' of https://github.com/CiscoDevNet/ansible-dcnm…
allenrobel Jun 26, 2024
250f9e4
Merge branch 'develop' of https://github.com/CiscoDevNet/ansible-dcnm…
allenrobel Jun 26, 2024
29f4a06
Merge branch 'develop' of https://github.com/CiscoDevNet/ansible-dcnm…
allenrobel Jun 27, 2024
39305f4
Enable logging via ENV variable
allenrobel Jun 27, 2024
1ebf9b2
Update integration tests, more...
allenrobel Jun 27, 2024
4a5295a
Initial commit for v2 enhancements for dcnm_image_policy
allenrobel Jun 29, 2024
d6f56fa
image_policy_create* unit tests updates.
allenrobel Jun 29, 2024
c2c2aea
Merged(): FIxed unintentional deletion of parameter values.
allenrobel Jun 29, 2024
ac98e7b
ImagePolicyUpdate: Align with v2 classes.
allenrobel Jun 29, 2024
5e221bb
ImagePolicyUpdate: Update unit tests
allenrobel Jun 30, 2024
1c48c90
ImagePolicyUpdateBulk: Align with v2 classes.
allenrobel Jun 30, 2024
fa3ded1
test_image_policy_update_bulk.py: Remove unused import.
allenrobel Jun 30, 2024
cf459f0
ImagePolicyReplaceBulk: Align with v2 classes.
allenrobel Jul 1, 2024
2a921a4
More alignment with v2 classes.
allenrobel Jul 1, 2024
c4be775
test_image_policy_replace_bulk.py: minor reformatting
allenrobel Jul 1, 2024
412e5c6
ImagePolicyQuery: Align with v2 classes.
allenrobel Jul 1, 2024
c72bea8
Config2Payload / Payload2Config: Align with v2 classes.
allenrobel Jul 1, 2024
824be64
Remove ApiEndpoints() and associated test cases.
allenrobel Jul 1, 2024
30bbd10
Final cleanup.
allenrobel Jul 1, 2024
b71415b
ImagePolicyCreate*: update unit tests to use ResponseGenerator()
allenrobel Jul 1, 2024
d668ea6
Use private addressing.
allenrobel Jul 1, 2024
8696b90
EpPolicyDelete(): Fix PEP8 too-many-black-lines.
allenrobel Jul 1, 2024
d3ca3c6
create.py: update docstrings, more...
allenrobel Jul 2, 2024
047181d
delete.py: update docstrings, more...
allenrobel Jul 2, 2024
71f6685
image_policies.py: update docstrings.
allenrobel Jul 2, 2024
758ea82
Update docstrings.
allenrobel Jul 2, 2024
8b2f2b0
Update docstrings, more...
allenrobel Jul 2, 2024
3b86662
ImagePolicyDelete(): Reduce controller requests, more...
allenrobel Jul 3, 2024
148893f
Merge branch 'develop' of https://github.com/CiscoDevNet/ansible-dcnm…
allenrobel Aug 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions playbooks/roles/dcnm_image_policy/dcnm_hosts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
all:
vars:
ansible_user: "admin"
ansible_password: "password-secret"
ansible_python_interpreter: python
ansible_httpapi_validate_certs: False
ansible_httpapi_use_ssl: True
children:
dcnm:
vars:
ansible_connection: ansible.netcommon.httpapi
ansible_network_os: cisco.dcnm.dcnm
hosts:
dcnm-instance.example.com:
nxos:
hosts:
n9k-hosta.example.com:
ansible_connection: ansible.netcommon.network_cli
ansible_network_os: cisco.nxos.nxos
ansible_ssh_port: 22
38 changes: 38 additions & 0 deletions playbooks/roles/dcnm_image_policy/dcnm_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
# This playbook can be used to execute integration tests for
# the role located in:
#
# tests/integration/targets/dcnm_image_policy
#
# Modify the hosts and vars sections with details for your testing
# setup and uncomment the testcase you want to run.
#
- hosts: dcnm
gather_facts: no
connection: ansible.netcommon.httpapi

vars:
# testcase: dcnm_image_policy_deleted
# testcase: dcnm_image_policy_merged
# testcase: dcnm_image_policy_overridden
# testcase: dcnm_image_policy_query
# testcase: dcnm_image_policy_replaced
switch_username: admin
switch_password: "foobar"
spine1: 192.168.1.2
spine2: 192.168.1.3
leaf1: 192.168.1.4
leaf2: 192.168.1.5
leaf3: 192.168.1.6
leaf4: 192.168.1.7
image_policy_1: "KR5M"
image_policy_2: "NR3F"
epld_image_1: n9000-epld.10.2.5.M.img
epld_image_2: n9000-epld.10.3.1.F.img
nxos_image_1: n9000-dk9.10.2.5.M.bin
nxos_image_2: n9000-dk9.10.3.1.F.bin
nxos_release_1: 10.2.5_nxos64-cs_64bit
nxos_release_2: 10.3.1_nxos64-cs_64bit

roles:
- dcnm_image_policy
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,50 @@ def verb(self):
return "POST"


class EpPolicyDelete(PolicyMgnt):
"""
## V1 API - PolicyMgnt().EpPolicyDelete()

### Description
Delete image policies.

### Raises
- None

### Path
- ``/rest/policymgnt/policy``

### Verb
- DELETE

### Notes
Expects a JSON payload as shown below, where ``policyNames`` is a
comma-separated list of policy names.

```json
{
"policyNames": "policyA,policyB,etc"
}
```
"""

def __init__(self):
super().__init__()
self.class_name = self.__class__.__name__
self.log = logging.getLogger(f"dcnm.{self.class_name}")
msg = "ENTERED api.v1.imagemanagement.rest."
msg += f"policymgnt.{self.class_name}"
self.log.debug(msg)

@property
def path(self):
return f"{self.policymgnt}/policy"

@property
def verb(self):
return "DELETE"


class EpPolicyDetach(PolicyMgnt):
"""
## V1 API - PolicyMgnt().EpPolicyDetach()
Expand Down Expand Up @@ -268,6 +312,51 @@ def verb(self):
return "DELETE"


class EpPolicyEdit(PolicyMgnt):
"""
## V1 API - PolicyMgnt().EpPolicyEdit()

### Description
Return endpoint information.

### Raises
- None

### Path
- ``/rest/policymgnt/edit-policy``

### Verb
- POST

### Parameters
- path: retrieve the path for the endpoint
- verb: retrieve the verb for the endpoint

### Usage
```python
instance = EpPolicyEdit()
path = instance.path
verb = instance.verb
```
"""

def __init__(self):
super().__init__()
self.class_name = self.__class__.__name__
self.log = logging.getLogger(f"dcnm.{self.class_name}")
msg = "ENTERED api.v1.imagemanagement.rest."
msg += f"policymgnt.{self.class_name}"
self.log.debug(msg)

@property
def path(self):
return f"{self.policymgnt}/edit-policy"

@property
def verb(self):
return "POST"


class EpPolicyInfo(PolicyMgnt):
"""
## V1 API - PolicyMgnt().EpPolicyInfo()
Expand Down
66 changes: 66 additions & 0 deletions plugins/module_utils/common/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,64 @@ class Properties:
- ``rest_send``: Set and return nn instance of the ``RestSend`` class.
- ``results``: Set and return an instance of the ``Results`` class.
"""
@property
def params(self):
"""
### Summary
Expects value to be a dictionary containing, at mimimum, the keys
``state`` and ``check_mode``.

### Raises
- setter: ``ValueError`` if value is not a dict.
- setter: ``ValueError`` if value["state"] is missing.
- setter: ``ValueError`` if value["state"] is not a valid state.
- setter: ``ValueError`` if value["check_mode"] is missing.

### Valid values

#### ``state``
- deleted
- merged
- overridden
- query
- replaced

#### ``check_mode``
- ``False`` - The Ansible module should make requested changes.
- ``True`` - The Ansible module should not make requested changed
and should only report what changes it would make if ``check_mode``
was ``False``.

### Details
- Example Valid params:
- ``{"state": "deleted", "check_mode": False}``
- ``{"state": "merged", "check_mode": False}``
- ``{"state": "overridden", "check_mode": False}``
- ``{"state": "query", "check_mode": False}``
- ``{"state": "replaced", "check_mode": False}``
- getter: return the params
- setter: set the params
"""
return self._params

@params.setter
def params(self, value):
method_name = inspect.stack()[0][3]
if not isinstance(value, dict):
msg = f"{self.class_name}.{method_name}: "
msg += "params must be a dictionary. "
msg += f"got {type(value).__name__} for "
msg += f"value {value}"
raise TypeError(msg)
if value.get("state", None) is None:
msg = f"{self.class_name}.{method_name}: "
msg += "params.state is required but missing."
raise ValueError(msg)
if value.get("check_mode", None) is None:
msg = f"{self.class_name}.{method_name}: "
msg += "params.check_mode is required but missing."
raise ValueError(msg)
self._params = value

@property
def rest_send(self):
Expand Down Expand Up @@ -106,6 +164,14 @@ def results(self, value):
raise TypeError(msg)
self._results = value

def add_params(self):
"""
### Summary
Class decorator method to set the ``params`` property.
"""
self.params = Properties.params
return self

def add_rest_send(self):
"""
### Summary
Expand Down
Loading
Loading