55 "net"
66 "strings"
77
8+ utilsnet "k8s.io/utils/net"
9+
810 "github.com/openshift/installer/pkg/types"
911 "github.com/openshift/installer/pkg/types/baremetal"
1012)
@@ -51,7 +53,7 @@ type TemplateData struct {
5153 ClusterOSImage string
5254
5355 // API VIP for use by ironic during bootstrap.
54- APIVIP string
56+ APIVIPs [] string
5557
5658 // Hosts is the information needed to create the objects in Ironic.
5759 Hosts []* baremetal.Host
@@ -71,6 +73,25 @@ type TemplateData struct {
7173 ExternalSubnetCIDR int
7274
7375 ExternalMACAddress string
76+
77+ // ExternalURLv6 is a callback URL for the node if the node and the BMC use different network families
78+ ExternalURLv6 string
79+ }
80+
81+ func externalURLs (apiVIPs []string ) (externalURLv4 string , externalURLv6 string ) {
82+ if len (apiVIPs ) > 1 {
83+ // IPv6 BMCs may not be able to reach IPv4 servers, use the right callback URL for them.
84+ // Warning: when backporting to 4.12 or earlier, change the port to 80!
85+ externalURL := fmt .Sprintf ("http://%s/" , net .JoinHostPort (apiVIPs [1 ], "6180" ))
86+ if utilsnet .IsIPv6String (apiVIPs [1 ]) {
87+ externalURLv6 = externalURL
88+ }
89+ if utilsnet .IsIPv4String (apiVIPs [1 ]) {
90+ externalURLv4 = externalURL
91+ }
92+ }
93+
94+ return
7495}
7596
7697// GetTemplateData returns platform-specific data for bootstrap templates.
@@ -86,8 +107,12 @@ func GetTemplateData(config *baremetal.Platform, networks []types.MachineNetwork
86107 templateData .ExternalStaticDNS = config .BootstrapExternalStaticDNS
87108 templateData .ExternalMACAddress = config .ExternalMACAddress
88109
110+ _ , externalURLv6 := externalURLs (config .APIVIPs )
111+
112+ templateData .ExternalURLv6 = externalURLv6
113+
89114 if len (config .APIVIPs ) > 0 {
90- templateData .APIVIP = config .APIVIPs [ 0 ]
115+ templateData .APIVIPs = config .APIVIPs
91116 templateData .BaremetalEndpointOverride = fmt .Sprintf ("http://%s/v1" , net .JoinHostPort (config .APIVIPs [0 ], "6385" ))
92117 templateData .BaremetalIntrospectionEndpointOverride = fmt .Sprintf ("http://%s/v1" , net .JoinHostPort (config .APIVIPs [0 ], "5050" ))
93118 }
0 commit comments