@@ -15,6 +15,7 @@ import (
1515 "github.com/openshift/installer/pkg/types"
1616 "github.com/openshift/installer/pkg/types/baremetal"
1717 baremetaldefaults "github.com/openshift/installer/pkg/types/baremetal/defaults"
18+ baremetalvalidation "github.com/openshift/installer/pkg/types/baremetal/validation"
1819 "github.com/openshift/installer/pkg/types/external"
1920 "github.com/openshift/installer/pkg/types/none"
2021 "github.com/openshift/installer/pkg/types/validation"
@@ -121,6 +122,10 @@ func (a *OptionalInstallConfig) validateSupportedPlatforms(installConfig *types.
121122 allErrs = append (allErrs , a .validateVSpherePlatform (installConfig )... )
122123 }
123124
125+ if installConfig .Platform .Name () == baremetal .Name {
126+ allErrs = append (allErrs , a .validateBMCConfig (installConfig )... )
127+ }
128+
124129 return allErrs
125130}
126131
@@ -260,6 +265,25 @@ func (a *OptionalInstallConfig) GetBaremetalHosts() []*baremetal.Host {
260265 return nil
261266}
262267
268+ func (a * OptionalInstallConfig ) validateBMCConfig (installConfig * types.InstallConfig ) field.ErrorList {
269+ var allErrs field.ErrorList
270+
271+ bmcConfigured := false
272+ for _ , host := range installConfig .Platform .BareMetal .Hosts {
273+ if host .BMC .Address == "" {
274+ continue
275+ }
276+ bmcConfigured = true
277+ }
278+
279+ if bmcConfigured {
280+ fieldPath := field .NewPath ("Platform" , "BareMetal" )
281+ allErrs = append (allErrs , baremetalvalidation .ValidateProvisioningNetworking (installConfig .Platform .BareMetal , installConfig .Networking , fieldPath )... )
282+ }
283+
284+ return allErrs
285+ }
286+
263287func warnUnusedConfig (installConfig * types.InstallConfig ) {
264288 // "Proxyonly" is the default set from generic install config code
265289 if installConfig .AdditionalTrustBundlePolicy != "Proxyonly" {
@@ -302,14 +326,6 @@ func warnUnusedConfig(installConfig *types.InstallConfig) {
302326 fieldPath := field .NewPath ("Platform" , "Baremetal" , "LibvirtURI" )
303327 logrus .Debugf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .LibvirtURI ))
304328 }
305- if baremetal .ClusterProvisioningIP != defaultBM .ClusterProvisioningIP {
306- fieldPath := field .NewPath ("Platform" , "Baremetal" , "ClusterProvisioningIP" )
307- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .ClusterProvisioningIP ))
308- }
309- if baremetal .DeprecatedProvisioningHostIP != defaultBM .DeprecatedProvisioningHostIP {
310- fieldPath := field .NewPath ("Platform" , "Baremetal" , "ProvisioningHostIP" )
311- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .DeprecatedProvisioningHostIP ))
312- }
313329 if baremetal .BootstrapProvisioningIP != defaultBM .BootstrapProvisioningIP {
314330 fieldPath := field .NewPath ("Platform" , "Baremetal" , "BootstrapProvisioningIP" )
315331 logrus .Debugf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .BootstrapProvisioningIP ))
@@ -318,48 +334,12 @@ func warnUnusedConfig(installConfig *types.InstallConfig) {
318334 fieldPath := field .NewPath ("Platform" , "Baremetal" , "ExternalBridge" )
319335 logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .ExternalBridge ))
320336 }
321- if baremetal .ProvisioningNetwork != defaultBM .ProvisioningNetwork {
322- fieldPath := field .NewPath ("Platform" , "Baremetal" , "ProvisioningNetwork" )
323- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .ProvisioningNetwork ))
324- }
325337 if baremetal .ProvisioningBridge != defaultBM .ProvisioningBridge {
326338 fieldPath := field .NewPath ("Platform" , "Baremetal" , "ProvisioningBridge" )
327339 logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .ProvisioningBridge ))
328340 }
329- if baremetal .ProvisioningNetworkInterface != defaultBM .ProvisioningNetworkInterface {
330- fieldPath := field .NewPath ("Platform" , "Baremetal" , "ProvisioningNetworkInterface" )
331- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .ProvisioningNetworkInterface ))
332- }
333- if baremetal .ProvisioningNetworkCIDR .String () != defaultBM .ProvisioningNetworkCIDR .String () {
334- fieldPath := field .NewPath ("Platform" , "Baremetal" , "ProvisioningNetworkCIDR" )
335- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .ProvisioningNetworkCIDR ))
336- }
337- if baremetal .DeprecatedProvisioningDHCPExternal != defaultBM .DeprecatedProvisioningDHCPExternal {
338- fieldPath := field .NewPath ("Platform" , "Baremetal" , "ProvisioningDHCPExternal" )
339- logrus .Warnf (fmt .Sprintf ("%s: true is ignored" , fieldPath ))
340- }
341- if baremetal .ProvisioningDHCPRange != defaultBM .ProvisioningDHCPRange {
342- fieldPath := field .NewPath ("Platform" , "Baremetal" , "ProvisioningDHCPRange" )
343- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .ProvisioningDHCPRange ))
344- }
345341
346342 for i , host := range baremetal .Hosts {
347- if host .BMC .Username != "" {
348- fieldPath := field .NewPath ("Platform" , "Baremetal" , fmt .Sprintf ("Hosts[%d]" , i ), "BMC" , "Username" )
349- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , host .BMC .Username ))
350- }
351- if host .BMC .Password != "" {
352- fieldPath := field .NewPath ("Platform" , "Baremetal" , fmt .Sprintf ("Hosts[%d]" , i ), "BMC" , "Password" )
353- logrus .Warnf (fmt .Sprintf ("%s is ignored" , fieldPath ))
354- }
355- if host .BMC .Address != "" {
356- fieldPath := field .NewPath ("Platform" , "Baremetal" , fmt .Sprintf ("Hosts[%d]" , i ), "BMC" , "Address" )
357- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , host .BMC .Address ))
358- }
359- if host .BMC .DisableCertificateVerification {
360- fieldPath := field .NewPath ("Platform" , "Baremetal" , fmt .Sprintf ("Hosts[%d]" , i ), "BMC" , "DisableCertificateVerification" )
361- logrus .Warnf (fmt .Sprintf ("%s: true is ignored" , fieldPath ))
362- }
363343 // The default is UEFI. +kubebuilder:validation:Enum="";UEFI;UEFISecureBoot;legacy. Set from generic install config code
364344 if host .BootMode != "UEFI" {
365345 fieldPath := field .NewPath ("Platform" , "Baremetal" , fmt .Sprintf ("Hosts[%d]" , i ), "BootMode" )
0 commit comments