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

Feat(eos_designs): Add default_mgmt_method to be used later in new management settings. #3328

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from functools import cached_property
from typing import TYPE_CHECKING

from ansible_collections.arista.avd.plugins.plugin_utils.errors import AristaAvdMissingVariableError
from ansible_collections.arista.avd.plugins.plugin_utils.utils import default, get

if TYPE_CHECKING:
Expand Down Expand Up @@ -54,3 +55,43 @@ def mgmt_gateway(self: SharedUtils) -> str | None:
@cached_property
def ipv6_mgmt_gateway(self: SharedUtils) -> str | None:
return get(self.hostvars, "ipv6_mgmt_gateway")

@cached_property
def default_mgmt_method(self: SharedUtils) -> str | None:
"""
This is only executed if some protocol looks for the default value, so we can raise here to ensure a working config.
ClausHolbechArista marked this conversation as resolved.
Show resolved Hide resolved
"""
default_mgmt_method = get(self.hostvars, "default_mgmt_method", default="oob")
if default_mgmt_method == "oob":
if (self.mgmt_ip is None) and (self.ipv6_mgmt_ip is None):
raise AristaAvdMissingVariableError("'default_mgmt_method: oob' requires either 'mgmt_ip' or 'ipv6_mgmt_ip' to bet set.")

return default_mgmt_method

elif default_mgmt_method == "inband":
# Check for missing interface
if self.inband_mgmt_interface is None:
raise AristaAvdMissingVariableError("'default_mgmt_method: inband' requires 'inband_mgmt_interface' to be set.")

return default_mgmt_method

return None

@cached_property
def default_mgmt_protocol_vrf(self: SharedUtils) -> str | None:
if self.default_mgmt_method == "oob":
return self.mgmt_interface_vrf
elif self.default_mgmt_method == "inband":
# inband_mgmt_vrf returns None for vrf default.
return self.inband_mgmt_vrf or "default"

return None

@cached_property
def default_mgmt_protocol_interface(self: SharedUtils) -> str | None:
if self.default_mgmt_method == "oob":
return self.mgmt_interface
elif self.default_mgmt_method == "inband":
return self.inband_mgmt_interface

return None
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

| Variable | Type | Required | Default | Value Restrictions | Description |
| -------- | ---- | -------- | ------- | ------------------ | ----------- |
| [<samp>default_mgmt_method</samp>](## "default_mgmt_method") | String | | `oob` | Valid Values:<br>- oob<br>- inband<br>- none | `default_mgmt_method` controls the default VRF and source interface used for the following management and monitoring protocols configured with `eos_designs`:<br> - `cv_settings`<br> - `dns_settings`<br> - `ntp_settings`<br> - `sflow_settings`<br><br>`oob` means the protocols will be configured with the VRF set by `mgmt_interface_vrf` and `mgmt_interface` as source interface.<br>`inband` means the protocols will be configured with the VRF set by `inband_mgmt_vrf` and `inband_mgmt_interface` as source interface.<br>`none` means the VRF and or interface must be manually set for each protocol.<br>This can be overriden under the settings for each protocol.<br> |
carlbuchmann marked this conversation as resolved.
Show resolved Hide resolved
| [<samp>mgmt_destination_networks</samp>](## "mgmt_destination_networks") | List, items: String | | | | List of IPv4 prefixes to configure as static routes towards the OOB Management interface gateway.<br>Replaces the default route. |
| [<samp>&nbsp;&nbsp;- &lt;str&gt;</samp>](## "mgmt_destination_networks.[].&lt;str&gt;") | String | | | | IPv4_address/Mask. |
| [<samp>mgmt_gateway</samp>](## "mgmt_gateway") | String | | | | OOB Management interface gateway in IPv4 format.<br>Used as next-hop for default gateway or static routes defined under 'mgmt_destination_networks'. |
Expand All @@ -18,6 +19,7 @@
=== "YAML"

```yaml
default_mgmt_method: <str>
mgmt_destination_networks:
- <str>
mgmt_gateway: <str>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3079,6 +3079,17 @@
},
"title": "Default Interfaces"
},
"default_mgmt_method": {
"type": "string",
"description": "`default_mgmt_method` controls the default VRF and source interface used for the following management and monitoring protocols configured with `eos_designs`:\n - `cv_settings`\n - `dns_settings`\n - `ntp_settings`\n - `sflow_settings`\n\n`oob` means the protocols will be configured with the VRF set by `mgmt_interface_vrf` and `mgmt_interface` as source interface.\n`inband` means the protocols will be configured with the VRF set by `inband_mgmt_vrf` and `inband_mgmt_interface` as source interface.\n`none` means the VRF and or interface must be manually set for each protocol.\nThis can be overriden under the settings for each protocol.\n",
carlbuchmann marked this conversation as resolved.
Show resolved Hide resolved
"enum": [
"oob",
"inband",
"none"
],
"default": "oob",
"title": "Default Management Method"
},
"default_node_types": {
"type": "array",
"description": "Uses hostname matches against a regular expression to determine the node type.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,23 @@ keys:
items:
type: str
description: Interface range or interface.
default_mgmt_method:
documentation_options:
table: management-interface-settings
type: str
description: "`default_mgmt_method` controls the default VRF and source interface
used for the following management and monitoring protocols configured with `eos_designs`:\n
\ - `cv_settings`\n - `dns_settings`\n - `ntp_settings`\n - `sflow_settings`\n\n`oob`
means the protocols will be configured with the VRF set by `mgmt_interface_vrf`
and `mgmt_interface` as source interface.\n`inband` means the protocols will
be configured with the VRF set by `inband_mgmt_vrf` and `inband_mgmt_interface`
as source interface.\n`none` means the VRF and or interface must be manually
carlbuchmann marked this conversation as resolved.
Show resolved Hide resolved
set for each protocol.\nThis can be overriden under the settings for each protocol.\n"
carlbuchmann marked this conversation as resolved.
Show resolved Hide resolved
valid_values:
- oob
- inband
- none
default: oob
default_node_types:
type: list
primary_key: node_type
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) 2023 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
# yaml-language-server: $schema=../../../../plugins/plugin_utils/schema/avd_meta_schema.json
# Line above is used by RedHat's YAML Schema vscode extension
# Use Ctrl + Space to get suggestions for every field. Autocomplete will pop up after typing 2 letters.
type: dict
keys:
default_mgmt_method:
documentation_options:
table: management-interface-settings
type: str
description: |
`default_mgmt_method` controls the default VRF and source interface used for the following management and monitoring protocols configured with `eos_designs`:
- `cv_settings`
- `dns_settings`
- `ntp_settings`
- `sflow_settings`

`oob` means the protocols will be configured with the VRF set by `mgmt_interface_vrf` and `mgmt_interface` as source interface.
carlbuchmann marked this conversation as resolved.
Show resolved Hide resolved
`inband` means the protocols will be configured with the VRF set by `inband_mgmt_vrf` and `inband_mgmt_interface` as source interface.
carlbuchmann marked this conversation as resolved.
Show resolved Hide resolved
`none` means the VRF and or interface must be manually set for each protocol.
This can be overriden under the settings for each protocol.
carlbuchmann marked this conversation as resolved.
Show resolved Hide resolved
valid_values:
- oob
- inband
- none
default: oob