@@ -71,6 +71,11 @@ func GenerateConfigDB(input *values.Values, platform *p.Platform, environment *p
7171 return nil , err
7272 }
7373
74+ vlanInterfaces , err := getVLANInterfaces (input .VLANs , version )
75+ if err != nil {
76+ return nil , err
77+ }
78+
7479 configdb := ConfigDB {
7580 ACLRules : rules ,
7681 ACLTables : tables ,
@@ -105,7 +110,7 @@ func GenerateConfigDB(input *values.Values, platform *p.Platform, environment *p
105110 PortChannelMembers : getPortChannelMembers (input .PortChannels .List ),
106111 SAG : sag ,
107112 VLANs : getVLANs (input .VLANs ),
108- VLANInterfaces : getVLANInterfaces ( input . VLANs ) ,
113+ VLANInterfaces : vlanInterfaces ,
109114 VLANMembers : getVLANMembers (input .VLANs ),
110115 VLANSubinterfaces : getVLANSubinterfaces (input .VLANSubinterfaces ),
111116 VRFs : getVRFs (input .Interconnects , input .Ports , input .VLANs ),
@@ -493,7 +498,7 @@ func getPortsAndBreakouts(ports values.Ports, breakouts map[string]string, platf
493498}
494499
495500func getSAG (sag values.SAG , version * v.Version ) (* SAG , error ) {
496- if version .Branch != string (v .Branch202211 ) {
501+ if version .Branch != string (v .Branch202211 ) && sag . MAC != "" {
497502 return nil , fmt .Errorf ("sag configuration only works with sonic versions from the ec202211 branch" )
498503 }
499504
@@ -521,15 +526,23 @@ func getVLANs(vlans []values.VLAN) map[string]VLAN {
521526 return configVLANs
522527}
523528
524- func getVLANInterfaces (vlans []values.VLAN ) map [string ]VLANInterface {
529+ func getVLANInterfaces (vlans []values.VLAN , version * v. Version ) ( map [string ]VLANInterface , error ) {
525530 vlanInterfaces := make (map [string ]VLANInterface )
526531
527532 for _ , vlan := range vlans {
528533 var vlanInterface VLANInterface
529534
535+ if version .Branch != string (v .Branch202211 ) && vlan .SAG != nil {
536+ return nil , fmt .Errorf ("sag only works for sonic builds from branch 202211" )
537+ }
538+ var sag string
539+ if vlan .SAG != nil {
540+ sag = strconv .FormatBool (* vlan .SAG )
541+ }
542+
530543 if vlan .VRF != "" {
531544 vlanInterface = VLANInterface {
532- StaticAnycastGateway : strconv . FormatBool ( vlan . SAG ) ,
545+ StaticAnycastGateway : sag ,
533546 VRFName : vlan .VRF ,
534547 }
535548 }
@@ -541,7 +554,7 @@ func getVLANInterfaces(vlans []values.VLAN) map[string]VLANInterface {
541554 vlanInterfaces ["Vlan" + vlan .ID + "|" + vlan .IP ] = VLANInterface {}
542555 }
543556
544- return vlanInterfaces
557+ return vlanInterfaces , nil
545558}
546559
547560func getVLANMembers (vlans []values.VLAN ) map [string ]VLANMember {
0 commit comments