Skip to content

dcnm_fabric v2. Ready for review. #310

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 113 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
4d3aa86
Convert type hints to non-deprecated dict/list and remove typing impo…
allenrobel Jul 5, 2024
b6f5ca7
Modularize integration tests (not yet complete)
allenrobel Jul 5, 2024
dbb2813
Modularize integration tests (complete)
allenrobel Jul 6, 2024
959b586
Replace Any,Dict with non-deprecated type hints.
allenrobel Jul 6, 2024
6a42493
Copy image_policies.py to module_utils/common...
allenrobel Jul 6, 2024
59011ac
Update Log() to v2.
allenrobel Jul 7, 2024
3ad8de0
Update MergeDicts() import to MergeDicts() v2.
allenrobel Jul 7, 2024
46c5584
Update ParamsMergeDefaults() import to ParamsMergeDefaults() v2.
allenrobel Jul 7, 2024
eebee3a
Update ParamsValidate() import to ParamsValidate() v2.
allenrobel Jul 7, 2024
df81da2
Add EpIssu() endpoint
allenrobel Jul 7, 2024
a1b72c6
Leverage v2 classes (work in progress)
allenrobel Jul 7, 2024
525651b
WIP: Modify support classes to use RestSend() v2
allenrobel Jul 8, 2024
b9e93cb
WIP: Modify support classes to use RestSend() v2 Part2
allenrobel Jul 9, 2024
9c84f65
Align integration test with latest commits.
allenrobel Jul 9, 2024
399bf2a
ImageUpgrade: use ConversionUtils() for conversion functions.
allenrobel Jul 9, 2024
c620d1e
ImageUpgrade: Set endpoint closer to commit()
allenrobel Jul 10, 2024
ce1ca43
ImagePolicyAttach(): hardening.
allenrobel Jul 10, 2024
277dbb1
WaitForControllerDone: new class
allenrobel Jul 10, 2024
2585dcb
RestSend() v2: set payload to None after commit()
allenrobel Jul 10, 2024
8be8511
EpPolicyDetach(): require list of serial numbers.
allenrobel Jul 10, 2024
ceeb82d
Minor code reordering.
allenrobel Jul 10, 2024
6e7ec81
ImagePolicyDetach() fixes, more...
allenrobel Jul 11, 2024
c307708
dcnm_image_upgrade.py: fix serial_numbers populate
allenrobel Jul 11, 2024
26319ed
Refactor, add method return type hints
allenrobel Jul 12, 2024
2ea4bb7
Update debug log message with class/method names.
allenrobel Jul 12, 2024
bad8fa3
Remove useless results property assignments.
allenrobel Jul 12, 2024
ddfb6a8
rename self.endpoint to self.ep_policy_attach
allenrobel Jul 12, 2024
c0d6b53
wait_for_controller_done.py: fix raise, more...
allenrobel Jul 12, 2024
9c3785a
General improvements
allenrobel Jul 12, 2024
ad30849
Log debug message only once per loop.
allenrobel Jul 12, 2024
7837564
Remove debug log that's no longer needed.
allenrobel Jul 12, 2024
c39ba73
IT: deleted.yaml: Align asserts with expected results.
allenrobel Jul 12, 2024
25b9a87
Run through linters.
allenrobel Jul 12, 2024
681e4bd
Results(): Be extra-careful to avoid false positives.
allenrobel Jul 12, 2024
245dc66
IT: Add deleted_1x_switch integration test.
allenrobel Jul 12, 2024
6c100fe
IT: Update testcase to reflect new result output.
allenrobel Jul 13, 2024
cfd3bda
dcnm_image_upgrade.py: appease pylint
allenrobel Jul 13, 2024
f996b52
Remove unused files.
allenrobel Jul 13, 2024
f2a9bdf
Remove debug log messages.
allenrobel Jul 13, 2024
ee0c7f4
dcnm_image_upgrade.py: Refactor
allenrobel Jul 14, 2024
ea51372
install_options.py: rename self.endpoint to self.ep_install_options
allenrobel Jul 14, 2024
44e97b5
IT: update integration tests to reflect Results() v2 output.
allenrobel Jul 14, 2024
ca36718
image_policy_detach.py: Update docstrings
allenrobel Jul 14, 2024
9cfde70
Remove files that are no longer needed.
allenrobel Jul 14, 2024
b8f2b5a
UT: WIP, initial updates to utils.py for unit tests.
allenrobel Jul 14, 2024
dbddbf6
UT: ImageStage(): Convert unit tests to align with v2 support classes.
allenrobel Jul 15, 2024
b914a19
test_image_stsage.py : Various cleanup
allenrobel Jul 15, 2024
b99b649
test_image_stage.py: add test
allenrobel Jul 15, 2024
0768907
test_image_stage.py: Add asserts, update comments
allenrobel Jul 15, 2024
bb2b9e2
image_stage.py: Add debug logs for method entry, more...
allenrobel Jul 15, 2024
91154b4
UT: ImageValidate(): Convert unit tests to align with v2 support clas…
allenrobel Jul 15, 2024
cd200c4
UT: ImageValidate(): complete unit test alignment.
allenrobel Jul 16, 2024
948a0ee
image_stage.py: Add serial_numbers to several log messages.
allenrobel Jul 16, 2024
950f309
UT: test_switch_issu_details_by_serial_number.py
allenrobel Jul 16, 2024
13c9803
UT: SwitchIssuDetailsBy*(): Unit test alignment complete.
allenrobel Jul 16, 2024
f1e8e68
UT: WIP ImageUpgrade(): Unit test alignment with v2 support libraries.
allenrobel Jul 17, 2024
21f35ed
UT: ImageUpgrade(): Unit test alignment with v2 support libraries com…
allenrobel Jul 18, 2024
cb4873d
Remove unused vars
allenrobel Jul 18, 2024
72acf5c
UT: ImageUpgrade: move devices out of test file.
allenrobel Jul 18, 2024
32c2474
UT: ImageInstallOptions: Unit test alignment with v2 support libraries.
allenrobel Jul 19, 2024
35557eb
Minor, rename var
allenrobel Jul 19, 2024
33eb9c6
RestSend(): set _payload to None after commit.
allenrobel Jul 19, 2024
af82e16
Update two fabric testcases that started failing.
allenrobel Jul 19, 2024
e8c565e
UT: ControllerVersion: align unit tests with v2 support classes
allenrobel Jul 20, 2024
2cb8ffa
UT: ImagePolicies: align unit tests with v2 support classes
allenrobel Jul 20, 2024
648f4c3
UT: EpPolicyDetach() update unit tests
allenrobel Jul 20, 2024
46a3e20
UT: Remove duplicate unit tests
allenrobel Jul 20, 2024
20be34b
Run through black
allenrobel Jul 20, 2024
76b37c8
UT: Remove duplicate unit tests
allenrobel Jul 20, 2024
aa9c60c
dcnm_image_upgrade v2: Fix sanity errors
allenrobel Jul 20, 2024
86120c8
dcnm_image_upgrade v2: Fix more sanity errors
allenrobel Jul 21, 2024
28aa5aa
Add boilerplate
allenrobel Jul 21, 2024
e826f50
ControllerFeatures(): leverage RestSend() v2
allenrobel Jul 21, 2024
7e64268
UT: SwitchDetails(): Add 500 response test, more
allenrobel Jul 22, 2024
3e4b0d7
Remove deprecated use of typing Any, Dict.
allenrobel Jul 22, 2024
bc58972
Remove need to pass params to FabricDetails*() v2
allenrobel Jul 22, 2024
6a41238
Remove need to pass params to FabricConfigDeploy()
allenrobel Jul 22, 2024
9135bdc
Remove need to pass params to FabricConfigSave()
allenrobel Jul 23, 2024
68c731a
UT: FabricConfigDeploy() update unit tests to use Sender() and RestSe…
allenrobel Jul 23, 2024
671606b
WIP: initial work to move to RestSend() v2
allenrobel Jul 23, 2024
9fcb447
Results().did_anything_change(): add condition
allenrobel Jul 23, 2024
b507dfe
FabricCommon(): remove properties dict.
allenrobel Jul 23, 2024
ba3f41c
FabricCreateCommon()._build_properties(): remove.
allenrobel Jul 23, 2024
d44bad3
FabricDelete(): changes for RestSend() v2
allenrobel Jul 23, 2024
85862e0
UT: FabricDelete(): update unit tests
allenrobel Jul 23, 2024
f4d5fb5
UT: FabricCreateCommon(): update unit tests
allenrobel Jul 23, 2024
de232a1
UT: utils.py, align with previous UT changes.
allenrobel Jul 23, 2024
2e0f1e8
FabricSummary()._build_properties(): remove
allenrobel Jul 23, 2024
0144c9e
UT: update to align with b507dfe7.
allenrobel Jul 23, 2024
48c8bb2
UT: FabricSummary(): align unit tests with 2e0f1e83.
allenrobel Jul 23, 2024
4850c96
FabricCreate(): remove properties dict.
allenrobel Jul 23, 2024
3796017
FabricQuery: Remove need to pass params.
allenrobel Jul 23, 2024
2becfd0
FabricReplaced: Remove need to pass params
allenrobel Jul 23, 2024
f4a6cc3
FabricUpdate(): Remove need to pass params
allenrobel Jul 24, 2024
f4425cd
WIP: dcnm_fabric.py: update to use v2 libraries
allenrobel Jul 24, 2024
140eca1
Use Properties() class decorators
allenrobel Jul 24, 2024
c4e559c
Remove unused import.
allenrobel Jul 24, 2024
9102057
IT: Update integration tests
allenrobel Jul 24, 2024
2d91a50
Remove unneeded comment
allenrobel Jul 24, 2024
767b0c1
IT: Update asserts for metadata.action
allenrobel Jul 24, 2024
964b4ba
FabricConfigSave(): fix check_mode and state assignment
allenrobel Jul 24, 2024
8a631b8
dcnm_fabric.py: Remove params from class initializers.
allenrobel Jul 24, 2024
9abf3d6
dcnm_fabric.py: Various improvements...
allenrobel Jul 25, 2024
47aa8bb
IT: Add dcnm_fabric_replaced_vxlan
allenrobel Jul 25, 2024
2f940d8
IT: Fix comments in dcnm_fabric_replaced_basic
allenrobel Jul 25, 2024
c04d253
IT: Add test for VXLAN with non-default SITE_ID
allenrobel Jul 25, 2024
9cae00f
Idempotence fixes.
allenrobel Jul 25, 2024
a7ea0b7
Fix pylint and PEP8 sanity errors.
allenrobel Jul 25, 2024
a8e694d
Common(): leverage class decorators in Properties()
allenrobel Jul 25, 2024
52fe2ce
Numerous changes to remove legacy fabric_details.py
allenrobel Jul 25, 2024
647e6fa
Query(): Fix and add integration test.
allenrobel Jul 26, 2024
16d897a
Merge branch 'develop' into dcnm_image_upgrade_v2_backup
allenrobel Aug 7, 2024
dfc1a72
Merge branch 'dcnm_image_upgrade_v2_backup' into dcnm_fabric_v2
allenrobel Aug 7, 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
14 changes: 11 additions & 3 deletions playbooks/roles/dcnm_fabric/dcnm_tests.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
# This playbook can be used to execute integration tests for
# the role located in:
# the roles located in:
#
# Modify the vars section with details for testing setup.
# ./tests/integration/targets/dcnm_fabric/tests/*.yaml
#
# Modify the vars section with details for your testing setup.
#
# NOTES:
# 1. For the IPFM test cases (dcnm_*_ipfm), ensure that the controller
Expand All @@ -17,17 +19,23 @@
connection: ansible.netcommon.httpapi

