Skip to content
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

dcnm_image_upgrade (ready to merge). #269

Merged
merged 300 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
300 commits
Select commit Hold shift + click to select a range
a8389b4
More robust handling of response_data
allenrobel Nov 6, 2023
103415d
Let the user know which device is failing.
allenrobel Nov 6, 2023
c95b5e0
More unit tests
allenrobel Nov 7, 2023
13fd3b2
run thru black/isort
allenrobel Nov 7, 2023
5fc1914
Convert user input to boolean if it's boolean-like
allenrobel Nov 7, 2023
6458c21
Add testcase, standardize testcase names, more...
allenrobel Nov 7, 2023
3615266
standardize test names
allenrobel Nov 7, 2023
deda29d
Fix docstring
allenrobel Nov 7, 2023
3b968ea
Rename "module" to something more descriptive
allenrobel Nov 7, 2023
af21244
Consider the upgrade status when determining idempotence
allenrobel Nov 7, 2023
bcc6b06
Determine valid EPLD module differently, more...
allenrobel Nov 7, 2023
78f22bb
Remove log messages
allenrobel Nov 7, 2023
12863ea
More robust handling of missing keys
allenrobel Nov 7, 2023
f53ea5b
Remove log messages
allenrobel Nov 7, 2023
135ce72
method_name should be local to each method
allenrobel Nov 7, 2023
81b5f65
Remove fail_json from validate_devices.
allenrobel Nov 7, 2023
055ddd3
Update test_image_mgmt_upgrade_00005 based on last commit
allenrobel Nov 7, 2023
cec1ae0
Add testcases for ImageUpgrade.commit(), more...
allenrobel Nov 8, 2023
3c6acd1
Add unit tests, more...
allenrobel Nov 8, 2023
9787f2b
Add unit tests for _merge_defaults_to_switch_config
allenrobel Nov 8, 2023
0e587d2
build_payload: Add another unit test, more...
allenrobel Nov 8, 2023
dd5f469
Remove check for install_options.success, more...
allenrobel Nov 8, 2023
2201527
ImageUpgrade.commit - add more unit tests
allenrobel Nov 9, 2023
8611263
run through black/isort
allenrobel Nov 9, 2023
9c9b5cb
build_payload: convert boolean-like strings to boolean
allenrobel Nov 9, 2023
1e54622
Fix bad method name make_bool -> make_boolean
allenrobel Nov 9, 2023
1f81bea
Remove duplicate testcase 00004
allenrobel Nov 9, 2023
dfe5686
ImageUpgrade: verify upgrade.nxos/upgrade.epld, more...
allenrobel Nov 9, 2023
19bac40
upgrade.epld - remove redundant assignment/check
allenrobel Nov 9, 2023
17f22cb
Add unit tests, more...
allenrobel Nov 9, 2023
4826d91
Add unit test for _wait_for_image_upgrade_to_complete
allenrobel Nov 9, 2023
99b1d2e
Add unit test for _wait_for_image_upgrade_to_complete
allenrobel Nov 9, 2023
a5bc699
Sort set difference for unit tests, more...
allenrobel Nov 9, 2023
afe991c
_get() run return value thru make_boolean()
allenrobel Nov 9, 2023
2615dd2
test_image_upgrade_ImagePolicyAction: Standardize test names, more...
allenrobel Nov 10, 2023
edcf475
image_policy_action: rename build_attach_payload to build_payload
allenrobel Nov 10, 2023
5257fbc
Run thru black/isort
allenrobel Nov 10, 2023
fea0a93
Don't hardcode method names
allenrobel Nov 10, 2023
9aa6897
Provide user's value in fail_json message
allenrobel Nov 10, 2023
b0e30ea
Add unit tests, run thru black/isort, more...
allenrobel Nov 10, 2023
3b73d7c
Standardize test names
allenrobel Nov 10, 2023
370a737
Run thru black/isort
allenrobel Nov 10, 2023
3872d84
Standardize test names, more...
allenrobel Nov 10, 2023
88668a9
Run thru black/isort, doctstring cleanup
allenrobel Nov 10, 2023
3f8b03f
Add property vpc_role2, more...
allenrobel Nov 11, 2023
bced276
Standardize test names
allenrobel Nov 11, 2023
c540c1d
Standardize test names, run thru black/isort
allenrobel Nov 11, 2023
4a13890
Standardize docstrings
allenrobel Nov 12, 2023
00f5f1a
Run thru black/isort
allenrobel Nov 12, 2023
42a6151
Add TEST_NOTES and remove unused entries
allenrobel Nov 12, 2023
c120512
Make global var name unique
allenrobel Nov 12, 2023
1525e7b
Add copyright and attribution
allenrobel Nov 13, 2023
c45c9a0
Remove unused import
allenrobel Nov 13, 2023
b5457cb
Standardize test names, remove unused fixtures, more...
allenrobel Nov 13, 2023
127112d
Add TEST_NOTES to _handle_delete_post_put_response fixtures
allenrobel Nov 13, 2023
e51874f
Remove unused file
allenrobel Nov 13, 2023
74731ef
Detach policy only if have policy matches want policy
allenrobel Nov 13, 2023
1b9a521
Run thru pylint
allenrobel Nov 13, 2023
b80d765
Run thru black/isort
allenrobel Nov 13, 2023
222a788
Run thru black/isort/pylint
allenrobel Nov 13, 2023
76bb186
Run thru black, isort, pylint, make method_name local to functions
allenrobel Nov 14, 2023
7166e3b
Update docstrings
allenrobel Nov 14, 2023
82d0411
Removed unused fixtures file
allenrobel Nov 14, 2023
4e85707
Remove unused payloads file
allenrobel Nov 14, 2023
326a8b2
Remove unused configs file
allenrobel Nov 14, 2023
5fd86ed
Add a TODO for a future test
allenrobel Nov 14, 2023
f4a2a28
Update docstrings
allenrobel Nov 14, 2023
50b84d3
Update docstrings, rename error_message to match
allenrobel Nov 14, 2023
7ec981b
Update docstrings
allenrobel Nov 14, 2023
7ad3bca
Run thru black, isort, pylint
allenrobel Nov 14, 2023
118211b
Add docstrings
allenrobel Nov 14, 2023
63bd11d
Add docstrings
allenrobel Nov 14, 2023
22c8c51
Modify boolean asserts to satisfy pylint
allenrobel Nov 14, 2023
d09bea6
Appease linters and ansible sanity (part 1)
allenrobel Nov 15, 2023
f607842
Fix imports
allenrobel Nov 15, 2023
68ebfab
Fixes, hardening, reduce unit test code duplication, more...
allenrobel Nov 17, 2023
f33062c
Use load_playbook_config for all inputs, more...
allenrobel Nov 17, 2023
9813d83
merge_dicts() handle case where no suboptions are specified in option…
allenrobel Dec 6, 2023
8307f7e
ansible-sanity related cleanup
allenrobel Dec 6, 2023
403b44d
Ignore missing-gplv3-license for dcnm_image_upgrade.py
allenrobel Dec 7, 2023
32496d1
Move all parameter validation to ParamsValidator class
allenrobel Dec 13, 2023
98f7734
Decouple _merge_defaults_to_switch_configs from _merge_global_and_swi…
allenrobel Dec 13, 2023
6f95875
Add integer range validation
allenrobel Dec 14, 2023
805a453
Use copy.copy() when assigning need to self.need
allenrobel Dec 14, 2023
d2b1dab
sentence should be on a single line
allenrobel Dec 14, 2023
f3aef22
Expanded on meaning of validate
allenrobel Dec 14, 2023
17b443c
Fix copywrite
allenrobel Dec 14, 2023
91eea87
Align epld description with current playbook structure
allenrobel Dec 14, 2023
3117251
Fix nxos options in two places in example playbook
allenrobel Dec 14, 2023
76dcfa5
Leverage ansible.module_utils.common validation
allenrobel Dec 14, 2023
cf1acbc
Decouple ParamsValidate from ImageUpgradeCommon
allenrobel Dec 15, 2023
d661077
Run thru black/isort
allenrobel Dec 15, 2023
53ee8da
isolate self.need from need using copy.copy()
allenrobel Dec 15, 2023
314906f
rename test file (remove extraneous "image_upgrade")
allenrobel Dec 15, 2023
280f1b3
Initial set of unit tests for ParamsValidate, more...
allenrobel Dec 15, 2023
cfce0b7
add assert for mandatory_param_spec_keys
allenrobel Dec 15, 2023
3b8bab1
Update or add copyright header, more...
allenrobel Dec 15, 2023
821c354
Align fail_json messages to suggest similar debugging steps.
allenrobel Dec 16, 2023
b052ca9
Add unit tests for multitype and integer range, more...
allenrobel Dec 16, 2023
60952fe
Fix assert expectation
allenrobel Dec 16, 2023
a8d366b
Add required 'preferred_type' param for multi-type, more...
allenrobel Dec 17, 2023
66c8cbf
Harden ParamsValidate and add more unit tests, more...
allenrobel Dec 19, 2023
b961965
Run thru black/isort.
allenrobel Dec 19, 2023
0cfd5fd
ParamsValidate hardening, add type check, more...
allenrobel Dec 19, 2023
f009242
Add properties to enable/disable debugging and set the logfile name, …
allenrobel Dec 20, 2023
57f4990
Run thru black and isort
allenrobel Dec 20, 2023
ad90605
Appease ansible sanity tests, more...
allenrobel Dec 20, 2023
b1dda7d
ImageValidate: add unit tests for instance.commit()
allenrobel Dec 20, 2023
3024008
ImageValidate: additional unit tests, more...
allenrobel Dec 21, 2023
fc53763
ImageUpgradeTask: leverage ParamsMergeDefault class
allenrobel Dec 21, 2023
2ca3fb4
Copy dcnm_inventory action plugin and modify for dcnm_image_upgrade
allenrobel Dec 21, 2023
f086735
Appease pycodestyle pep8 issues in sanity run
allenrobel Dec 21, 2023
bf09150
Fix pylint disallowed-name error in sanity tests
allenrobel Dec 21, 2023
eacfef4
Fixes for Undefined variable '__class__' pylint errors
allenrobel Dec 22, 2023
331a726
Remove pylint disable=consider-using-with which doesn't seem compatib…
allenrobel Dec 22, 2023
f6f7860
Add docs for dcnm_image_uupgrade
allenrobel Dec 22, 2023
89d0809
Fix typo in validate() fail_json message, add related unit tests
allenrobel Dec 22, 2023
3ad6a63
Use a common class for log messages
allenrobel Dec 23, 2023
0ffad67
Move merge_dicts() to a common class MergeDicts, more...
allenrobel Dec 23, 2023
db529c7
Move unit tests for common classes out of image_upgrade
allenrobel Dec 24, 2023
4d666d9
Don't abbreviate import
allenrobel Dec 24, 2023
9fdae8c
MergeDicts: add unit tests, simplify logic
allenrobel Dec 24, 2023
ba9aa28
Additional unit test
allenrobel Dec 24, 2023
41c88e9
ImageValidaate: move refresh() out of for loop
allenrobel Dec 24, 2023
221a3e3
ParamsMergeDefaults: use dict.get() rather than "not in"
allenrobel Dec 24, 2023
305912d
ImageInstallOptions: Avoid NDFC error
allenrobel Dec 24, 2023
11ee773
Add unit test to cover the changes in the last commit
allenrobel Dec 24, 2023
3701dbd
rename ParamsValidate.validate() to ParamsValidate.commit()
allenrobel Dec 25, 2023
55dd467
Changing behavior of ImagePolicies, more...
allenrobel Dec 27, 2023
0d7c00b
Add a failed_result to all fail_json calls, more...
allenrobel Dec 31, 2023
f8b8037
Fix mocked fail_json() to add **kwargs required by last commit.
allenrobel Dec 31, 2023
4a535aa
Fix ansible-sanity complaints
allenrobel Dec 31, 2023
dc5eec7
Fix ansible-sanity errors
allenrobel Dec 31, 2023
6390ee4
SwitchIssuDetails: change filtering key name, more...
allenrobel Dec 31, 2023
a199ba1
Change "retrieval_key" to "filter", more...
allenrobel Dec 31, 2023
9ce9a1c
New logging system. New result system, more...
allenrobel Jan 9, 2024
dffc8b5
Forgot to add module_utils/common/result.py
allenrobel Jan 9, 2024
95049e9
Switching to JSON for the logging config, more...
allenrobel Jan 9, 2024
198404e
Appease the linters
allenrobel Jan 9, 2024
816b518
Fix pylint error for a couple earlier python versions
allenrobel Jan 9, 2024
82f3305
Fix a few things found with local linter, more...
allenrobel Jan 9, 2024
0bbafcc
Remove unit test for MergeDicts.debug @property
allenrobel Jan 10, 2024
6555796
Modify unit tests for the new logger implementation
allenrobel Jan 10, 2024
c16309c
Fix pylint f-string errors
allenrobel Jan 10, 2024
54f63c3
Enhance playbook results
allenrobel Jan 11, 2024
28af1eb
Fix pylint error
allenrobel Jan 11, 2024
4243cb7
Result handling for merged state
allenrobel Jan 11, 2024
2fbf843
Fix unit tests to reflect changes in the last commit
allenrobel Jan 11, 2024
b5b5d8e
Remove one call to issu_details.refresh() in _build_payload(), more...
allenrobel Jan 11, 2024
4dc4cfd
Remove a TODO that was harder than I thought
allenrobel Jan 11, 2024
06c673e
Modified returned result not to use ansible state names
allenrobel Jan 12, 2024
5e78862
Fix linter shebang error
allenrobel Jan 12, 2024
677bf19
Fix trailing whitespace linter error
allenrobel Jan 12, 2024
aeb7878
Improve ImageStage results and logging, more...
allenrobel Jan 12, 2024
6d2957c
Consistent diff between ImageStage and ImageValidate
allenrobel Jan 12, 2024
cd329e0
Refactor, more...
allenrobel Jan 18, 2024
71cd2fc
Add type defininitions for dicts, more...
allenrobel Jan 18, 2024
5cc8f68
Fix linter pycodestyle linter error
allenrobel Jan 18, 2024
46de1a0
Initial integration test for "merged" state
allenrobel Jan 19, 2024
21866a4
Appease YAML linter
allenrobel Jan 19, 2024
743a1b5
IT: Fix jinja2 warning, add "deleted" state test, more...
allenrobel Jan 19, 2024
b0b04f9
skip query state diffs when determining if anything changed
allenrobel Jan 20, 2024
6ca1380
Add "query" state integration test
allenrobel Jan 20, 2024
758653e
Add loop around dcnm_send to wait for successful response.
allenrobel Jan 23, 2024
b1be893
Remove test_image_mgmt_validate_00020
allenrobel Jan 23, 2024
7137d46
ImageUpgradeTaskResult: Remove redundant class definition.
allenrobel Jan 23, 2024
6247470
Break "merged" state integration tests into two files, more...
allenrobel Jan 23, 2024
a37a01f
ImageUpgradeTask: Fix idempotence for merged state
allenrobel Jan 23, 2024
5baa10d
Move timeout and unit_test properties to ImageUpgradeCommon
allenrobel Jan 24, 2024
33bebb4
Add safe_send() method to call dcnm_send with a retry and timeout mec…
allenrobel Jan 24, 2024
795094c
Add recent runtimes to integration tests
allenrobel Jan 24, 2024
56ae8fb
Forgot to commit changes to unit test.
allenrobel Jan 24, 2024
c3e3e05
Fix PEP8 issue with inline comment
allenrobel Jan 24, 2024
83cc254
Cleanup result names
allenrobel Jan 24, 2024
15af4d3
Move ImagePolicyAction.safe_send to ImageUpgradeCommon.dcnm_send_with…
allenrobel Jan 24, 2024
7f171b5
ImagePolicies() - initialize response data to {}, more...
allenrobel Jan 25, 2024
4325d2e
Use dcnm_send_with_retry in more classes
allenrobel Jan 26, 2024
0eccb59
Fix PEP8 error (need two black lines)
allenrobel Jan 26, 2024
8fe798e
Remove unused dcnm_send import
allenrobel Jan 26, 2024
a258131
Add class RestSend(), more...
allenrobel Jan 28, 2024
d0a09f0
Fix PEP8 whitespace error
allenrobel Jan 28, 2024
b184356
Fix PEP8 import handling error
allenrobel Jan 28, 2024
50028d4
Fix PEP8 linespace error, move MockRestSend to image_mgmt for now
allenrobel Jan 28, 2024
1ff362b
Move MockRestSend into the image management unit test directory
allenrobel Jan 28, 2024
4b68149
Fix f-string error
allenrobel Jan 28, 2024
577cc8c
Remove need for MockRestSend
allenrobel Jan 29, 2024
6bc8074
ImageUpgrade: instantiate RestSend in __init__, more...
allenrobel Jan 29, 2024
deb31c6
ImageStage: Leverage RestSend(), more...
allenrobel Jan 31, 2024
eb76baa
Add unit test for ImageStage for len(serial_num) == 0
allenrobel Jan 31, 2024
fe37a6a
Fix PEP8 errors in sanity tests
allenrobel Jan 31, 2024
8e6ebfb
ImageStage: Add unit test for 500 response
allenrobel Feb 1, 2024
f8e7b06
ImageStage: add unit tests, more...
allenrobel Feb 1, 2024
3bc52c8
ImageValidate: leverage RestSend, more...
allenrobel Feb 1, 2024
3a480b0
SwitchDetails: Leverage RestSend
allenrobel Feb 1, 2024
57c8554
response and result properties should be inherited
allenrobel Feb 4, 2024
dc9d845
Fix ansible-sanity PEP8 issues
allenrobel Feb 4, 2024
2e36073
Increase example logging_config.json maxBytes from 500K to 50M
allenrobel Feb 5, 2024
319cf88
Update comments to include correct testcase name
allenrobel Feb 5, 2024
da496e8
Fix reference to non-existing property
allenrobel Feb 6, 2024
d11dc36
Disable logging
allenrobel Feb 6, 2024
48520d5
SwitchIssuDetails: rename refresh() to refresh_super(), more...
allenrobel Feb 7, 2024
7126064
ImagePolicies: do not fail_json if length of DATA.lastOperDataObject …
allenrobel Feb 8, 2024
e5b95bd
Don't call refresh() more than needed.
allenrobel Feb 18, 2024
53a5fe0
Fix pep8 too many blank lines
allenrobel Feb 18, 2024
3bd708a
rename image_mgmt directory to image_upgrade
allenrobel Feb 18, 2024
1be103e
ImageStage: Add unit test for successful commit, more...
allenrobel Feb 21, 2024
eb3bb39
Remove unused mocks
allenrobel Feb 21, 2024
903d86b
Remove unused mocks
allenrobel Feb 21, 2024
b317424
Remove unused mocks, more...
allenrobel Feb 21, 2024
8ce2e6a
Add unit test for bad result due to 500 response
allenrobel Feb 21, 2024
d932251
Fix pylint invalid-name errors
allenrobel Feb 21, 2024
5fdb3bf
Remove unused fixture, more...
allenrobel Feb 21, 2024
ad6bac1
Fix test_log.py import of MockAnsibleModule
allenrobel Feb 21, 2024
ae0ed59
Expand unit test execution to all files under tests/unit/.
allenrobel Feb 21, 2024
ff3efe3
ImageStage.check_interval unit test: parameter for bool case
allenrobel Feb 21, 2024
40b3351
ImageStage.check_timeout unit test: parameter for bool case
allenrobel Feb 22, 2024
8481d1d
Fix comment typos
allenrobel Feb 23, 2024
8d8eb49
ImageUpgradeCommon: Add unit tests, more...
allenrobel Feb 23, 2024
4c8e743
Update version_added to "3.5.0"
allenrobel Feb 24, 2024
17b81bd
image_upgrade.py: 100% unit test coverage
allenrobel Feb 25, 2024
0e32d52
Move issu_detail.refresh() out of inner for loops
allenrobel Feb 25, 2024
c1ff802
Remove caplog from unit tests, update docstrings.
allenrobel Feb 25, 2024
9bb1b50
ImageUpgradeCommon: add unit tests
allenrobel Feb 25, 2024
db36e9f
ImagePolicies: Add unit tests, update docstrings, remove inherited pr…
allenrobel Feb 26, 2024
d51a721
Replace (pylint) disallowed name "foo"
allenrobel Feb 26, 2024
3557f54
Move rest_send.py to module_utils/common
allenrobel Feb 26, 2024
c0d28bc
Add path and verb properties, fix whitespace issue.
allenrobel Feb 26, 2024
99042cc
Use do_not_raise() to verify that fail_json isn't called.
allenrobel Feb 26, 2024
18ae3cd
ImageUpgradeTaskResult: 100% unit test coverage
allenrobel Feb 28, 2024
c3d8ae2
Fix PEP8 sanity issue
allenrobel Feb 28, 2024
838b1d7
ImagePolicyAction: 100% unit test coverage
allenrobel Feb 29, 2024
c2621cb
ImageValidate: remove unused unit test
allenrobel Feb 29, 2024
e7a57c2
SwitchDetails: 100% unit test coverage
allenrobel Feb 29, 2024
6502398
SwitchIssuDetailsBy*: 100% unit test coverage
allenrobel Feb 29, 2024
63ac119
Shaved a couple seconds off unit test runtime
allenrobel Feb 29, 2024
e8c838f
Fix PEP8 whitespace errors
allenrobel Feb 29, 2024
fc3adc9
Fix PEP8 whitespace error
allenrobel Feb 29, 2024
6b517e8
ImageStage: Instantiate path and verb in __init__()
allenrobel Feb 29, 2024
3987a04
ImageValidate: 98% unit test coverage
allenrobel Mar 1, 2024
ad6d70e
ImageInstallOptions: 99% unit test coverage
allenrobel Mar 1, 2024
e52497d
Disable logging
allenrobel Mar 1, 2024
0e68d01
Update integration tests with new include syntax
allenrobel Mar 2, 2024
347f84e
Initial check_mode changes (needs more work)
allenrobel Mar 5, 2024
08da08d
Fix PEP8 too many blank lines
allenrobel Mar 5, 2024
682a20d
Add support for check_mode
allenrobel Mar 6, 2024
285127c
Fix pylint f-string interpolation errors.
allenrobel Mar 6, 2024
ce359cf
Pull in changes from dcnm_image_policy
allenrobel Mar 21, 2024
46be48e
Apply changes to results.py from dcnm_image_policy
allenrobel Mar 22, 2024
bf7c41c
Align result output with existing DCNM collection modules
allenrobel Mar 23, 2024
37bdb8f
Fix yamllint "too many blank lines"
allenrobel Mar 23, 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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz

