@@ -43,6 +43,13 @@ type ConfigDB struct {
4343}
4444
4545func GenerateConfigDB (input * values.Values , platform * p.Platform , currentDeviceMetadata DeviceMetadata ) (* ConfigDB , error ) {
46+ if input == nil {
47+ return nil , fmt .Errorf ("no input values provided" )
48+ }
49+ if platform == nil {
50+ return nil , fmt .Errorf ("no platform information provided" )
51+ }
52+
4653 ports , breakouts , err := getPortsAndBreakouts (input .Ports , input .Breakouts , platform )
4754 if err != nil {
4855 return nil , err
@@ -55,25 +62,22 @@ func GenerateConfigDB(input *values.Values, platform *p.Platform, currentDeviceM
5562
5663 features := getFeatures (input .Features )
5764 rules , tables := getACLRulesAndTables (input .SSHSourceranges )
58- vxlanevpn , vxlanTunnel , vxlanTunnelMap := getVXLAN (input .VTEPs , input .LoopbackAddress )
65+ vxlanevpn , vxlanTunnel , vxlanTunnelMap := getVXLAN (input .VTEP , input .LoopbackAddress )
5966
6067 configdb := ConfigDB {
61- ACLRules : rules ,
62- ACLTables : tables ,
63- Breakouts : breakouts ,
64- DeviceMetadata : * deviceMetadata ,
65- DNSNameservers : getDNSNameservers (input .Nameservers ),
66- Features : features ,
67- Interfaces : getInterfaces (input .Ports , input .BGPPorts , input .Interconnects ),
68- LLDP : getLLDP (input .LLDPHelloTime ),
69- LoopbackInterface : map [string ]struct {}{
70- "Loopback0" : {},
71- "Loopback0|" + input .LoopbackAddress + "/32" : {},
72- },
73- MCLAGDomains : getMCLAGDomains (input .MCLAG ),
74- MCLAGInterfaces : getMCLAGInterfaces (input .MCLAG ),
75- MCLAGUniqueIPs : getMCLAGUniqueIPs (input .MCLAG ),
76- MgmtInterfaces : getMgmtInterfaces (input .MgmtInterface ),
68+ ACLRules : rules ,
69+ ACLTables : tables ,
70+ Breakouts : breakouts ,
71+ DeviceMetadata : * deviceMetadata ,
72+ DNSNameservers : getDNSNameservers (input .Nameservers ),
73+ Features : features ,
74+ Interfaces : getInterfaces (input .Ports , input .BGPPorts , input .Interconnects ),
75+ LLDP : getLLDP (input .LLDPHelloTime ),
76+ LoopbackInterface : getLoopbackInterface (input .LoopbackAddress ),
77+ MCLAGDomains : getMCLAGDomains (input .MCLAG ),
78+ MCLAGInterfaces : getMCLAGInterfaces (input .MCLAG ),
79+ MCLAGUniqueIPs : getMCLAGUniqueIPs (input .MCLAG ),
80+ MgmtInterfaces : getMgmtInterfaces (input .MgmtInterface ),
7781 MgmtPorts : map [string ]MgmtPort {
7882 "eth0" : {
7983 AdminStatus : AdminStatusUp ,
@@ -163,18 +167,16 @@ func getACLRulesAndTables(sourceRanges []string) (map[string]ACLRule, map[string
163167}
164168
165169func getDeviceMetadata (input * values.Values , currentMetadata DeviceMetadata ) (* DeviceMetadata , error ) {
166- hint := "remove current config_db.json and run `config-setup factory` to generate an initial config_db.json with all the necessary information"
167-
168170 if currentMetadata .Localhost .Platform == "" {
169- return nil , fmt .Errorf ("missing platform from current device metadata\n hint: %s" , hint )
171+ return nil , fmt .Errorf ("missing platform from current device metadata" )
170172 }
171173
172174 if currentMetadata .Localhost .HWSKU == "" {
173- return nil , fmt .Errorf ("missing hwsku from current device metadata\n hint: %s" , hint )
175+ return nil , fmt .Errorf ("missing hwsku from current device metadata" )
174176 }
175177
176178 if currentMetadata .Localhost .MAC == "" {
177- return nil , fmt .Errorf ("missing mac from current device metadata\n hint: %s" , hint )
179+ return nil , fmt .Errorf ("missing mac from current device metadata" )
178180 }
179181
180182 return & DeviceMetadata {
@@ -265,6 +267,17 @@ func getLLDP(interval int) *LLDP {
265267 }
266268}
267269
270+ func getLoopbackInterface (loopback string ) map [string ]struct {} {
271+ if loopback == "" {
272+ return nil
273+ }
274+
275+ return map [string ]struct {}{
276+ "Loopback0" : {},
277+ fmt .Sprintf ("Loopback0|%s/32" , loopback ): {},
278+ }
279+ }
280+
268281func getMCLAGDomains (mclag values.MCLAG ) map [string ]MCLAGDomain {
269282 if mclag .KeepaliveVLAN == "" {
270283 return nil
@@ -549,8 +562,12 @@ func getVRFs(interconnects map[string]values.Interconnect, ports values.Ports, v
549562 return vrfs
550563}
551564
552- func getVXLAN (vteps []values.VTEP , loopback string ) (* VXLANEVPN , map [string ]VXLANTunnel , VXLANTunnelMap ) {
553- if len (vteps ) == 0 {
565+ func getVXLAN (vtep values.VTEP , loopback string ) (* VXLANEVPN , map [string ]VXLANTunnel , VXLANTunnelMap ) {
566+ if ! vtep .Enabled && len (vtep .VXLANTunnelMaps ) == 0 {
567+ return nil , nil , nil
568+ }
569+
570+ if loopback == "" {
554571 return nil , nil , nil
555572 }
556573
@@ -568,7 +585,7 @@ func getVXLAN(vteps []values.VTEP, loopback string) (*VXLANEVPN, map[string]VXLA
568585
569586 vxlanTunnelMap := make (VXLANTunnelMap )
570587
571- for _ , vtep := range vteps {
588+ for _ , vtep := range vtep . VXLANTunnelMaps {
572589 vxlanTunnelMap ["vtep|map_" + vtep .VNI + "_" + vtep .VLAN ] = VXLANTunnelMapEntry {
573590 VLAN : vtep .VLAN ,
574591 VNI : vtep .VNI ,
0 commit comments