Skip to content

Commit

Permalink
Feat(eos_cli_config_gen): DHCP Server data model (#3269)
Browse files Browse the repository at this point in the history
Co-authored-by: Guillaume Mulocher <[email protected]>
  • Loading branch information
emilarista and gmuloc authored Jan 3, 2024
1 parent de33210 commit 82ad975
Show file tree
Hide file tree
Showing 13 changed files with 899 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# dhcp-servers

## Table of Contents

- [Management](#management)
- [Management Interfaces](#management-interfaces)
- [DHCP Server](#dhcp-server)
- [DHCP Servers Summary](#dhcp-servers-summary)
- [DHCP Server Configuration](#dhcp-server-configuration)

## Management

### Management Interfaces

#### Management Interfaces Summary

##### IPv4

| Management Interface | description | Type | VRF | IP Address | Gateway |
| -------------------- | ----------- | ---- | --- | ---------- | ------- |
| Management1 | oob_management | oob | MGMT | 10.73.255.122/24 | 10.73.255.2 |

##### IPv6

| Management Interface | description | Type | VRF | IPv6 Address | IPv6 Gateway |
| -------------------- | ----------- | ---- | --- | ------------ | ------------ |
| Management1 | oob_management | oob | MGMT | - | - |

#### Management Interfaces Device Configuration

```eos
!
interface Management1
description oob_management
vrf MGMT
ip address 10.73.255.122/24
```

## DHCP Server

### DHCP Servers Summary

| DHCP Server Enabled | VRF | IPv4 DNS Domain | IPv6 DNS Domain |
| ------------------- | --- | --------------- | --------------- |
| True | AVRF | - | - |
| True | defauls | - | - |
| True | default | - | - |
| True | defaulu | - | - |
| True | TEST | testv4.com | testv6.com |
| False | VRF01 | - | - |

#### VRF AVRF DHCP Server

##### Subnets

| Subnet | Name | DNS Servers | Default Gateway | Lease Time | Ranges |
| ------ | ---- | ----------- | --------------- | ---------- | ------ |
| 172.16.254.0/24 | - | - | 172.16.254.1 | - | - |

#### VRF default DHCP Server

##### Subnets

| Subnet | Name | DNS Servers | Default Gateway | Lease Time | Ranges |
| ------ | ---- | ----------- | --------------- | ---------- | ------ |
| 2a00:2::/64 | - | - | - | - | - |
| 10.2.3.0/24 | - | - | - | - | - |

#### VRF TEST DHCP Server

##### Subnets

| Subnet | Name | DNS Servers | Default Gateway | Lease Time | Ranges |
| ------ | ---- | ----------- | --------------- | ---------- | ------ |
| 10.0.0.0/24 | TEST1 | 10.1.1.12, 10.1.1.13 | 10.0.0.1 | 0 days, 0 hours, 10 minutes | 10.0.0.10-10.0.0.100, 10.0.0.110-10.0.0.120 |

##### IPv4 Vendor Options

| Vendor ID | Sub-option Code | Sub-option Type | Sub-option Data |
| --------- | ----------------| --------------- | --------------- |
| NTP | 1 | string | test |
| NTP | 42 | ipv4-address | 10.1.1.1 |
| NTP | 66 | array ipv4-address | 1.1.1.1 2.2.2.2 |

#### VRF VRF01 DHCP Server

##### Subnets

| Subnet | Name | DNS Servers | Default Gateway | Lease Time | Ranges |
| ------ | ---- | ----------- | --------------- | ---------- | ------ |
| 192.168.0.0/24 | - | - | - | - | - |

### DHCP Server Configuration

```eos
!
dhcp server vrf AVRF
!
subnet 172.16.254.0/24
default-gateway 172.16.254.1
!
dhcp server vrf defauls
!
dhcp server
!
subnet 2a00:2::/64
!
subnet 10.2.3.0/24
!
dhcp server vrf defaulu
!
dhcp server vrf TEST
dns domain name ipv4 testv4.com
dns domain name ipv6 testv6.com
!
subnet 10.0.0.0/24
!
range 10.0.0.10 10.0.0.100
!
range 10.0.0.110 10.0.0.120
name TEST1
dns server 10.1.1.12 10.1.1.13
lease time 0 days 0 hours 10 minutes
default-gateway 10.0.0.1
!
vendor-option ipv4 NTP
sub-option 1 type string data "test"
sub-option 42 type ipv4-address data 10.1.1.1
sub-option 66 type array ipv4-address data 1.1.1.1 2.2.2.2
!
dhcp server vrf VRF01
!
subnet 192.168.0.0/24
disabled
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
!RANCID-CONTENT-TYPE: arista
!
dhcp server vrf AVRF
!
subnet 172.16.254.0/24
default-gateway 172.16.254.1
!
dhcp server vrf defauls
!
dhcp server
!
subnet 2a00:2::/64
!
subnet 10.2.3.0/24
!
dhcp server vrf defaulu
!
dhcp server vrf TEST
dns domain name ipv4 testv4.com
dns domain name ipv6 testv6.com
!
subnet 10.0.0.0/24
!
range 10.0.0.10 10.0.0.100
!
range 10.0.0.110 10.0.0.120
name TEST1
dns server 10.1.1.12 10.1.1.13
lease time 0 days 0 hours 10 minutes
default-gateway 10.0.0.1
!
vendor-option ipv4 NTP
sub-option 1 type string data "test"
sub-option 42 type ipv4-address data 10.1.1.1
sub-option 66 type array ipv4-address data 1.1.1.1 2.2.2.2
!
dhcp server vrf VRF01
!
subnet 192.168.0.0/24
disabled
!
transceiver qsfp default-mode 4x10G
!
hostname dhcp-servers
!
no enable password
no aaa root
!
interface Management1
description oob_management
vrf MGMT
ip address 10.73.255.122/24
!
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
dhcp_servers:
- vrf: defauls
- vrf: defaulu
- vrf: TEST
ipv4_vendor_options:
- vendor_id: NTP
sub_options:
- code: 42
ipv4_address: "10.1.1.1"
- code: 1
string: "test"
- code: 66
array_ipv4_address: [1.1.1.1, 2.2.2.2]
disabled: false
dns_domain_name_ipv4: testv4.com
dns_domain_name_ipv6: testv6.com
subnets:
- subnet: 10.0.0.0/24 # required
name: TEST1
ranges:
- start: 10.0.0.110 # required
end: 10.0.0.120 # required
- start: 10.0.0.10 # required
end: 10.0.0.100 # required
dns_servers:
- 10.1.1.12
- 10.1.1.13
lease_time:
days: 0
hours: 0
minutes: 10
default_gateway: 10.0.0.1

- vrf: default
subnets:
- subnet: 10.2.3.0/24
- subnet: 2a00:2::/64

- vrf: VRF01
subnets:
- subnet: 192.168.0.0/24
disabled: true

- vrf: AVRF
subnets:
- subnet: 172.16.254.0/24
default_gateway: 172.16.254.1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ daemons
dps-interfaces
dns-ntp
dhcp-relay
dhcp-servers
dot1x
dot1x-2
enable-password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,11 @@ roles/eos_cli_config_gen/docs/tables/ip-dhcp-relay.md

--8<--
roles/eos_cli_config_gen/docs/tables/ip-dhcp-snooping.md

### DHCP Servers

--8<--
roles/eos_cli_config_gen/docs/tables/dhcp-servers.md
--8<--

### IP ICMP redirect
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!--
~ 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.
-->
=== "Table"

| Variable | Type | Required | Default | Value Restrictions | Description |
| -------- | ---- | -------- | ------- | ------------------ | ----------- |
| [<samp>dhcp_servers</samp>](## "dhcp_servers") | List, items: Dictionary | | | | |
| [<samp>&nbsp;&nbsp;-&nbsp;disabled</samp>](## "dhcp_servers.[].disabled") | Boolean | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;vrf</samp>](## "dhcp_servers.[].vrf") | String | Required, Unique | | | VRF in which to configure the DHCP server, use `default` to indicate default VRF. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;dns_domain_name_ipv4</samp>](## "dhcp_servers.[].dns_domain_name_ipv4") | String | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;dns_domain_name_ipv6</samp>](## "dhcp_servers.[].dns_domain_name_ipv6") | String | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;ipv4_vendor_options</samp>](## "dhcp_servers.[].ipv4_vendor_options") | List, items: Dictionary | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;vendor_id</samp>](## "dhcp_servers.[].ipv4_vendor_options.[].vendor_id") | String | Required, Unique | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sub_options</samp>](## "dhcp_servers.[].ipv4_vendor_options.[].sub_options") | List, items: Dictionary | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;code</samp>](## "dhcp_servers.[].ipv4_vendor_options.[].sub_options.[].code") | Integer | Required, Unique | | Min: 1<br>Max: 254 | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string</samp>](## "dhcp_servers.[].ipv4_vendor_options.[].sub_options.[].string") | String | | | | String value for suboption data.<br>Only one of `string`, `ipv4_address` and `array_ipv4_address` variables should be used for any one suboption.<br>The order of precedence if multiple of these variables are defined is `string` -> `ipv4_address` -> `array_ipv4_address`. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ipv4_address</samp>](## "dhcp_servers.[].ipv4_vendor_options.[].sub_options.[].ipv4_address") | String | | | | IPv4 address value for suboption data.<br>Only one of `string`, `ipv4_address` and `array_ipv4_address` variables should be used for any one suboption.<br>The order of precedence if multiple of these variables are defined is `string` -> `ipv4_address` -> `array_ipv4_address`. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array_ipv4_address</samp>](## "dhcp_servers.[].ipv4_vendor_options.[].sub_options.[].array_ipv4_address") | List, items: String | | | | Array of IPv4 addresses for suboption data.<br>Only one of `string`, `ipv4_address` and `array_ipv4_address` variables should be used for any one suboption.<br>The order of precedence if multiple of these variables are defined is `string` -> `ipv4_address` -> `array_ipv4_address`. |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lt;str&gt;</samp>](## "dhcp_servers.[].ipv4_vendor_options.[].sub_options.[].array_ipv4_address.[]") | String | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;subnets</samp>](## "dhcp_servers.[].subnets") | List, items: Dictionary | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;subnet</samp>](## "dhcp_servers.[].subnets.[].subnet") | String | Required, Unique | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name</samp>](## "dhcp_servers.[].subnets.[].name") | String | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default_gateway</samp>](## "dhcp_servers.[].subnets.[].default_gateway") | String | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dns_servers</samp>](## "dhcp_servers.[].subnets.[].dns_servers") | List, items: String | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;&lt;str&gt;</samp>](## "dhcp_servers.[].subnets.[].dns_servers.[]") | String | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ranges</samp>](## "dhcp_servers.[].subnets.[].ranges") | List, items: Dictionary | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;start</samp>](## "dhcp_servers.[].subnets.[].ranges.[].start") | String | Required | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end</samp>](## "dhcp_servers.[].subnets.[].ranges.[].end") | String | Required | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lease_time</samp>](## "dhcp_servers.[].subnets.[].lease_time") | Dictionary | | | | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;days</samp>](## "dhcp_servers.[].subnets.[].lease_time.days") | Integer | Required | | Min: 0<br>Max: 2000 | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hours</samp>](## "dhcp_servers.[].subnets.[].lease_time.hours") | Integer | Required | | Min: 0<br>Max: 23 | |
| [<samp>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minutes</samp>](## "dhcp_servers.[].subnets.[].lease_time.minutes") | Integer | Required | | Min: 0<br>Max: 59 | |

=== "YAML"

```yaml
dhcp_servers:
- disabled: <bool>

# VRF in which to configure the DHCP server, use `default` to indicate default VRF.
vrf: <str; required; unique>
dns_domain_name_ipv4: <str>
dns_domain_name_ipv6: <str>
ipv4_vendor_options:
- vendor_id: <str; required; unique>
sub_options:
- code: <int; 1-254; required; unique>

# String value for suboption data.
# Only one of `string`, `ipv4_address` and `array_ipv4_address` variables should be used for any one suboption.
# The order of precedence if multiple of these variables are defined is `string` -> `ipv4_address` -> `array_ipv4_address`.
string: <str>

# IPv4 address value for suboption data.
# Only one of `string`, `ipv4_address` and `array_ipv4_address` variables should be used for any one suboption.
# The order of precedence if multiple of these variables are defined is `string` -> `ipv4_address` -> `array_ipv4_address`.
ipv4_address: <str>

# Array of IPv4 addresses for suboption data.
# Only one of `string`, `ipv4_address` and `array_ipv4_address` variables should be used for any one suboption.
# The order of precedence if multiple of these variables are defined is `string` -> `ipv4_address` -> `array_ipv4_address`.
array_ipv4_address:
- <str>
subnets:
- subnet: <str; required; unique>
name: <str>
default_gateway: <str>
dns_servers:
- <str>
ranges:
- start: <str; required>
end: <str; required>
lease_time:
days: <int; 0-2000; required>
hours: <int; 0-23; required>
minutes: <int; 0-59; required>
```
Loading

0 comments on commit 82ad975

Please sign in to comment.