Skip to content

WIP: dcnm_vrf - Pydantic integration #400

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

Open
wants to merge 409 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 168 commits
Commits
Show all changes
409 commits
Select commit Hold shift + click to select a range
a4a7654
Cleanup debugging detritus
allenrobel May 20, 2025
155c27c
Merge vrfTemplateConfig update methods
allenrobel May 20, 2025
e372184
Experimental: convert to JSON as late as possible
allenrobel May 20, 2025
31e1bfe
Remove commented code
allenrobel May 20, 2025
f2f2604
push_diff_create_update: simplify logic
allenrobel May 20, 2025
c66ae2a
get_items_to_detach() - move to class scope
allenrobel May 20, 2025
182a6f2
Rename/relocate methods
allenrobel May 21, 2025
7ed20a5
diff_for_attach_deploy: redundant key delete
allenrobel May 21, 2025
4cfc3a3
diff_for_attach_deploy: replace ast.literal_eval
allenrobel May 21, 2025
c6725f5
Replace ast.literal_eval with json.loads
allenrobel May 21, 2025
ae4e255
Address Copilot PR review comments
allenrobel May 21, 2025
363512b
Address Copilot PR review comment (part 2)
allenrobel May 21, 2025
f0afdf7
Address Copilot PR review comment (part 3)
allenrobel May 21, 2025
468752a
Refactor get_have -> populate_have_create
allenrobel May 21, 2025
7e98292
Fix PEP8 sanity issue
allenrobel May 21, 2025
13e250f
Cleanup after last commit
allenrobel May 21, 2025
961ce0f
get_have: minor simplification
allenrobel May 21, 2025
58852f9
get_have refactor -> populate_have_deploy
allenrobel May 21, 2025
def3196
Cleanup after last commit
allenrobel May 21, 2025
ebdc16a
get_have refactor -> populate_have_attach
allenrobel May 21, 2025
0128cbf
Appease pylint
allenrobel May 22, 2025
8be2e08
populate_have_attach: minor changes
allenrobel May 22, 2025
1984ff9
Cleanup after last commit
allenrobel May 22, 2025
c90ad03
get_want: refactor
allenrobel May 22, 2025
a0e9959
Cleanup after last commit
allenrobel May 22, 2025
4bf3092
get_diff_query: refactor
allenrobel May 22, 2025
f913de9
get_diff_query: refactor
allenrobel May 23, 2025
05c4ca7
Remove commented code
allenrobel May 23, 2025
84a2416
Rename DataItem to something less generic
allenrobel May 23, 2025
9e60d1c
Update docstring
allenrobel May 23, 2025
a2506f6
VrfPayloadV12: Update docstring
allenrobel May 23, 2025
9b95ab4
vrf_model_to_payload: new method
allenrobel May 23, 2025
5b7b86e
push_diff_attach: json.dumps(payload)
allenrobel May 23, 2025
87c139b
push_diff_delete: json.dumps(payload)
allenrobel May 23, 2025
a5dbd82
push_diff_deploy: json.dumps(payload)
allenrobel May 23, 2025
e8631f9
push_diff_detach: json.dumps(payload)
allenrobel May 23, 2025
f612c09
push_diff_undeploy: json.dumps(payload)
allenrobel May 23, 2025
2341aa4
push_diff_create_update: json.dumps(payload)
allenrobel May 23, 2025
7677d04
diff_merge_create: leverage send_to_controller
allenrobel May 23, 2025
45359a3
push_diff_attach: refactor lan_attach_list update
allenrobel May 24, 2025
ef02d99
Appease pep8 linter
allenrobel May 24, 2025
b19c0c5
Remove commented code
allenrobel May 24, 2025
2997adf
diff_for_attach_deploy: refactor
allenrobel May 26, 2025
2c0e92a
Appease pylint
allenrobel May 26, 2025
e379625
diff_for_attach_deploy_orig: remove
allenrobel May 26, 2025
ae5d069
populate_have_create: avoid KeyError
allenrobel May 27, 2025
945e66c
populate_have_attach: refactor
allenrobel May 27, 2025
753fe17
populate_have_attach_orig: remove
allenrobel May 27, 2025
13e78d1
_update_vrf_lite_extension: return updated attach
allenrobel May 27, 2025
ec6ff78
get_diff_query_for_vrfs_in_want: simplify
allenrobel May 27, 2025
9e07100
format_diff: refactor
allenrobel May 27, 2025
85948ce
diff_for_attach_deploy: update comments
allenrobel May 27, 2025
8b221f2
format_diff_orig: remove
allenrobel May 27, 2025
4cd1e54
get_diff_delete: refactor
allenrobel May 27, 2025
6bf426c
get_diff_replaced: refactor
allenrobel May 27, 2025
b0e02e0
Remove original methods
allenrobel May 28, 2025
4940751
update_vrf_attach_vrf_lite_extensions: initial refactor
allenrobel May 28, 2025
c28eb00
update_vrf_attach_vrf_lite_extensions_orig: remove
allenrobel May 28, 2025
15e5980
update_lan_attach_list: return pydantic model
allenrobel May 28, 2025
794e87c
Remove original methods, update docstrings
allenrobel May 29, 2025
199b67e
_update_vrf_lite_extension: use vrf_lite model
allenrobel May 29, 2025
a6464df
get_vrf_lite_objects_model: update and rename
allenrobel May 29, 2025
f15fec2
compare_properties: rename to property_values_match
allenrobel May 29, 2025
7d59b56
get_vrf_objects -> get_controller_vrf_object_models
allenrobel May 29, 2025
c0263cc
Update log messages
allenrobel May 29, 2025
37c92b6
Remove duplicate line
allenrobel May 29, 2025
6daf6a6
get_vrf_lan_attach_list -> get_controller_vrf_attachment_models
allenrobel May 29, 2025
06f53e0
Rename vars for readability
allenrobel May 29, 2025
d73d602
get_diff_replace: rename vars
allenrobel May 29, 2025
b8af9ea
get_diff_replace: rename vars (part 2)
allenrobel May 29, 2025
e9beef7
diff_merge_attach: rename vars for readability
allenrobel May 29, 2025
ca2cc30
diff_for_attach_deploy: rename vars for readability
allenrobel May 29, 2025
6e6dadf
Appease pep8 linter
allenrobel May 29, 2025
3d12b57
Fix two unit tests, replace dcnm_get_url
allenrobel May 30, 2025
796cf8d
Cleanup debug log messages
allenrobel May 30, 2025
073101b
Experimental commit
allenrobel May 31, 2025
20a005e
Appease pylint
allenrobel May 31, 2025
29a9c4d
Appease pep8
allenrobel May 31, 2025
3bbf62d
Update sanity/ignore-*.txt
allenrobel May 31, 2025
93a2f24
sanity/ignore-*.txt remove duplicate lines
allenrobel May 31, 2025
7fde7b4
Fix type hints
allenrobel May 31, 2025
8cc66de
Appease pylint
allenrobel May 31, 2025
8bbd9fc
DcnmVrfV12: add var self.have_attach_model
allenrobel May 31, 2025
0f43f37
HaveLanAttachItem: Accept a null vlan (vlanId)
allenrobel May 31, 2025
f0bf463
_deployment_status_match: Add debug logs
allenrobel May 31, 2025
6948df0
diff_merge_attach: Add debug logs
allenrobel May 31, 2025
1accc6a
Modifications for model-based delete state
allenrobel Jun 1, 2025
fb68ca1
Update sanity/ignore-*.txt
allenrobel Jun 1, 2025
a540003
Add logs to debug integration test failures
allenrobel Jun 1, 2025
8336977
Appease pylint
allenrobel Jun 1, 2025
afec3cf
Add logs to debug integration test failures (part 2)
allenrobel Jun 1, 2025
8e2091b
Add logs to debug integration test failures (part 3)
allenrobel Jun 2, 2025
6b8f19c
Appease pylint
allenrobel Jun 2, 2025
113c3da
Fix for integration test errors
allenrobel Jun 2, 2025
c195903
Update copyright
allenrobel Jun 2, 2025
ed626f4
Rename model file
allenrobel Jun 2, 2025
b029d17
Forgot to add dcnm_vrf_v12.py to the last commit
allenrobel Jun 2, 2025
531eef5
IT: Try fix for replaced-state integration test
allenrobel Jun 2, 2025
fab3b19
IT: logs to debug replaced-state failure, more…
allenrobel Jun 2, 2025
0e58547
IT: logs to debug replaced-state failure (part 2)
allenrobel Jun 2, 2025
ff30165
Appease pylint
allenrobel Jun 2, 2025
f4c59e5
Experimental: push_diff_attach_model
allenrobel Jun 2, 2025
12da88f
Appease pylint, update sanity/ignore-*.txt
allenrobel Jun 2, 2025
bb8e83e
Forgot to add new model to the last couple commits
allenrobel Jun 2, 2025
d936a22
Appease pylint
allenrobel Jun 2, 2025
5d412c3
IT: Potential fix for replaced-state test failure
allenrobel Jun 2, 2025
5b13f7e
Appease pylint
allenrobel Jun 2, 2025
3c13755
update_lan_attach_list: fabricName -> fabric, more
allenrobel Jun 2, 2025
f9e7a5e
push_diff_detach: fabricName -> fabric
allenrobel Jun 2, 2025
52a9149
VrfAttachPayloadV12: fix vlan field
allenrobel Jun 2, 2025
e4e4d55
get_items_to_detach_model: Modify return value
allenrobel Jun 2, 2025
72a06b6
IT: Cleanup after verifying integration passes
allenrobel Jun 3, 2025
34590ac
Add debugs for self.model_enabled
allenrobel Jun 3, 2025
eb7a38f
update_lan_attach_list : Rework legacy code
allenrobel Jun 4, 2025
018544f
Appease pylint
allenrobel Jun 4, 2025
baf0733
Appease pep8
allenrobel Jun 4, 2025
87a9f71
update_vrf_lite_extensions_new: fix nbr_dict update
allenrobel Jun 4, 2025
40f985b
Try fix for null vlan in diff_attach.
allenrobel Jun 4, 2025
4a66606
push_diff_attach_model: append directly to payload
allenrobel Jun 4, 2025
f4e9e05
push_diff_attach_model: refactor
allenrobel Jun 4, 2025
10d5e69
update_lan_attach_list_vrf_lite: rename vrf_attach
allenrobel Jun 4, 2025
533a0ae
Remove legacy code
allenrobel Jun 4, 2025
a95443f
Rename vars/methods to reduce cognitive load
allenrobel Jun 4, 2025
861b3f3
want_create: initial changes to leverage playbook model
allenrobel Jun 5, 2025
62137f9
Remove legacy code, more…
allenrobel Jun 5, 2025
01317a7
Experimental: Move methods to separate class
allenrobel Jun 6, 2025
79e9e44
Appease pep8
allenrobel Jun 6, 2025
d9b11d5
Update tests/sanity-*.txt with new files
allenrobel Jun 6, 2025
08f1448
SerialNumberToVrfLite: rename method
allenrobel Jun 6, 2025
3e8ccf3
get_diff_override: Convert to model-based, more…
allenrobel Jun 6, 2025
6d30e22
Fix log message
allenrobel Jun 6, 2025
6c02d3c
update_attach_params: Rename method for clarity
allenrobel Jun 6, 2025
bb09900
Utility classes for fabric_inventory conversions
allenrobel Jun 7, 2025
3e9bb40
push_diff_detach: divert to push_diff_detach_model
allenrobel Jun 7, 2025
fb6e2a7
IT: Potential fix for overridden-state failure
allenrobel Jun 7, 2025
fbf2198
update_have_attach_lan_detach_list: remove
allenrobel Jun 7, 2025
cc410a5
get_diff_override_model: remove intermediate vars
allenrobel Jun 7, 2025
6761e39
get_diff_override_model: reverse logic and dedent
allenrobel Jun 7, 2025
7ace6bf
get_diff_replace: simplification (part 1)
allenrobel Jun 7, 2025
42737ed
Use send_to_controller in more methods
allenrobel Jun 8, 2025
830d182
Appease pep8
allenrobel Jun 8, 2025
1d1d7be
Fix args to send_to_controller
allenrobel Jun 8, 2025
ab793c2
New models
allenrobel Jun 8, 2025
3d6831b
Appease Ansible sanity import tests
allenrobel Jun 8, 2025
976e316
Fix SendToController(action=) in two methods
allenrobel Jun 8, 2025
a99f15b
send_to_controller: use an optional response model
allenrobel Jun 8, 2025
5edd5fa
Retain UPPER_CASE fields for controller responses
allenrobel Jun 8, 2025
98b1ec1
Appease pep8
allenrobel Jun 8, 2025
d13aca6
Fix model alias
allenrobel Jun 8, 2025
bcab423
Standardize controller response model filenames
allenrobel Jun 9, 2025
680dc65
Controller response model cleanup (part 1)
allenrobel Jun 9, 2025
a0ea059
Appease linters
allenrobel Jun 9, 2025
10fdf75
Add temporary debug message
allenrobel Jun 9, 2025
79aff90
Appease linters
allenrobel Jun 9, 2025
3cc296e
Add REQUEST_PATH to controller response models, more…
allenrobel Jun 10, 2025
461b86b
UT: Use older fixtures for DCNMv11 unit tests
allenrobel Jun 10, 2025
96ed598
Standardize var names
allenrobel Jun 10, 2025
940d406
VrfTemplateConfigV12: bgp_passwd_encrypt validator
allenrobel Jun 10, 2025
4a89619
Revert last commit
allenrobel Jun 10, 2025
2a516d2
want_create: model-based handling, initial commit
allenrobel Jun 10, 2025
cb766ef
want_create -> want_create_models (part 2)
allenrobel Jun 10, 2025
4e727fb
want_create -> want_create_models (part 3)
allenrobel Jun 11, 2025
a4bf5f9
want_create -> want_create_models (part 4)
allenrobel Jun 11, 2025
1b94f4e
get_diff_query_for_vrfs_in_want: fix lookup
allenrobel Jun 11, 2025
47d96ac
want_create -> want_create_models (part 5)
allenrobel Jun 11, 2025
602d4eb
VrfPayloadV12: add field vrf_extension_template
allenrobel Jun 11, 2025
0f54f61
Rename methods/vars for clarity
allenrobel Jun 11, 2025
382c454
Add type hints and debug messages
allenrobel Jun 11, 2025
189a2a4
populate_have_deploy: return value directly
allenrobel Jun 12, 2025
42ab817
Appease pep8
allenrobel Jun 12, 2025
cc530f0
Consistent list var naming
allenrobel Jun 12, 2025
9763ce8
Rename method populate_have_attach_model
allenrobel Jun 12, 2025
51eef7b
Appease pep8
allenrobel Jun 12, 2025
9f93ded
get_diff_replace: leverage self.have_attach_models
allenrobel Jun 12, 2025
357e589
diff_merge_attach: leverage self.have_attach_models
allenrobel Jun 12, 2025
2e15089
diff_for_attach_deploy: leverage self.have_attach_models
allenrobel Jun 12, 2025
09de74a
PayloadVrfsAttachments: attachment payload validation
allenrobel Jun 13, 2025
0f2f8de
Appease sanity test
allenrobel Jun 13, 2025
2ace871
Revert relative import
allenrobel Jun 13, 2025
425723a
Standardize model filenames and class names
allenrobel Jun 13, 2025
bab9913
Appease sanity import and pep8 errors
allenrobel Jun 13, 2025
4e6287b
Update method to leverage model
allenrobel Jun 14, 2025
3ce6c8f
Run dcnm_vrf_v12.py through isort
allenrobel Jun 14, 2025
e69fed5
Appease pylint
allenrobel Jun 14, 2025
981c1f6
Fix update_attach_params_extension_values
allenrobel Jun 14, 2025
ff84ce1
Appease pep8
allenrobel Jun 14, 2025
b157183
Move dot1q validation to model
allenrobel Jun 14, 2025
5c24258
UT: model_playbook_vrf_v12.py
allenrobel Jun 14, 2025
9d6f59e
Appease pep8, more…
allenrobel Jun 14, 2025
11140d7
UT: PlaybookVrfLiteModel..dot1q validation
allenrobel Jun 14, 2025
baba33b
UT: vrf_lite.ipv4_addr validation
allenrobel Jun 15, 2025
ab6b939
UT: vrf_lite.ipv6_addr validation
allenrobel Jun 15, 2025
eb734ac
UT: vrf_lite.interface validation
allenrobel Jun 15, 2025
00d1d04
UT and model updates
allenrobel Jun 15, 2025
75713fe
UT: More unit tests for playbook models
allenrobel Jun 16, 2025
fc17d81
PlaybookVrfModelV12: Remove aliases
allenrobel Jun 17, 2025
133f550
UT: refactor vrf playbook tests
allenrobel Jun 17, 2025
6b7a6ee
Appease pylint
allenrobel Jun 17, 2025
f90f8ba
Appease pylint inappropriate error
allenrobel Jun 17, 2025
88359cc
Appease pylint by removing broken directive
allenrobel Jun 17, 2025
5bcca46
Appease import sanity test
allenrobel Jun 17, 2025
be8dcc5
UT: vrf model: rp_loopback_id
allenrobel Jun 18, 2025
83332cd
UT: vrf model: service_vrf_template
allenrobel Jun 18, 2025
7ecb14e
UT: vrf model: source
allenrobel Jun 18, 2025
dad0917
UT: vrf model: static_default_route
allenrobel Jun 18, 2025
386cae1
UT: vrf model: trm cases
allenrobel Jun 18, 2025
4d61df3
UT: multicast group tests
allenrobel Jun 18, 2025
4713ab5
UT: ip_address refactor
allenrobel Jun 18, 2025
1fc15b7
UT: vlan_id, vrf_description
allenrobel Jun 18, 2025
a028388
Fix vlan_id field_validator
allenrobel Jun 18, 2025
ef6eba6
UT: vrf_extension_template
allenrobel Jun 18, 2025
77d57d5
UT: Finish unit tests for VRF playbook
allenrobel Jun 18, 2025
56683b2
UT: vrf_name, update tests
allenrobel Jun 19, 2025
a72a8a6
Cherry-pick .github/workflows/main.yml from develop
allenrobel Jun 20, 2025
35fd575
Fix sorting of vrf names, and initial UT
allenrobel Jun 20, 2025
d56ac92
Align sanity/ignore-*.txt with develop branch
allenrobel Jun 20, 2025
58bb160
Appease linters
allenrobel Jun 20, 2025
90f7835
Remove ndfc_pc_members_validate.py
allenrobel Jun 20, 2025
deabe60
Appease sanity
allenrobel Jun 20, 2025
87c0405
Appease sanity
allenrobel Jun 20, 2025
10b5e48
UT: Refactor load_fixture.py
allenrobel Jun 20, 2025
24306cb
Appease pep8
allenrobel Jun 20, 2025
1ca638c
UT: PayloadVrfsAttachments, initial unit tests
allenrobel Jun 21, 2025
cb90746
UT: Fix definition of vrf_name_tests
allenrobel Jun 21, 2025
9a467de
1. tests/unit/module_utils/vrf/test_model_payload_vrfs_attachments.py
allenrobel Jun 21, 2025
92433fd
New model for instanceValues payload
allenrobel Jun 23, 2025
c4de1c6
Fix unit test, appease linters
allenrobel Jun 23, 2025
3a92bb2
DiffAttachToControllerPayload.commit() refactor
allenrobel Jun 23, 2025
8cc7336
UT: Rename v12 unit test fixture file to match v11
allenrobel Jun 24, 2025
33e7750
PayloadVrfsAttachments: validate extensionValues
allenrobel Jun 24, 2025
dac42aa
Experimental fix for 500 controller response
allenrobel Jun 24, 2025
85a1259
push_diff_attach_model: run payload thru json.dumps()
allenrobel Jun 24, 2025
409d4aa
PayloadVrfsAttachments: Fix serialization
allenrobel Jun 27, 2025
401e7aa
DiffAttachToControllerPayload: Modify payload assignment
allenrobel Jun 27, 2025
3745a46
ControllerResponseVrfsSwitchesSwitchDetails: optional fields
allenrobel Jun 28, 2025
984c575
Fix for attachment payload via model, more…
allenrobel Jun 29, 2025
8f77e83
IT: Log test titles to dcnm.log
allenrobel Jun 29, 2025
d045523
SerialNumberToVrfLite: Update docstrings
allenrobel Jun 29, 2025
50796ba
Initial controller response model and unit tests for Easy_Fabric
allenrobel Jun 29, 2025
da41147
Appease pep8 linter
allenrobel Jun 29, 2025
b1ce88a
Update tests/sanity/ignore-*.txt
allenrobel Jun 29, 2025
7525682
UT: Initial AI-generated test cases for NvPairs
allenrobel Jun 29, 2025
444999b
UT: Remove unused fixtures
allenrobel Jun 30, 2025
19c8e21
Update with detailed description of Ansible states
allenrobel Jul 10, 2025
3581cb1
Add license boilerplate and module docstring
allenrobel Jul 10, 2025
6c71b73
Restore original dcnm_vrf module, rename new vrf module to dcnm_vrf_v2
allenrobel Jul 11, 2025
f86ea21
Appease linters
allenrobel Jul 11, 2025
2d91591
Appease pep8 linter, update AnsibleStates enum
allenrobel Jul 11, 2025
b700357
Re-enable unit tests for dcnm_vrf_v2
allenrobel Jul 11, 2025
228cee3
PayloadVrfsDeployments: Fix typo in class name and update unit tests
allenrobel Jul 11, 2025
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
17 changes: 16 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ jobs:
with:
python-version: "3.10"

