Skip to content

Commit a50a3f8

Browse files
Add support for IP settings in interfaces.yml
1 parent 2df4cf5 commit a50a3f8

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

docs/reporef/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,14 @@ Keys for interfaces.yml or interfaces_<model>.yml:
404404
* aggregate_id: Optional. Identifier for configuring LACP etc. Integer value.
405405
Special value -1 means configure MLAG and use ID based on indexnum.
406406
* tags: Optional list of strings, custom user defined tags to apply.
407+
* vrf: Optional VRF instance, must be specified if IP adress is specified
408+
* ipv4_address: Optional IPv4 address for the interface
409+
* ipv6_address: Optional IPv6 address for the interface
410+
* mtu: Optional integer specifying MTU size
411+
* acl_ipv4_in: Access control list to apply for ingress IPv4 traffic to interface. Optional.
412+
* acl_ipv4_out: Access control list to apply for egress IPv4 traffic from interface. Optional.
413+
* acl_ipv6_in: Access control list to apply for ingress IPv6 traffic to interface. Optional.
414+
* acl_ipv6_out: Access control list to apply for egress IPv6 traffic from interface. Optional.
407415
* cli_append_str: Optional. Custom configuration to append to this interface.
408416

409417
The "downlink" ifclass is used on DIST devices to specify that this interface

src/cnaas_nms/db/settings_fields.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,24 @@ class f_interface(BaseModel):
139139
tagged_vlan_list: Optional[List[int]] = None
140140
aggregate_id: Optional[int] = None
141141
tags: Optional[List[str]] = None
142+
vrf: Optional[str] = vlan_name_schema
143+
ipv4_address: Optional[str] = None
144+
ipv6_address: Optional[str] = ipv6_if_schema
145+
mtu: Optional[int] = mtu_schema
146+
acl_ipv4_in: Optional[str] = None
147+
acl_ipv4_out: Optional[str] = None
148+
acl_ipv6_in: Optional[str] = None
149+
acl_ipv6_out: Optional[str] = None
142150
cli_append_str: str = ""
143151

152+
@validator("ipv4_address")
153+
def vrf_required_if_ipv4_address_set(cls, v, values, **kwargs):
154+
if v:
155+
validate_ipv4_if(v)
156+
if "vrf" not in values or not values["vrf"]:
157+
raise ValueError("VRF is required when specifying ipv4_gw")
158+
return v
159+
144160
@validator("tagged_vlan_list", each_item=True)
145161
def check_valid_vlan_ids(cls, v):
146162
assert 0 < v < 4096

0 commit comments

Comments
 (0)