vars:
# This testcase field can run any test in the tests directory for the role
# Uncomment ONE of the following testcases
# testcase: dcnm_fabric_deleted_basic
# testcase: dcnm_fabric_deleted_basic_ipfm
# testcase: dcnm_fabric_deleted_basic_lan_classic
# testcase: dcnm_fabric_deleted_basic_msd
# testcase: dcnm_fabric_deleted_basic_vxlan
# testcase: dcnm_fabric_merged_basic
# testcase: dcnm_fabric_merged_basic_ipfm
# testcase: dcnm_fabric_merged_save_deploy
# testcase: dcnm_fabric_merged_save_deploy_ipfm
# testcase: dcnm_fabric_replaced_basic
# testcase: dcnm_fabric_replaced_basic_vxlan
# testcase: dcnm_fabric_replaced_basic_vxlan_site_id
# testcase: dcnm_fabric_replaced_basic_ipfm
# testcase: dcnm_fabric_replaced_save_deploy
# testcase: dcnm_fabric_replaced_save_deploy_ipfm
# testcase: dcnm_fabric_query_basic.yaml
fabric_name_1: VXLAN_EVPN_Fabric
fabric_type_1: VXLAN_EVPN
fabric_name_2: VXLAN_EVPN_MSD_Fabric
Expand Down
15 changes: 15 additions & 0 deletions playbooks/roles/dcnm_image_upgrade/dcnm_hosts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
all:
vars:
ansible_user: "admin"
ansible_password: "password-ndfc"
switch_password: "password-switch"
ansible_python_interpreter: python
ansible_httpapi_validate_certs: False
ansible_httpapi_use_ssl: True
children:
ndfc:
vars:
ansible_connection: ansible.netcommon.httpapi
ansible_network_os: cisco.dcnm.dcnm
hosts:
192.168.1.1:
46 changes: 46 additions & 0 deletions playbooks/roles/dcnm_image_upgrade/dcnm_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
# This playbook can be used to execute integration tests for
# the role located in:
#
# tests/integration/targets/dcnm_image_upgrade
#
# 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: 00_setup_create_fabric
# testcase: 01_setup_add_switches_to_fabric
# testcase: 02_setup_replace_image_policies
# testcase: deleted
# testcase: deleted_1x_switch
# testcase: merged_global_config
# testcase: merged_override_global_config
# testcase: query
fabric_name: LAN_Classic_Fabric
switch_username: admin
switch_password: "{{ switch_password }}"
leaf1: 192.168.1.2
leaf2: 192.168.1.3
spine1: 192.168.1.4
# for dcnm_image_policy and dcnm_image_upgrade roles
image_policy_1: NR1F
image_policy_2: NR2F
# for dcnm_image_policy role
epld_image_1: n9000-epld.10.3.1.F.img
epld_image_2: n9000-epld.10.3.1.F.img
nxos_image_1: nxos64-cs.10.3.1.F.bin
nxos_image_2: nxos64-cs.10.3.2.F.bin
nxos_release_1: 10.3.1_nxos64-cs_64bit
nxos_release_2: 10.3.2_nxos64-cs_64bit
# for dcnm_image_upgrade role
fabric_name_1: "{{ fabric_name }}"
ansible_switch_1: "{{ leaf1 }}"
ansible_switch_2: "{{ leaf2 }}"
ansible_switch_3: "{{ spine1 }}"