- name: Install dependencies
run: |
pip install --upgrade pip
pip install pydantic

- name: Install ansible-base (v${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/v${{ matrix.ansible }}.tar.gz --disable-pip-version-check

Expand All @@ -44,7 +49,6 @@ jobs:
path: .cache/v${{ matrix.ansible }}/collection-tarballs
overwrite: true


sanity:
name: Run ansible-sanity tests
needs:
Expand All @@ -63,6 +67,11 @@ jobs:
with:
python-version: ${{ matrix.python }}

- name: Install dependencies
run: |
pip install --upgrade pip
pip install pydantic

- name: Install ansible-base (v${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/v${{ matrix.ansible }}.tar.gz --disable-pip-version-check

Expand All @@ -89,11 +98,17 @@ jobs:
matrix:
ansible: [2.15.12, 2.16.7]
steps:

- name: Set up Python "3.10"
uses: actions/setup-python@v1
with:
python-version: "3.10"

- name: Install dependencies
run: |
pip install --upgrade pip
pip install pydantic

- name: Install ansible-base (v${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/v${{ matrix.ansible }}.tar.gz --disable-pip-version-check

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# 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.
# pylint: disable=line-too-long
from __future__ import absolute_import, division, print_function

__metaclass__ = type
__author__ = "Allen Robel"

import inspect
import logging

from ..top_down import TopDown


class Fabrics(TopDown):
"""
## api.v1.lan-fabric.rest.top-down.fabrics.Fabrics()

### Description
Common methods and properties for top-down.fabrics.Fabrics() subclasses.

### Path
- ``/api/v1/lan-fabric/rest/top_down/fabrics``
"""

def __init__(self):
super().__init__()
self.class_name = self.__class__.__name__
self.log = logging.getLogger(f"dcnm.{self.class_name}")
self.fabrics = f"{self.top_down}/fabrics"
msg = f"ENTERED api.v1.lan_fabric.rest.top_down.fabrics.{self.class_name}"
self.log.debug(msg)
self._build_properties()

def _build_properties(self):
"""
- Set the fabric_name property.
"""
self.properties["fabric_name"] = None
self.properties["ticket_id"] = None

@property
def fabric_name(self):
"""
- getter: Return the fabric_name.
- setter: Set the fabric_name.
- setter: Raise ``ValueError`` if fabric_name is not valid.
"""
return self.properties["fabric_name"]

@fabric_name.setter
def fabric_name(self, value):
method_name = inspect.stack()[0][3]
try:
self.conversion.validate_fabric_name(value)
except (TypeError, ValueError) as error:
msg = f"{self.class_name}.{method_name}: "
msg += f"{error}"
raise ValueError(msg) from error
self.properties["fabric_name"] = value

@property
def path_fabric_name(self):
"""
- Endpoint path property, including fabric_name.
- Raise ``ValueError`` if fabric_name is not set and
``self.required_properties`` contains "fabric_name".
"""
method_name = inspect.stack()[0][3]
if self.fabric_name is None and "fabric_name" in self.required_properties:
msg = f"{self.class_name}.{method_name}: "
msg += "fabric_name must be set prior to accessing path."
raise ValueError(msg)
return f"{self.fabrics}/{self.fabric_name}"

@property
def ticket_id(self):
"""
- getter: Return the ticket_id.
- setter: Set the ticket_id.
- setter: Raise ``ValueError`` if ticket_id is not a string.
- Default: None
- Note: ticket_id is optional unless Change Control is enabled.
"""
return self.properties["ticket_id"]

@ticket_id.setter
def ticket_id(self, value):
method_name = inspect.stack()[0][3]
if not isinstance(value, str):
msg = f"{self.class_name}.{method_name}: "
msg += f"Expected string for {method_name}. "
msg += f"Got {value} with type {type(value).__name__}."
raise ValueError(msg)
self.properties["ticket_id"] = value
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
# 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.
# pylint: disable=line-too-long
from __future__ import absolute_import, division, print_function

__metaclass__ = type
__author__ = "Allen Robel"

import inspect
import logging

from ..fabrics import Fabrics
from .........common.enums.http_requests import RequestVerb


class Vrfs(Fabrics):
"""
## api.v1.lan-fabric.rest.top-down.fabrics.Vrfs()

### Description
Common methods and properties for top-down.fabrics.Vrfs() subclasses.

### Path
- ``/api/v1/lan-fabric/rest/top-down/fabrics/{fabric_name}/vrfs``
"""

def __init__(self):
super().__init__()
self.class_name = self.__class__.__name__
self.log = logging.getLogger(f"dcnm.{self.class_name}")
self.fabrics = f"{self.top_down}/fabrics"
msg = f"ENTERED api.v1.lan_fabric.rest.top_down.fabrics.vrfs.{self.class_name}"
self.log.debug(msg)
self._build_properties()

def _build_properties(self):
"""
- Set the fabric_name property.
"""
self.properties["fabric_name"] = None
self.properties["ticket_id"] = None

@property
def fabric_name(self):
"""
- getter: Return the fabric_name.
- setter: Set the fabric_name.
- setter: Raise ``ValueError`` if fabric_name is not valid.
"""
return self.properties["fabric_name"]

@fabric_name.setter
def fabric_name(self, value):
method_name = inspect.stack()[0][3]
try:
self.conversion.validate_fabric_name(value)
except (TypeError, ValueError) as error:
msg = f"{self.class_name}.{method_name}: "
msg += f"{error}"
raise ValueError(msg) from error
self.properties["fabric_name"] = value

@property
def path_fabric_name(self):
"""
- Endpoint path property, including fabric_name.
- Raise ``ValueError`` if fabric_name is not set and
``self.required_properties`` contains "fabric_name".
"""
method_name = inspect.stack()[0][3]
if self.fabric_name is None and "fabric_name" in self.required_properties:
msg = f"{self.class_name}.{method_name}: "
msg += "fabric_name must be set prior to accessing path."
raise ValueError(msg)
return f"{self.fabrics}/{self.fabric_name}"

@property
def ticket_id(self):
"""
- getter: Return the ticket_id.
- setter: Set the ticket_id.
- setter: Raise ``ValueError`` if ticket_id is not a string.
- Default: None
- Note: ticket_id is optional unless Change Control is enabled.
"""
return self.properties["ticket_id"]

@ticket_id.setter
def ticket_id(self, value):
method_name = inspect.stack()[0][3]
if not isinstance(value, str):
msg = f"{self.class_name}.{method_name}: "
msg += f"Expected string for {method_name}. "
msg += f"Got {value} with type {type(value).__name__}."
raise ValueError(msg)
self.properties["ticket_id"] = value


class EpVrfGet(Fabrics):
"""
## V1 API - Vrfs().EpVrfGet()

### Description
Return endpoint information.

### Raises
- ``ValueError``: If fabric_name is not set.
- ``ValueError``: If fabric_name is invalid.

### Path
- ``/rest/top-down/fabrics/{fabric_name}/vrfs``

### Verb
- GET

### Parameters
- fabric_name: string
- set the ``fabric_name`` to be used in the path
- required
- path: retrieve the path for the endpoint
- verb: retrieve the verb for the endpoint

### Usage
```python
instance = EpVrfGet()
instance.fabric_name = "MyFabric"
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}")
self.required_properties.add("fabric_name")
self._build_properties()
msg = "ENTERED api.v1.lan_fabric.rest.top_down.fabrics.vrfs."
msg += f"Vrfs.{self.class_name}"
self.log.debug(msg)

def _build_properties(self):
super()._build_properties()
self.properties["verb"] = RequestVerb.GET

@property
def path(self):
"""
- Endpoint for VRF GET request.
- Raise ``ValueError`` if fabric_name is not set.
"""
return f"{self.path_fabric_name}/vrfs"


class EpVrfPost(Fabrics):
"""
## V1 API - Vrfs().EpVrfPost()

### Description
Return endpoint information.

### Raises
- ``ValueError``: If fabric_name is not set.
- ``ValueError``: If fabric_name is invalid.

### Path
- ``/rest/top-down/fabrics/{fabric_name}/vrfs``

### Verb
- POST

### Parameters
- fabric_name: string
- set the ``fabric_name`` to be used in the path
- required
- path: retrieve the path for the endpoint
- verb: retrieve the verb for the endpoint

### Usage
```python
instance = EpVrfPost()
instance.fabric_name = "MyFabric"
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}")
self.required_properties.add("fabric_name")
self._build_properties()
msg = "ENTERED api.v1.lan_fabric.rest.top_down.fabrics.vrfs."
msg += f"Vrfs.{self.class_name}"
self.log.debug(msg)

def _build_properties(self):
super()._build_properties()
self.properties["verb"] = RequestVerb.POST

@property
def path(self):
"""
- Endpoint for VRF POST request.
- Raise ``ValueError`` if fabric_name is not set.
"""
return f"{self.path_fabric_name}/vrfs"
Loading