Skip to content

Commit

Permalink
[Yang model] Add Yang models for VNET table. (#14873)
Browse files Browse the repository at this point in the history
Created Yang Modle for VNET table.
#14534

##### Work item tracking
- Microsoft ADO **(number only)**:
18215579
  • Loading branch information
siqbal1986 authored May 18, 2023
1 parent c5d0507 commit c900abb
Show file tree
Hide file tree
Showing 6 changed files with 353 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Table of Contents
* [Versions](#versions)
* [VLAN](#vlan)
* [VLAN_MEMBER](#vlan_member)
* [VNET](#vnet)
* [VOQ Inband Interface](#voq-inband-interface)
* [VXLAN](#vxlan)
* [Virtual router](#virtual-router)
Expand Down Expand Up @@ -2067,6 +2068,33 @@ channel name as object key, and tagging mode as attributes.
}
```

### VNET

VNET table has Vnet name as the object key, and vxlan_tunnel name, scope, vni, peer list, advertised prefix, src mac, and overlay dest mac as attributes.
The vxlan_tunnel name (mandatory) is the tunnel name from the VXLAN table. scope (optional) must "default", vni (mandatory) is the vxlan tunnel vni, peer_list (optional) is for Vnet
peering, advertise_prefix (optional) is used to allow advertisement of this vnet's routes, overlay_dmac (optional) is the mac address which is used for VNET ping
monitoring sessions for the vnet routes and is optional.

```
{
"VNET": {
"Vnet1-1": {
"vxlan_tunnel": "vtep1",
"scope": "default",
"vni": "10011",
"peer_list": "",
"advertise_prefix": "true",
"overlay_dmac": "22:33:44:55:66:77"
},
"Vnetv4_v4-0": {
"vxlan_tunnel": "vtep2",
"scope": "default",
"vni": "10011",
}
}
}
```

### VOQ INBAND INTERFACE

VOQ_INBAND_INTERFACE holds the name of the inband system port dedicated for cpu communication. At this time, only inband_type of "port" is supported
Expand Down
1 change: 1 addition & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def run(self):
'./yang-models/sonic-types.yang',
'./yang-models/sonic-versions.yang',
'./yang-models/sonic-vlan.yang',
'./yang-models/sonic-vnet.yang',
'./yang-models/sonic-voq-inband-interface.yang',
'./yang-models/sonic-vxlan.yang',
'./yang-models/sonic-vrf.yang',
Expand Down
10 changes: 10 additions & 0 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -2024,6 +2024,16 @@
"vlan": "Vlan100"
}
},
"VNET": {
"vnet1": {
"vxlan_tunnel": "vtep1",
"scope": "default",
"vni": "100",
"peer_list": "",
"advertise_prefix": "true",
"overlay_dmac": "22:33:44:55:66:77"
}
},
"PORT_QOS_MAP": {
"Ethernet0": {
"dot1p_to_tc_map" : "Dot1p_to_tc_map1",
Expand Down
28 changes: 28 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/vnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"VNET_VALID_TEST1": {
"desc": "Valid VNET Configuration."
},
"VNET_VALID_TEST2": {
"desc": "Valid VNET Configuration."
},
"VNET_INVALID_VALUE_TEST1": {
"desc": "Invalid values in parameters.",
"eStr": [ "Invalid VRF name" ]
},
"VNET_INVALID_VALUE_TEST2": {
"desc": "Invalid values in parameters.",
"eStr": [ "Invalid value" ]
},
"VNET_INVALID_VALUE_TEST3": {
"desc": "Invalid values in parameters.",
"eStr": [ "does not satisfy the constraint" ]
},
"VNET_INVALID_VALUE_TEST4": {
"desc": "Invalid values in parameters.",
"eStr": [ "does not satisfy the constraint" ]
},
"VNET_INVALID_VXLAN_VTEP": {
"desc": "Missing Vxlan_TUNNEL configuration",
"eStr" : [ "points to a non-existing leaf" ]
}
}
182 changes: 182 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/vnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
{
"VNET_VALID_TEST1": {
"sonic-vxlan:sonic-vxlan": {
"sonic-vxlan:VXLAN_TUNNEL": {
"VXLAN_TUNNEL_LIST": [
{
"name": "vtep1",
"src_ip": "1.2.3.4"
}
]
}
},
"sonic-vnet:sonic-vnet": {
"sonic-vnet:VNET": {
"VNET_LIST": [
{
"name" : "def",
"vxlan_tunnel": "vtep1",
"vni": "10011"
}
]
}
}
},
"VNET_VALID_TEST2": {
"sonic-vxlan:sonic-vxlan": {
"sonic-vxlan:VXLAN_TUNNEL": {
"VXLAN_TUNNEL_LIST": [
{
"name": "vtep1",
"src_ip": "1.2.3.4"
}
]
}
},
"sonic-vnet:sonic-vnet": {
"sonic-vnet:VNET": {
"VNET_LIST": [
{
"name" : "abcd",
"vxlan_tunnel": "vtep1",
"scope": "default",
"vni": "10011",
"peer_list": "",
"advertise_prefix": "true",
"overlay_dmac": "22:33:44:55:66:77"
}
]
}
}
},
"VNET_INVALID_VALUE_TEST1": {
"sonic-vxlan:sonic-vxlan": {
"sonic-vxlan:VXLAN_TUNNEL": {
"VXLAN_TUNNEL_LIST": [
{
"name": "vtep1",
"src_ip": "1.2.3.4"
}
]
}
},
"sonic-vnet:sonic-vnet": {
"sonic-vnet:VNET": {
"VNET_LIST": [

{
"name" : "abcd-1",
"vxlan_tunnel": "vtep1",
"scope": "Vrf_blue",
"vni": "10011",
"peer_list": "",
"advertise_prefix": "true",
"overlay_dmac": "22:33:44:55:66:77"
}
]
}
}
},
"VNET_INVALID_VALUE_TEST2": {
"sonic-vxlan:sonic-vxlan": {
"sonic-vxlan:VXLAN_TUNNEL": {
"VXLAN_TUNNEL_LIST": [
{
"name": "vtep1",
"src_ip": "1.2.3.4"
}
]
}
},
"sonic-vnet:sonic-vnet": {
"sonic-vnet:VNET": {
"VNET_LIST": [
{
"name" : "abcdfg",
"vxlan_tunnel": "vtep1",
"scope": "default",
"vni": "999999999999",
"advertise_prefix": "unknown",
"overlay_dmac": "22:33:44:55:66:77"
}
]
}
}
},
"VNET_INVALID_VALUE_TEST3": {
"sonic-vxlan:sonic-vxlan": {
"sonic-vxlan:VXLAN_TUNNEL": {
"VXLAN_TUNNEL_LIST": [
{
"name": "vtep1",
"src_ip": "1.2.3.4"
}
]
}
},
"sonic-vnet:sonic-vnet": {
"sonic-vnet:VNET": {
"VNET_LIST": [
{
"name" : "abcd",
"vxlan_tunnel": "vtep1",
"scope": "default",
"vni": "20100",
"overlay_dmac": "22::"
}
]
}
}
},
"VNET_INVALID_VALUE_TEST4": {
"sonic-vxlan:sonic-vxlan": {
"sonic-vxlan:VXLAN_TUNNEL": {
"VXLAN_TUNNEL_LIST": [
{
"name": "vtep1",
"src_ip": "1.2.3.4"
}
]
}
},
"sonic-vnet:sonic-vnet": {
"sonic-vnet:VNET": {
"VNET_LIST": [
{
"name" : "abcdfd",
"scope": "default",
"overlay_dmac": "22::"
}

]
}
}
},
"VNET_INVALID_VXLAN_VTEP": {
"sonic-vxlan:sonic-vxlan": {
"sonic-vxlan:VXLAN_TUNNEL": {
"VXLAN_TUNNEL_LIST": [
{
"name": "vtep1",
"src_ip": "1.2.3.4"
}
]
}
},
"sonic-vnet:sonic-vnet": {
"sonic-vnet:VNET": {
"VNET_LIST": [
{
"name" : "abcd",
"vxlan_tunnel": "vtepxyz",
"scope": "default",
"vni": "10011",
"peer_list": "",
"advertise_prefix": "true",
"overlay_dmac": "22:33:44:55:66:77"
}
]
}
}
}
}
104 changes: 104 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-vnet.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
module sonic-vnet {
yang-version 1.1;
namespace "http://github.com/sonic-net/sonic-vnet";
prefix svnet;

import ietf-yang-types {
prefix yang;
}

import ietf-inet-types {
prefix inet;
}

import sonic-types {
prefix stypes;
}

import sonic-vxlan {
prefix svxlan;
}
organization
"SONiC";

contact
"SONiC";

description
"VNET YANG Module for SONiC OS";

revision 2023-04-25 {
description
"First revision.";
}

container sonic-vnet {

container VNET {

description "config db VNET table";

list VNET_LIST {

key "name";

leaf name {
description "An alphanumaric string to represent the name of the unique vnet";
type string;
}

leaf vxlan_tunnel {
mandatory true;
description "A valid and active vxlan tunnel to be used with this vnet for traffic encapsulation.";
type leafref {
path "/svxlan:sonic-vxlan/svxlan:VXLAN_TUNNEL/svxlan:VXLAN_TUNNEL_LIST/svxlan:name";
}
}

leaf vni {
mandatory true;
description "A valid and unique vni which will become part of the encapsulated traffic header.";
type stypes:vnid_type;
}

leaf peer_list {
description "Set of peers";
/* Values in leaf list are UNIQUE */
type string;
}

leaf guid {
description "An optional guid.";
type string {
length 1..255;
}
}

leaf scope {
description "can only be default.";
type string {
pattern "default" {
error-message "Invalid VRF name";
}
}
}

leaf advertise_prefix {
description "Flag to enable advertisement of route prefixes belonging to the Vnet.";
type boolean;
}

leaf overlay_dmac {
description "Overlay Dest MAC address to be used by Vnet ping.";
type yang:mac-address;
}

leaf src_mac {
description "source mac address for the Vnet";
type yang:mac-address;
}
}
}
}
}

0 comments on commit c900abb

Please sign in to comment.