roles:
- dcnm_image_upgrade
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# 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
__author__ = "Allen Robel"

import logging

from ansible_collections.cisco.dcnm.plugins.module_utils.common.api.v1.imagemanagement.rest.rest import \
Rest


class PackageMgnt(Rest):
"""
## api.v1.imagemanagement.rest.packagemgnt.PackageMgnt()

### Description
Common methods and properties for PackageMgnt() subclasses

### Path
``/appcenter/cisco/ndfc/api/v1/imagemanagement/rest/packagemgnt``
"""

def __init__(self):
super().__init__()
self.class_name = self.__class__.__name__
self.log = logging.getLogger(f"dcnm.{self.class_name}")
self.packagemgnt = f"{self.rest}/packagemgnt"
self.log.debug("ENTERED api.v1.PackageMgnt()")


class EpIssu(PackageMgnt):
"""
## api.v1.imagemanagement.rest.packagemgnt.EpIssu()

### Description
Return endpoint information.

### Raises
- None

### Path
- ``/api/v1/imagemanagement/rest/packagemgnt/issu``

### Verb
- GET

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

### Usage
```python
instance = EpIssu()
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"packagemgnt.{self.class_name}"
self.log.debug(msg)

@property
def path(self):
return f"{self.packagemgnt}/issu"

@property
def verb(self):
return "GET"
Original file line number Diff line number Diff line change
Expand Up @@ -299,18 +299,52 @@ def __init__(self):
super().__init__()
self.class_name = self.__class__.__name__
self.log = logging.getLogger(f"dcnm.{self.class_name}")
self._serial_numbers = None
msg = "ENTERED api.v1.imagemanagement.rest."
msg += f"policymgnt.{self.class_name}"
self.log.debug(msg)

@property
def path(self):
return f"{self.policymgnt}/detach-policy"
"""
### Summary
The endpoint path.

### Raises
- ``ValueError`` if:
- ``path`` is accessed before setting ``serial_numbers``.
"""
if self.serial_numbers is None:
msg = f"{self.class_name}.serial_numbers must be set before "
msg += f"accessing {self.class_name}.path."
raise ValueError(msg)
query_param = ",".join(self.serial_numbers)
return f"{self.policymgnt}/detach-policy?serialNumber={query_param}"

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

@property
def serial_numbers(self):
"""
### Summary
A ``list`` of switch serial numbers.

### Raises
- ``TypeError`` if:
- ``serial_numbers`` is not a ``list``.
"""
return self._serial_numbers

@serial_numbers.setter
def serial_numbers(self, value):
if not isinstance(value, list):
msg = f"{self.class_name}.serial_numbers must be a list "
msg += "of switch serial numbers."
raise TypeError(msg)
self._serial_numbers = value


class EpPolicyEdit(PolicyMgnt):
"""
Expand Down
Loading
Loading