Skip to content

Commit

Permalink
dcnm_bootflash module (#311)
Browse files Browse the repository at this point in the history
* WIP: Initial commit

bootflash_info.py
    - Initial work to retrieve bootflash info.

dcnm_bootflash.py
    - initial work on skeleton
    - Query(): sort of working.

playbooks/roles/dcnm_bootflash
    - base files added

tests/integration/targets/dcnm_bootflash/*
    - base files added

module_utils/common/api/v1/... /bootflash/bootflash.py
    - Initial endpoints done

* Renaming the module to dcnm_switch_bootflash

The original requested name was dcnm_switch_bootflash, but I was using dcnm_bootflash.

Have changed the name in all relevamt places.

* Refactor _get()

* Rename module to dcnm_bootflash

After discussing with Shangxin, renaming the module to dcnm_bootflash.  Have changed the name in all relevant places.

* Fix NDFC-added leading space in ipAddr

1. bootflash_info.py
    - build_matches(): strip leading space from ipAddr value in NDFC response.
    - Update and/or add docstrings throughout.
    - Add match property to return the current matching switch+file information.
    - Remove unused @Properties.add_params class decorator.

2. dcnm_bootflash.py
    - Query(): Rewrite to use self.have.

3. tests/integration/targets/dcnm_bootflash/tests/dcnm_bootflash_query.yaml
    - Rewrite assertions to avoid jinja2 warnings.
    - Update some of the REQUIREMENTS section.

* Deleted(): Initial work to handle deleted state.

* BootflashFiles(): Handle switch migration mode.

Add infrastructure to easily determine whether files can be deleted on each switch and raise ValueError with appropriate error message if any files cannot be deleted.

I suspect there will be more reasons than Migration mode so add capability to handle additional scenarios in the future.

* BootflashFiles(): simplify validate_commit_parameters()

* BootflashFiles().commit() update docstring.

* IT: integration test for deleted state.

This requires that files be manually created on switch-under-test bootflash. e.g.

echo foo > foo.txt

There's just no good, low-overhead, way to add files to a switch bootflash.  dcnm_file_upload + dcnm_image_upgrade is (IMHO) way too slow for an integration test.

Better just to get on the switch CLI and use echo...

* Remove stray pylint directive.

* BootflashFiles(): Appease pylint.

* BootflashFiles(): Update class docstring.

* BootflashFiles(): Add partition property.

1. Add partition property

2. Fix payload to use partition property (rather than file_path) for "partition" value.

* BootflashFiles(): Remove unused attributes.

BootflashFiles().__init__()
    - Remove self.response_dict and self.result_dict.
    - Alphabetize remaining attributes.

* dcnm_bootflash.py: simplify error message handling.

* Modify playbook structure based on discussion with team

Also implement idempotence for files in root directory of flash devices.

Idempotence cannot currently be supported for files in directories since the bootflash-info endpoint does not support listing files within directories.

* BootflashInfo(): Call bootflash-discovery

1. EpBootflashDiscovery(): new endpoint class.

2. BootflashInfo(): To ensure we have current bootflash information, send EpBootflashDiscovery request before sending EpBootflashInfo request.

3. BootflashInfo(): Refactor stripping of ipAddr in build_matches() info strip_ipaddr_leading_space()

4. BootflashInfo(): change all occurances of bootflash_type to supervisor (new supervisor property returns associated key bootflash_type).

5. BootflashInfo(): update docstrings.

6. imagemgnt.py: Remove EpBootflashInfo() from this file.  It already exists in imagemgnt/bootflash/bootflash.py

* BootflashFiles(): bootflash_type -> supervisor

1. BootflashFiles(): Rename all occurances of bootflash_type to supervisor.

2. BootflashFiles(): Run through linters.

* dcnm_bootflash.py: update DOCUMENTATION, more

1. Update DOCUMENTATION to note that currently we support only files in a partition's root directory.

2. Update EXAMPLES section to remove subdirectories.

3. Update docstrings throughout.

4. Common(): fix error messages to reference the correct vars.

3.

* IT: dcnm_bootflash_deleted.yaml: fix filepath

Remove directories from all filepath values since we do not support deleting files in directories.

* Add method docstrings.

* UT: Rename test file to reflect these are bootflash tests.

1. Rename EpBootFlashInfo() everywhere to EpBootflashInfo()

2. Rename test file to reflect that it contains tests for the bootflash endpoints.

* BootflashInfo(): Update class and method docstrings

* BootflashInfo().validate_refresh_parameters() refactor.

* BootflashInfo().__init__(): initialize filter properties

* dcnm_bootflash.py: share parse_target()

1. Deleted().parse_target() move to Common()

2. Query(): leverage parse_target()

* IT: Update tests to reflect recent commits

* dcnm_bootflash.py: Refactor out ParseTarget()

1. ParseTarget(): new class to parse a target dict.

2. dcnm_bootflash.py: Query() and Delete(): Leverage new ParseTargets() class.

3. BootflashInfo(): Only set results.action, results.check_mode, and results.state.  Leave it to the caller to set results.current_*.

4. BootflashInfo().populate_property(): Refactor out build_match()

5. BootflashInfo(): Run through linters.

6. ParseTarget(): new class to parse a single target e.g. bootflash:/my.txt into its constituent bootflash-files API parameters.

7. dcnm_bootflash.py: leverage ParseTarget()

8. dcnm_bootflash.py: Remove Common().get_have() in favor of using BootflashInfo() in Query() and Deleted()

9. dcnm_bootflash_query.py - Update integration test expectations based on above changes.

* BootflashInfo(): hardening.

BootflashInfo().populate_property() return None if property is not found in self.match.  Previously we raised ValueError().

* IT: dcnm_bootflash_delete.yaml: update

1. Update asserts based on previous commits.

2. Add expected results for each task.

* Support file globbing

Modifications to support file globbing syntax for matching files e.g.:

# match all .txt files on bootflash:
filepath: bootflash:/*.txt

# match log files for July 2024 on all partitions
filepath: *:/202407??.log

* BootflashInfo(): update class docstring, more...

1. Update class docstring with Usage section.

2. Rename two methods:
    - filter_supervisor_matches() -> match_filter_supervisor()
    - filter_switch_matches() -> match_filter_switch()

3. New method
    - match_filter_filepath(): refactored out of build_matches()

4. Rename validate_refresh_parameters().raise_exception() to:
    - validate_refresh_parameters().raise_value_error_if_not_set()

* IT: Update to test wildcards for partition and filepath.

* BootflashInfo(): Add method docstring.

2. BootflashInfo().match_filter_filepath(): Add method docstring.

* TargetToParams(): Add method docstrings.

* FileInfoToTarget(): Fix class docstring

* FileInfoToTarget(): Really fix class docstring...

The last commit didn't account for recent additions to the infomation of the target dict.  Fixed.

* FileInfoToTarget().commit(): Update docstring.

* Clean up diff results.  Optimize payload.

* BootflashFiles(): Add method docstrings, more...

1. BootflashFiles(): Add method docstrings
2. Run through linters

* Fix sanity errors

* BootflashFiles(): Fix var names.

1. BootflashFiles().ep_bootflash_info should be ep_bootflash_files.  Fixed.

2. change file_name, file_path, and file_size, to filename, filepath, and filesize.

* UT: BootflashFiles().__init__() add unit test.

* UT: BootflashInfo().__init__() add unit test.

1. BootflashInfo()
    - Add class decorator @Properties.add_rest_send
2. BootflashInfo().__init__()
    - self.action : change from "bootflash_query" to "bootflash_info"
    - Initialize self._matches rather than self.matches.
    - Initialize self._rest_send to None

* IT: BootflashInfo(): update assert to match action

BootflashInfo().action was modified in an earlier commit.  Updating the corresponding IT to reflect thsi change.

* BootflashFiles().target.setter: raise TypeError

1. BootflashFiles().target modified to raise TypeError if value is not a dict.
2. BootflashFiles(): Update docstrings.

* refactor and cleanup

1. bootflash_info.py
    - Align imports after renaming conversion classes.
    - Rename conversion class instance from file_info_to_target to convert_file_info_to_target.

2. dcnm_bootflash.py
    - Deleted().commit(): refactor.
    - Query().commit(): Remove unused code.
    - Align imports after renaming conversion classes.

3. convert_file_info_to_target.py
    - Rename from file_info_to_target.py
    - FileInfoToTarget(): rename to ConvertFileInfoToTarget()
    - Update docstrings.

4. convert_target_to_params.py
    - Rename from target_to_params.py
    - TargetToParams() rename to ConvertTargetToParams()

5. test_bootflash_files.py
    - Rename from test_dcnm_bootflash_files.py

6. test_bootflash_info.py
    - Rename from test_dcnm_bootflash_info.py
    - Update class instance name to reflect above changes.

6. New unit test files
    - test_convert_file_into_to_target.py
    - test_convert_target_to_params.py

* UT: BootflashInfo(): test_bootflash_info_00110

1. Add unit test test_bootflash_info_00110
    ### Summary
    - Verify exception is raised if rest_send is not set.

    ### Test
    -   ValueError is raised when rest_send is not set.

2. BootflashInfo().validate_refresh_parameters().raise_value_error_if_not_set(): ValueError() -> ValueError(msg)

3. Bootflash().switches: Update docstring.

* UT: BootflashInfo().refresh() unit tests

1. test_bootflash_info_00100 - Happy path
2. test_bootflash_info_00120 - ValueError is raised when results is not set.
3. test_bootflash_info_00130 - ValueError is raised when switch_details is not set.

* UT: Fixtures and utils for bootflash_info unit tests.

* utils.py: Fix sanity errors

Fix unused imports and too many blank lines.

* UT: BootflashInfo(): 88% coverage.

1. BootflashInfo(): Remove multiple unused getter properties.  An earlier version of BootflashInfo() provided getter properties for individual items in the file_info dict.  Functionality of BootflashInfo() changed from this earlier version such that these getter properties are no longer used.

2. Add unit tests.
    - test_bootflash_info_00140
    - test_bootflash_info_00150
    - test_bootflash_info_00200
    - test_bootflash_info_00210
    - test_bootflash_info_00300
    - test_bootflash_info_00310
    - test_bootflash_info_00320
    - test_bootflash_info_00400

* UT: BootflashInfo(): Add missing assert for 00210

1.  test_bootflash_info_00210 was missing the requisite assert.

* UT: BootflashInfo(): 91% coverage

1. BootflashInfo(): add test:
    - test_bootflash_info_00220

2. BootflashInfo().build_matches(): Remove conditional that would never be hit.

* BootflashInfo(): remove matches.setter, more...

1. BootflashInfo(): remove unused matches.setter.  instance._matches is set internally, so only matches.getter is needed.

2. BootflashInfo().build_matches(): remove check for ip_address since it's verified previously.

3. BootflashInfo(): Update docstrings and comments.

* UT: BootflashInfo(): Add test_bootflash_info_00230

1. BootflashInfo():
    - test_bootflash_info_00230

2. test_bootflash_info_00100
    - Remove 14 of 20 asserts as these are very expensive.  Reduced the test time from 30 to 8.4 seconds.

* UT: BootflashInfo(): 93% coverage.

1. Add test cases for switch_details.setter:
    - test_bootflash_info_00500
    - test_bootflash_info_00510

* UT: BootflashInfo(): 100% coverage

1. BootflashInfo().switches.setter: improve error messages.

2. test_bootflash_info.py: Add tests for BootflashInfo().switches.setter.
    -  test_bootflash_info_00600
    -  test_bootflash_info_00610
    -  test_bootflash_info_00620

* BootflashFiles(): Do not use payload for diff

Payload does not have much useful information, so use diff_current to populate the diff.

* ConvertTargetToParams(): Add Usage to class docstring

* dcnm_bootflash.py: remove unused import

* BootflashFiles: Add unit test, more...

1. BootflashFiles: test_bootflash_files_00100
    - Verify commit happy path.

2. utils.py:
    - Remove unused fixtures

* UT: BootflashInfo(): remove unused imports.

1. test_bootflash_info.py: remove unused imports.

* UT: ConvertFileInfoToTarget(): 100% coverage, more

1. test_convert_file_info_to_target.py
    - 100% test coverage for ConvertFileInfoToTarget()

2. ConvertFileInfoToTarget()
    - validate_commit_parameters(): new method
    - Update docstrings.
    - commit(): Raise ValueError if ":/" is nto in the resulting filepath.
    - date.getter: Fix error message.

* UT: Fix PurePosixPath version differences

Depending on the version of PurePosixPath, the error message differs (see below).  Fix by using a general .* regex for the Error detail: portion of the message.

argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'int'

Versus:

expected str, bytes or os.PathLike object, not int'

* UT: ConvertTargetToParams: 100% coverage, more...

1. convert_target_to_params.py
    - Update class docstring with example for file in directory.
    - ConvertTargetToParams().partition.setter: validate partition
    - ConvertTargetToParams().supervisor.setter: validate supervisor.

2. targets_BootflashFiles.json
    - rename to targets.json

3. test_bootflash_files.py
    - Update import for targets

4. test_convert_file_info_to_target.py
    - Cleanup docstrings

5. test_convert_target_to_params.py
    - Add testcases for 100% coverage.

6. utils.py
    - rename targets_bootflash_files() to targets()

* UT: BootflashFiles(): 75% coverage.

1. test_bootflash_files.py
   - test_bootflash_files_00200
     - Verify add_file() raises ValueError if switch mode is either "migration" or "inconsistent".

2. BootflashFiles().add_file()
    - Improve error message.

* UT: BootflashFiles(): 77% coverage.

1. BootflashFiles(). refresh_switch_details()
    - test_bootflash_files_00300
        - Verify ValueError raised if switch_details is not set.
    - test_bootflash_files_00310
        - Verify ValueError raised if rest_send is not set.

* IT: Add playbook to create bootflash files.

1. create_files.yaml
    - Use cisco.nxos.nxos_command module to create files on NX-OS switches.

* IT: Add spine1 and spine2 to dcnm_hosts.yaml

Add spine1 and spine2 to the inventory for use by create_files.yaml

* IT: dcnm_bootflash_query.yaml improvements.

1. Add test case for wildcard query.
2. Retain and expand test case for specific query.
3. Fix assertions.
4. Remove most file objects from Expected output for brevity.

* IT: expand dcnm_bootflash_deleted.yaml

1. Delete dcnm_bootflash_deleted.yaml and expand into two test cases.
   - dcnm_bootflash_deleted_specific.yaml
   - dcnm_bootflash_deleted_wildcard.yaml

2. dcnm_tests.yaml
    - Add file vars for dcnm_bootflash tests.
    - Update list of test cases to include those in 1 above.

3. dcnm_bootflash_query.yaml
    - Minor update to comments.

* IT: dcnm_bootflash_query.yaml update run time.

* UT: BootflashFiles(): 94% coverage.

* UT: BootflashFiles(): 99% coverage.  more...

1. BootflashFiles():
    - Update method docstrings.
    - filesize: Remove unused property.
    - target.setter: Require target to include filepath, ip_address, serial_number, and supervisor.

2. test_bootflash_files.py
    - 99% coverage.
    - Move target dictionaries into targets.json

* dcnm_bootflash Common(): remove unused properties.

* UT: dcnm_bootflash.py: 29% coverage.

* Common().__init__() hardening, more...

1. dcnm_bootflash.py Common().__init__(): added more verifications.

2. test_dcnm_bootflash_common.py
    - 40% coverage.

3. utils.py
    - Update params_deleted.config to include targets list.

* Common().get_want(): Improve error messages, more

1. dcnm_bootflash.py
    - Common().get_want(): Improve error messages.
    - main(): Add TypeError to except tuple when instantiating Log()

* UT: Common(): 100% coverage

1. test_bootflash_common.py
    - 100% coverage of Common() in dcnm_bootflash.py
    - Remove unused commented imports.

* UT: dcnm_bootflash.py: 66% coverage

1. dcnm_bootflash.py
    - Common().get_want(): Use copy.deepcopy()

2. test_bootflash_deleted.py
    - Deleted(): Initial unit tests

* Deleted(): 68% coverage.

1. test_bootflash_deleted.py
    - test_bootflash_deleted_02000
        - populate_files_to_delete() negative test

* BootflashFiles().target: fix exception type

1. BootflashFiles().target should raise TypeError if value is not a dictionary.

2. test_bootflash_files.py
    - Update corresponding unit tests.

* Deleted().update_bootflash_files(): hardening

1. dcnm_bootflash.py
    - Deleted().update_bootflash_files(): add try/except block around
       - convert_target_to_params
       - bootflash_files property setters

2. test_bootflash_deleted.py
    - Add unit tests for the above

* UT: dcnm_bootflash.py: 71% coverage.

1. test_bootflash_deleted.py
    - Deleted(): 100% coverage

* UT: Query(): initial unit tests

1. test_bootflash_query.py
    - 87% coverage for dcnm_bootlfash.py
    - test_bootflash_query_00000
    - test_bootflash_query_00010
    - test_bootflash_query_01000

* Common().__init__(): Fix target handling. more...

1. dcnm_bootflash.py
    - Common()__init__()
        - Fix crash when users doesn't include global target.
    - Query().register_null_result()
        - new method.

2. Update unit tests to align with changes to Common() above.

3. test_bootflash_query.py
    - test_bootflash_query_01010
        - Add test

4. Run everything through black/isort.

* dcnm_bootflash.py: Fix pylint error.

* IT: Move query tests into separate files.

1. Move query-state tests into separate files to match deleted-state tests.

* IT: Fix deleted-state tests idempotency asserts

1. result.response was changed a couple commits ago.  Modifying integration tests to align with those changes.

* IT: Remove hard-coded filenames, more...

1. tests/integration/targets/dcnm_bootflash/defaults/main.yaml
    - Add default filenames here.  User can override in dcnm_tests.yaml
    - Add default wildcard_filepath here.  User can override in dcnm_tests.yaml

2. Update inventory to use switch1 and switch2 instead of spine1 and spine2

3. tests/integration/targets/dcnm_bootflash/tests/*.yaml
    - Change spine1 and spine2 to switch1 and switch2 everywhere
    - Update REQUIREMENTS section with current set of vars and mention
      that the default vars can be overridden by uncommenting in dcnm_tests.yaml

4. playbooks/roles/dcnm_bootflash/*.yaml
    - Update to reflect the above changes.
    - Remove all vars not used in the dcnm_bootflash integration tests.

* IT: create_files.yaml - read vars from file.

There doesn't appear to be a way to add create_files as a testcase within dcnm_bootflash role.

For now, create_files.yaml is a separate playbook that uses ansible.builtin.include_vars to read nxos_vars.yaml to determine what files to create.

1. playbooks/roles/dcnm_bootflash/create_files.yaml
    - modify to read vars from nxos_vars.yaml

2. playbooks/roles/dcnm_bootflash/nxos_vars.yaml
    - contains dictionary nxos_vars defining files to create.

* dcnm_bootflash.py: Add wildcard examples.

* Fix yamllint error

* Fix typo in EXAMPLES section.

* Add Docs

* Doc updates

---------

Co-authored-by: mwiebe <[email protected]>
  • Loading branch information
allenrobel and mikewiebe authored Oct 30, 2024
1 parent e998756 commit 336594c
Show file tree
Hide file tree
Showing 59 changed files with 10,409 additions and 49 deletions.
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

0 comments on commit 336594c

Please sign in to comment.