Skip to content

dcnm_bootflash module #311

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 99 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
3e844b1
WIP: Initial commit
allenrobel Jul 29, 2024
17c6e93
Renaming the module to dcnm_switch_bootflash
allenrobel Jul 29, 2024
7fde49d
Refactor _get()
allenrobel Jul 29, 2024
1aecf48
Rename module to dcnm_bootflash
allenrobel Jul 29, 2024
e088482
Fix NDFC-added leading space in ipAddr
allenrobel Jul 30, 2024
633298a
Deleted(): Initial work to handle deleted state.
allenrobel Jul 30, 2024
160836a
BootflashFiles(): Handle switch migration mode.
allenrobel Jul 30, 2024
e988dfc
BootflashFiles(): simplify validate_commit_parameters()
allenrobel Jul 31, 2024
85c41a3
BootflashFiles().commit() update docstring.
allenrobel Jul 31, 2024
7c2749a
IT: integration test for deleted state.
allenrobel Jul 31, 2024
080823d
Remove stray pylint directive.
allenrobel Jul 31, 2024
a0f4988
BootflashFiles(): Appease pylint.
allenrobel Jul 31, 2024
f6c6130
BootflashFiles(): Update class docstring.
allenrobel Jul 31, 2024
cfacc39
BootflashFiles(): Add partition property.
allenrobel Jul 31, 2024
22c9f1f
BootflashFiles(): Remove unused attributes.
allenrobel Jul 31, 2024
0022d1e
dcnm_bootflash.py: simplify error message handling.
allenrobel Jul 31, 2024
0668a90
Modify playbook structure based on discussion with team
allenrobel Aug 1, 2024
b5a3275
BootflashInfo(): Call bootflash-discovery
allenrobel Aug 1, 2024
80c3d71
BootflashFiles(): bootflash_type -> supervisor
allenrobel Aug 1, 2024
80b0171
dcnm_bootflash.py: update DOCUMENTATION, more
allenrobel Aug 1, 2024
9d78975
IT: dcnm_bootflash_deleted.yaml: fix filepath
allenrobel Aug 2, 2024
74774a8
Add method docstrings.
allenrobel Aug 2, 2024
84ca5bd
UT: Rename test file to reflect these are bootflash tests.
allenrobel Aug 2, 2024
ddc9d1c
BootflashInfo(): Update class and method docstrings
allenrobel Aug 2, 2024
9da7dc0
BootflashInfo().validate_refresh_parameters() refactor.
allenrobel Aug 2, 2024
3d8e7e5
BootflashInfo().__init__(): initialize filter properties
allenrobel Aug 3, 2024
ee1567c
dcnm_bootflash.py: share parse_target()
allenrobel Aug 3, 2024
8e9d0ab
IT: Update tests to reflect recent commits
allenrobel Aug 3, 2024
813e9fc
dcnm_bootflash.py: Refactor out ParseTarget()
allenrobel Aug 5, 2024
8e0c7d8
BootflashInfo(): hardening.
allenrobel Aug 5, 2024
eb6a7c7
IT: dcnm_bootflash_delete.yaml: update
allenrobel Aug 5, 2024
ee92c72
Support file globbing
allenrobel Aug 6, 2024
b49792c
BootflashInfo(): update class docstring, more...
allenrobel Aug 6, 2024
012dd99
IT: Update to test wildcards for partition and filepath.
allenrobel Aug 6, 2024
c5b78b6
BootflashInfo(): Add method docstring.
allenrobel Aug 7, 2024
6230447
TargetToParams(): Add method docstrings.
allenrobel Aug 7, 2024
cf7c6a3
FileInfoToTarget(): Fix class docstring
allenrobel Aug 7, 2024
9e32356
FileInfoToTarget(): Really fix class docstring...
allenrobel Aug 7, 2024
a29c485
FileInfoToTarget().commit(): Update docstring.
allenrobel Aug 7, 2024
29f34bc
Clean up diff results. Optimize payload.
allenrobel Aug 7, 2024
93b0c11
BootflashFiles(): Add method docstrings, more...
allenrobel Aug 7, 2024
5299773
Fix sanity errors
allenrobel Aug 7, 2024
992d4e0
BootflashFiles(): Fix var names.
allenrobel Aug 7, 2024
c29a756
UT: BootflashFiles().__init__() add unit test.
allenrobel Aug 8, 2024
ca29946
UT: BootflashInfo().__init__() add unit test.
allenrobel Aug 8, 2024
1779086
IT: BootflashInfo(): update assert to match action
allenrobel Aug 8, 2024
0a9b186
BootflashFiles().target.setter: raise TypeError
allenrobel Aug 8, 2024
e455c37
refactor and cleanup
allenrobel Aug 8, 2024
e45d3a8
UT: BootflashInfo(): test_bootflash_info_00110
allenrobel Aug 9, 2024
2a088ca
UT: BootflashInfo().refresh() unit tests
allenrobel Aug 9, 2024
004259d
UT: Fixtures and utils for bootflash_info unit tests.
allenrobel Aug 9, 2024
8e50dba
utils.py: Fix sanity errors
allenrobel Aug 9, 2024
e5d1907
UT: BootflashInfo(): 88% coverage.
allenrobel Aug 9, 2024
51efab5
UT: BootflashInfo(): Add missing assert for 00210
allenrobel Aug 9, 2024
8fafe16
UT: BootflashInfo(): 91% coverage
allenrobel Aug 9, 2024
2b4e4a1
BootflashInfo(): remove matches.setter, more...
allenrobel Aug 10, 2024
6b23107
UT: BootflashInfo(): Add test_bootflash_info_00230
allenrobel Aug 10, 2024
de148f8
UT: BootflashInfo(): 93% coverage.
allenrobel Aug 10, 2024
1b0242e
UT: BootflashInfo(): 100% coverage
allenrobel Aug 10, 2024
32f66b7
BootflashFiles(): Do not use payload for diff
allenrobel Aug 12, 2024
0cd5a79
ConvertTargetToParams(): Add Usage to class docstring
allenrobel Aug 12, 2024
9cf3b22
dcnm_bootflash.py: remove unused import
allenrobel Aug 12, 2024
fafd233
BootflashFiles: Add unit test, more...
allenrobel Aug 12, 2024
312aa40
UT: BootflashInfo(): remove unused imports.
allenrobel Aug 12, 2024
fc701b7
UT: ConvertFileInfoToTarget(): 100% coverage, more
allenrobel Aug 12, 2024
1cdef8b
UT: Fix PurePosixPath version differences
allenrobel Aug 12, 2024
c6b8169
UT: ConvertTargetToParams: 100% coverage, more...
allenrobel Aug 12, 2024
77156ec
UT: BootflashFiles(): 75% coverage.
allenrobel Aug 12, 2024
c31b94d
UT: BootflashFiles(): 77% coverage.
allenrobel Aug 12, 2024
129145f
IT: Add playbook to create bootflash files.
allenrobel Aug 13, 2024
8922bad
IT: Add spine1 and spine2 to dcnm_hosts.yaml
allenrobel Aug 13, 2024
0496f91
IT: dcnm_bootflash_query.yaml improvements.
allenrobel Aug 13, 2024
e733dd5
IT: expand dcnm_bootflash_deleted.yaml
allenrobel Aug 13, 2024
135d2f5
IT: dcnm_bootflash_query.yaml update run time.
allenrobel Aug 13, 2024
aa6e560
UT: BootflashFiles(): 94% coverage.
allenrobel Aug 13, 2024
925e513
UT: BootflashFiles(): 99% coverage. more...
allenrobel Aug 14, 2024
a3a2f6a
dcnm_bootflash Common(): remove unused properties.
allenrobel Aug 14, 2024
613e388
UT: dcnm_bootflash.py: 29% coverage.
allenrobel Aug 14, 2024
b767f00
Common().__init__() hardening, more...
allenrobel Aug 14, 2024
3dc8a40
Common().get_want(): Improve error messages, more
allenrobel Aug 14, 2024
b779fcb
UT: Common(): 100% coverage
allenrobel Aug 14, 2024
841763b
UT: dcnm_bootflash.py: 66% coverage
allenrobel Aug 14, 2024
63a0886
Deleted(): 68% coverage.
allenrobel Aug 14, 2024
bb0746c
BootflashFiles().target: fix exception type
allenrobel Aug 14, 2024
0967483
Deleted().update_bootflash_files(): hardening
allenrobel Aug 15, 2024
9acf188
UT: dcnm_bootflash.py: 71% coverage.
allenrobel Aug 15, 2024
2aea53c
UT: Query(): initial unit tests
allenrobel Aug 15, 2024
a1cadbd
Common().__init__(): Fix target handling. more...
allenrobel Aug 15, 2024
29b4ad7
dcnm_bootflash.py: Fix pylint error.
allenrobel Aug 15, 2024
b49aba2
IT: Move query tests into separate files.
allenrobel Aug 15, 2024
822058d
IT: Fix deleted-state tests idempotency asserts
allenrobel Aug 15, 2024
895cb2d
IT: Remove hard-coded filenames, more...
allenrobel Aug 16, 2024
5e685c3
IT: create_files.yaml - read vars from file.
allenrobel Aug 16, 2024
23c775e
dcnm_bootflash.py: Add wildcard examples.
allenrobel Aug 19, 2024
1c23f69
Fix yamllint error
allenrobel Aug 20, 2024
b9667e2
Fix typo in EXAMPLES section.
allenrobel Aug 20, 2024
9677e5b
Add Docs
mikewiebe Oct 30, 2024
3b5e0a3
Doc updates
mikewiebe Oct 30, 2024
3c2ec80
Merge branch 'develop' into dcnm_bootflash
mikewiebe Oct 30, 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Name | Description
### Modules
Name | Description
--- | ---
[cisco.dcnm.dcnm_bootflash](https://github.com/CiscoDevNet/ansible-dcnm/blob/main/docs/cisco.dcnm.dcnm_bootflash_module.rst)|Bootflash management for Nexus switches.
[cisco.dcnm.dcnm_fabric](https://github.com/CiscoDevNet/ansible-dcnm/blob/main/docs/cisco.dcnm.dcnm_fabric_module.rst)|Manage creation and configuration of NDFC fabrics.
[cisco.dcnm.dcnm_image_policy](https://github.com/CiscoDevNet/ansible-dcnm/blob/main/docs/cisco.dcnm.dcnm_image_policy_module.rst)|Image policy management for Nexus Dashboard Fabric Controller
[cisco.dcnm.dcnm_image_upgrade](https://github.com/CiscoDevNet/ansible-dcnm/blob/main/docs/cisco.dcnm.dcnm_image_upgrade_module.rst)|Image management for Nexus switches
Expand Down
330 changes: 330 additions & 0 deletions docs/cisco.dcnm.dcnm_bootflash_module.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,330 @@
.. _cisco.dcnm.dcnm_bootflash_module:


*************************
cisco.dcnm.dcnm_bootflash
*************************

**Bootflash management for Nexus switches.**


Version added: 3.6.0

.. contents::
:local:
:depth: 1


Synopsis
--------
- Delete, query bootflash files.




Parameters
----------

.. raw:: html

<table border=0 cellpadding=0 class="documentation-table">
<tr>
<th colspan="4">Parameter</th>
<th>Choices/<font color="blue">Defaults</font></th>
<th width="100%">Comments</th>
</tr>
<tr>
<td colspan="4">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>config</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">dictionary</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>Configuration parameters for the module.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td colspan="3">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>switches</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
/ <span style="color: purple">elements=dictionary</span>
</div>
</td>
<td>
</td>
<td>
<div>List of dictionaries containing switches on which query or delete operations are executed.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>ip_address</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>The ip address of a switch.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>targets</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
/ <span style="color: purple">elements=dictionary</span>
</div>
</td>
<td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td>
<td>
<div>List of dictionaries containing options for files to be deleted or queried.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>filepath</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>The path to the file to be deleted or queried. Only files in the root directory of the partition are currently supported.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>supervisor</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>active</b>&nbsp;&larr;</div></li>
<li>standby</li>
</ul>
</td>
<td>
<div>Either active or standby. The supervisor containing the filepath.</div>
</td>
</tr>


<tr>
<td class="elbow-placeholder"></td>
<td colspan="3">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>targets</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
/ <span style="color: purple">elements=dictionary</span>
</div>
</td>
<td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td>
<td>
<div>List of dictionaries containing options for files to be deleted or queried.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>filepath</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
/ <span style="color: red">required</span>
</div>
</td>
<td>
</td>
<td>
<div>The path to the file to be deleted or queried.</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>supervisor</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li><div style="color: blue"><b>active</b>&nbsp;&larr;</div></li>
<li>standby</li>
</ul>
</td>
<td>
<div>Either active or standby. The supervisor containing the filepath.</div>
</td>
</tr>


<tr>
<td colspan="4">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>state</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>deleted</li>
<li><div style="color: blue"><b>query</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div>The state of the feature or object after module completion</div>
</td>
</tr>
</table>
<br/>




Examples
--------

.. code-block:: yaml

# This module supports the following states:
#
# deleted:
# Delete files from the bootflash of one or more switches.
#
# If an image is in use by a device, the module will fail. Use
# dcnm_image_upgrade module, state deleted, to detach image policies
# containing images to be deleted.
#
# query:
#
# Return information for one or more files.
#
# Delete two files from each of three switches.

- name: Delete two files from each of two switches
cisco.dcnm.dcnm_bootflash:
state: deleted
config:
targets:
- filepath: bootflash:/foo.txt
supervisor: active
- filepath: bootflash:/bar.txt
supervisor: standby
switches:
- ip_address: 192.168.1.1
- ip_address: 192.168.1.2
- ip_address: 192.168.1.3

# Delete two files from switch 192.168.1.1 and switch 192.168.1.2:
# - foo.txt on the active supervisor's bootflash: device.
# - bar.txt on the standby supervisor's bootflash: device.
# Delete potentially multiple files from switch 192.168.1.3:
# - All txt files on the standby supervisor's bootflash: device
# that match the pattern 202401??.txt, e.g. 20240123.txt.
# Delete potentially multiple files from switch 192.168.1.4:
# - All txt files on all flash devices on active supervisor.

- name: Delete files
cisco.dcnm.dcnm_bootflash:
state: deleted
config:
targets:
- filepath: bootflash:/foo.txt
supervisor: active
- filepath: bootflash:/bar.txt
supervisor: standby
switches:
- ip_address: 192.168.1.1
- ip_address: 192.168.1.2
- ip_address: 192.168.1.3
targets:
- filepath: bootflash:/202401??.txt
supervisor: standby
- ip_address: 192.168.1.4
targets:
- filepath: "*:/*.txt"
supervisor: active
register: result
- name: print result
ansible.builtin.debug:
var: result

# Query the controller for information about one file on three switches.
# Since the default for supervisor is "active", the module will query the
# active supervisor's bootflash: device.

- name: Query file on three switches
cisco.dcnm.dcnm_bootflash:
state: query
config:
targets:
- filepath: bootflash:/foo.txt
switches:
- ip_address: 192.168.1.1
- ip_address: 192.168.1.2
- ip_address: 192.168.1.3
register: result
- name: print result
ansible.builtin.debug:
var: result




Status
------


Authors
~~~~~~~

- Allen Robel (@quantumonion)
1 change: 1 addition & 0 deletions docs/cisco.dcnm.dcnm_image_policy_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Parameters
</div>
</td>
<td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td>
<td>
<div>List of dictionaries containing image policy parameters</div>
Expand Down
1 change: 1 addition & 0 deletions docs/cisco.dcnm.dcnm_image_upload_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Parameters
</div>
</td>
<td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td>
<td>
<div>A dictionary of images and other related information that is required to download the same.</div>
Expand Down
1 change: 1 addition & 0 deletions docs/cisco.dcnm.dcnm_interface_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Parameters
</div>
</td>
<td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td>
<td>
<div>A dictionary of interface operations</div>
Expand Down
1 change: 1 addition & 0 deletions docs/cisco.dcnm.dcnm_links_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Parameters
</div>
</td>
<td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td>
<td>
<div>A list of dictionaries containing Links information.</div>
Expand Down
1 change: 1 addition & 0 deletions docs/cisco.dcnm.dcnm_vpc_pair_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Parameters
</div>
</td>
<td>
<b>Default:</b><br/><div style="color: blue">[]</div>
</td>
<td>
<div>A list of dictionaries containing VPC switch pair information</div>
Expand Down
Loading
Loading