@@ -37,6 +37,7 @@ type ConfigDB struct {
3737 VLANs map [string ]VLAN `json:"VLAN,omitempty"`
3838 VLANInterfaces map [string ]VLANInterface `json:"VLAN_INTERFACE,omitempty"`
3939 VLANMembers map [string ]VLANMember `json:"VLAN_MEMBER,omitempty"`
40+ VRRPInterfaces map [string ]VRRPInterface `json:"VRRP_INTERFACE,omitempty"`
4041 VLANSubinterfaces map [string ]VLANSubinterface `json:"VLAN_SUB_INTERFACE,omitempty"`
4142 VRFs map [string ]VRF `json:"VRF,omitempty"`
4243 VXLANEVPN * VXLANEVPN `json:"VXLAN_EVPN_NVO,omitempty"`
@@ -76,6 +77,11 @@ func GenerateConfigDB(input *values.Values, platform *p.Platform, environment *p
7677 return nil , err
7778 }
7879
80+ vrrpInterfaces , err := getVRRPInterfaces (input .VLANs , version )
81+ if err != nil {
82+ return nil , err
83+ }
84+
7985 configdb := ConfigDB {
8086 ACLRules : rules ,
8187 ACLTables : tables ,
@@ -112,6 +118,7 @@ func GenerateConfigDB(input *values.Values, platform *p.Platform, environment *p
112118 VLANs : getVLANs (input .VLANs ),
113119 VLANInterfaces : vlanInterfaces ,
114120 VLANMembers : getVLANMembers (input .VLANs ),
121+ VRRPInterfaces : vrrpInterfaces ,
115122 VLANSubinterfaces : getVLANSubinterfaces (input .VLANSubinterfaces ),
116123 VRFs : getVRFs (input .Interconnects , input .Ports , input .VLANs ),
117124 VXLANEVPN : vxlanevpn ,
@@ -576,6 +583,31 @@ func getVLANMembers(vlans []values.VLAN) map[string]VLANMember {
576583 return vlanMembers
577584}
578585
586+ func getVRRPInterfaces (vlans []values.VLAN , version * v.Version ) (map [string ]VRRPInterface , error ) {
587+ vrrpInterfaces := make (map [string ]VRRPInterface )
588+ for _ , vlan := range vlans {
589+ if vlan .VRRP .Group == "" {
590+ continue
591+ }
592+
593+ if version .Branch != string (v .Branch202111 ) {
594+ return nil , fmt .Errorf ("vrrp configuration only works with sonic versions from the ec202111 branch" )
595+ }
596+
597+ vrrpInterfaces ["Vrrp" + vlan .VRRP .Group + "-v4" ] = VRRPInterface {
598+ ParentInterface : "Vlan" + vlan .ID ,
599+ }
600+
601+ if vlan .VRRP .IP == "" {
602+ continue
603+ }
604+
605+ vrrpInterfaces ["Vrrp" + vlan .VRRP .Group + "-v4|" + vlan .VRRP .IP ] = VRRPInterface {}
606+ }
607+
608+ return vrrpInterfaces , nil
609+ }
610+
579611func getVLANSubinterfaces (subinterfaces []values.VLANSubinterface ) map [string ]VLANSubinterface {
580612 vlanSubinterfaces := make (map [string ]VLANSubinterface )
581613
0 commit comments