- name: Run DCNM Unit tests
run: coverage run --source=. -m pytest tests/unit/modules/dcnm/. -vvvv
run: coverage run --source=. -m pytest tests/unit/. -vvvv
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/dcnm
env:
PYTHONPATH: /home/runner/.ansible/collections
Expand Down
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_image_upgrade](https://github.com/CiscoDevNet/ansible-dcnm/blob/main/docs/cisco.dcnm.dcnm_image_upgrade_module.rst)|Image management for Nexus switches
[cisco.dcnm.dcnm_interface](https://github.com/CiscoDevNet/ansible-dcnm/blob/main/docs/cisco.dcnm.dcnm_interface_module.rst)|DCNM Ansible Module for managing interfaces.
[cisco.dcnm.dcnm_inventory](https://github.com/CiscoDevNet/ansible-dcnm/blob/main/docs/cisco.dcnm.dcnm_inventory_module.rst)|Add and remove Switches from a DCNM managed VXLAN fabric.
[cisco.dcnm.dcnm_links](https://github.com/CiscoDevNet/ansible-dcnm/blob/main/docs/cisco.dcnm.dcnm_links_module.rst)|DCNM ansible module for managing Links.
Expand Down
Empty file added dcnm-ut
Empty file.
1,053 changes: 1,053 additions & 0 deletions docs/cisco.dcnm.dcnm_image_upgrade_module.rst

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions plugins/action/dcnm_image_upgrade.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright (c) 2024 Cisco and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import, division, print_function

__metaclass__ = type

from ansible_collections.ansible.netcommon.plugins.action.network import (
ActionModule as ActionNetworkModule,
)
from ansible.utils.display import Display

display = Display()


class ActionModule(ActionNetworkModule):
def run(self, tmp=None, task_vars=None):

connection = self._connection
persistent_connect_timeout = connection.get_option("persistent_connect_timeout")
persistent_command_timeout = connection.get_option("persistent_command_timeout")

timeout = 1000

if (persistent_command_timeout < timeout or persistent_connect_timeout < timeout):
display.warning(
"PERSISTENT_COMMAND_TIMEOUT is %s"
% str(persistent_command_timeout),
self._play_context.remote_addr,
)
display.warning(
"PERSISTENT_CONNECT_TIMEOUT is %s"
% str(persistent_connect_timeout),
self._play_context.remote_addr,
)
msg = (
"PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT"
)
msg += " must be set to {0} seconds or higher when using dcnm_image_upgrade module.".format(timeout)
msg += " Current persistent_command_timeout setting:" + str(
persistent_command_timeout
)
msg += " Current persistent_connect_timeout setting:" + str(
persistent_connect_timeout
)
return {"failed": True, "msg": msg}

if self._task.args.get('state') == 'merged':
display.warning("Upgrading switches can take a while. Please be patient...")
self.result = super(ActionModule, self).run(task_vars=task_vars)
return self.result
Empty file.
283 changes: 283 additions & 0 deletions plugins/module_utils/common/controller_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
"""
Class to retrieve and return information about an NDFC controller
"""
#
# Copyright (c) 2024 Cisco and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import, division, print_function

__metaclass__ = type
__copyright__ = "Copyright (c) 2024 Cisco and/or its affiliates."
__author__ = "Allen Robel"

import logging

from ansible_collections.cisco.dcnm.plugins.module_utils.image_upgrade.api_endpoints import \
ApiEndpoints
from ansible_collections.cisco.dcnm.plugins.module_utils.image_upgrade.image_upgrade_common import \
ImageUpgradeCommon
from ansible_collections.cisco.dcnm.plugins.module_utils.network.dcnm.dcnm import \
dcnm_send


class ControllerVersion(ImageUpgradeCommon):
"""
Return image version information from the Controller

NOTES:
1. considered using dcnm_version_supported() but it does not return
minor release info, which is needed due to key changes between
12.1.2e and 12.1.3b. For example, see ImageStage().commit()

Endpoint:
/appcenter/cisco/ndfc/api/v1/fm/about/version

Usage (where module is an instance of AnsibleModule):

instance = ControllerVersion(module)
instance.refresh()
if instance.version == "12.1.2e":
do 12.1.2e stuff
else:
do other stuff

Response:
{
"version": "12.1.2e",
"mode": "LAN",
"isMediaController": false,
"dev": false,
"isHaEnabled": false,
"install": "EASYFABRIC",
"uuid": "f49e6088-ad4f-4406-bef6-2419de914ff1",
"is_upgrade_inprogress": false
}
"""

def __init__(self, ansible_module):
super().__init__(ansible_module)
self.class_name = self.__class__.__name__

self.log = logging.getLogger(f"dcnm.{self.class_name}")
self.log.debug("ENTERED ControllerVersion()")

self.endpoints = ApiEndpoints()
self._init_properties()

def _init_properties(self):
self.properties = {}
self.properties["data"] = None
self.properties["result"] = None
self.properties["response"] = None

def refresh(self):
"""
Refresh self.response_data with current version info from the Controller
"""
path = self.endpoints.controller_version.get("path")
verb = self.endpoints.controller_version.get("verb")
self.properties["response"] = dcnm_send(self.ansible_module, verb, path)
self.properties["result"] = self._handle_response(self.response, verb)

if self.result["success"] is False or self.result["found"] is False:
msg = f"{self.class_name}.refresh() failed: {self.result}"
self.ansible_module.fail_json(msg)

self.properties["response_data"] = self.response.get("DATA")
if self.response_data is None:
msg = f"{self.class_name}.refresh() failed: response "
msg += "does not contain DATA key. Controller response: "
msg += f"{self.response}"
self.ansible_module.fail_json(msg)

def _get(self, item):
return self.make_boolean(self.make_none(self.response_data.get(item)))

@property
def dev(self):
"""
Return True if the Controller is running a development release.
Return False if the Controller is not running a development release.
Return None otherwise

Possible values:
True
False
None
"""
return self._get("dev")

@property
def install(self):
"""
Return the value of install, if it exists.
Return None otherwise

Possible values:
EASYFABRIC
(probably other values)
None
"""
return self._get("install")

@property
def is_ha_enabled(self):
"""
Return True if Controller is high-availability enabled.
Return False if Controller is not high-availability enabled.
Return None otherwise

Possible values:
True
False
None
"""
return self.make_boolean(self._get("isHaEnabled"))

@property
def is_media_controller(self):
"""
Return True if Controller is a media controller.
Return False if Controller is not a media controller.
Return None otherwise

Possible values:
True
False
None
"""
return self.make_boolean(self._get("isMediaController"))

@property
def is_upgrade_inprogress(self):
"""
Return True if a Controller upgrade is in progress.
Return False if a Controller upgrade is not in progress.
Return None otherwise

Possible values:
True
False
None
"""
return self.make_boolean(self._get("is_upgrade_inprogress"))

@property
def response_data(self):
"""
Return the data retrieved from the request
"""
return self.properties.get("response_data")

@property
def result(self):
"""
Return the GET result from the Controller
"""
return self.properties.get("result")

@property
def response(self):
"""
Return the GET response from the Controller
"""
return self.properties.get("response")

@property
def mode(self):
"""
Return the controller mode, if it exists.
Return None otherwise

Possible values:
LAN
None
"""
return self._get("mode")

@property
def uuid(self):
"""
Return the value of uuid, if it exists.
Return None otherwise

Possible values:
uuid e.g. "f49e6088-ad4f-4406-bef6-2419de914df1"
None
"""
return self._get("uuid")

@property
def version(self):
"""
Return the controller version, if it exists.
Return None otherwise

Possible values:
version, e.g. "12.1.2e"
None
"""
return self._get("version")

@property
def version_major(self):
"""
Return the controller major version, if it exists.
Return None otherwise

We are assuming semantic versioning based on:
https://semver.org

Possible values:
if version is 12.1.2e, return 12
None
"""
if self.version is None:
return None
return (self._get("version").split("."))[0]

@property
def version_minor(self):
"""
Return the controller minor version, if it exists.
Return None otherwise

We are assuming semantic versioning based on:
https://semver.org

Possible values:
if version is 12.1.2e, return 1
None
"""
if self.version is None:
return None
return (self._get("version").split("."))[1]

@property
def version_patch(self):
"""
Return the controller minor version, if it exists.
Return None otherwise

We are assuming semantic versioning based on:
https://semver.org

Possible values:
if version is 12.1.2e, return 2e
None
"""
if self.version is None:
return None
return (self._get("version").split("."))[2]
Loading
Loading