-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix(plugins): Prevent deprecation warnings when deprecated filters ar…
…e not used (#4199) Co-authored-by: Carl Buchmann <[email protected]>
- Loading branch information
1 parent
72b2d27
commit 5b4b171
Showing
12 changed files
with
162 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
ansible_collections/arista/avd/plugins/filter/deprecated_filters.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright (c) 2023-2024 Arista Networks, Inc. | ||
# Use of this source code is governed by the Apache License 2.0 | ||
# that can be found in the LICENSE file. | ||
# | ||
# deprecated filters - grouped together to avoid Ansible to generate warning on loading the module name... | ||
# | ||
|
||
__metaclass__ = type | ||
|
||
from ansible.errors import AnsibleFilterError | ||
|
||
from ansible_collections.arista.avd.plugins.plugin_utils.pyavd_wrappers import RaiseOnUse, wrap_filter | ||
|
||
PLUGIN_NAME_1 = "arista.avd.generate_lacp_id" | ||
PLUGIN_NAME_2 = "arista.avd.generate_esi" | ||
PLUGIN_NAME_3 = "arista.avd.generate_route_target" | ||
|
||
try: | ||
from pyavd.j2filters import generate_esi, generate_lacp_id, generate_route_target | ||
except ImportError as e: | ||
generate_lacp_id = RaiseOnUse( | ||
AnsibleFilterError( | ||
f"The '{PLUGIN_NAME_1}' plugin requires the 'pyavd' Python library. Got import error", | ||
orig_exc=e, | ||
) | ||
) | ||
generate_esi = RaiseOnUse( | ||
AnsibleFilterError( | ||
f"The '{PLUGIN_NAME_2}' plugin requires the 'pyavd' Python library. Got import error", | ||
orig_exc=e, | ||
) | ||
) | ||
generate_route_target = RaiseOnUse( | ||
AnsibleFilterError( | ||
f"The '{PLUGIN_NAME_3}' plugin requires the 'pyavd' Python library. Got import error", | ||
orig_exc=e, | ||
) | ||
) | ||
|
||
|
||
class FilterModule(object): | ||
def filters(self): | ||
return { | ||
"generate_lacp_id": wrap_filter(PLUGIN_NAME_1)(generate_lacp_id), | ||
"generate_esi": wrap_filter(PLUGIN_NAME_2)(generate_esi), | ||
"generate_route_target": wrap_filter(PLUGIN_NAME_3)(generate_route_target), | ||
} |
66 changes: 0 additions & 66 deletions
66
ansible_collections/arista/avd/plugins/filter/generate_esi.py
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
ansible_collections/arista/avd/plugins/filter/generate_esi.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
DOCUMENTATION: | ||
name: generate_esi | ||
collection: arista.avd | ||
author: Arista Ansible Team (@aristanetworks) | ||
version_added: "1.1" | ||
short_description: Transforms short_esi `0303:0202:0101` to EVPN ESI format `0000:0000:0303:0202:0101` | ||
description: Concatenates the given `esi_prefix` and `short_esi`. | ||
positional: _input | ||
options: | ||
_input: | ||
description: Short ESI value as per AVD definition in eos_designs. | ||
type: string | ||
required: true | ||
esi_prefix: | ||
description: ESI prefix value. Will be concatenated with the `short_esi`. | ||
type: string | ||
default: "0000:0000:" | ||
deprecated: | ||
removed_in: "5.0.0" | ||
why: This filter is no longer used by AVD and is very simple to replace with generic Jinja syntax. | ||
alternative: Use Jinja string concatenation instead like `{{ <esi_prefix> ~ <short_esi> }}` | ||
|
||
EXAMPLES: | | ||
--- | ||
esi: "{{ short_esi | arista.avd.generate_esi('deaf:beed:') }}" | ||
RETURN: | ||
_value: | ||
description: Concatenated string of `esi_prefix` and `short_esi` like `0000:0000:0303:0202:0101` | ||
type: string |
61 changes: 0 additions & 61 deletions
61
ansible_collections/arista/avd/plugins/filter/generate_lacp_id.py
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
ansible_collections/arista/avd/plugins/filter/generate_lacp_id.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
DOCUMENTATION: | ||
name: generate_lacp_id | ||
collection: arista.avd | ||
author: Arista Ansible Team (@aristanetworks) | ||
version_added: "1.1" | ||
short_description: Transforms short_esi `0303:0202:0101` to LACP ID format `0303.0202.0101` | ||
description: Replaces `:` with `.` | ||
positional: _input | ||
options: | ||
_input: | ||
description: Short ESI value as per AVD definition in eos_designs. | ||
type: string | ||
required: true | ||
deprecated: | ||
removed_in: "5.0.0" | ||
why: This filter is no longer used by AVD and is very simple to replace with a generic Jinja filter. | ||
alternative: Use the builtin `replace` filter instead like `{{ <short_esi> | replace(':', '.') }}` | ||
|
||
EXAMPLES: |- | ||
--- | ||
lacp_id: "{{ short_esi | arista.avd.generate_lacp_id }}" | ||
RETURN: | ||
_value: | ||
description: String based on LACP ID format like 0303.0202.0101 | ||
type: string |
63 changes: 0 additions & 63 deletions
63
ansible_collections/arista/avd/plugins/filter/generate_route_target.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.