@@ -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"
@@ -117,6 +118,10 @@ func (a *OptionalInstallConfig) validateSupportedPlatforms(installConfig *types.
117118 allErrs = append (allErrs , a .validateVSpherePlatform (installConfig )... )
118119 }
119120
121+ if installConfig .Platform .Name () == baremetal .Name {
122+ allErrs = append (allErrs , a .validateBMCConfig (installConfig )... )
123+ }
124+
120125 return allErrs
121126}
122127
@@ -256,6 +261,25 @@ func (a *OptionalInstallConfig) GetBaremetalHosts() []*baremetal.Host {
256261 return nil
257262}
258263
264+ func (a * OptionalInstallConfig ) validateBMCConfig (installConfig * types.InstallConfig ) field.ErrorList {
265+ var allErrs field.ErrorList
266+
267+ bmcConfigured := false
268+ for _ , host := range installConfig .Platform .BareMetal .Hosts {
269+ if host .BMC .Address == "" {
270+ continue
271+ }
272+ bmcConfigured = true
273+ }
274+
275+ if bmcConfigured {
276+ fieldPath := field .NewPath ("Platform" , "BareMetal" )
277+ allErrs = append (allErrs , baremetalvalidation .ValidateProvisioningNetworking (installConfig .Platform .BareMetal , installConfig .Networking , fieldPath )... )
278+ }
279+
280+ return allErrs
281+ }
282+
259283func warnUnusedConfig (installConfig * types.InstallConfig ) {
260284 // "Proxyonly" is the default set from generic install config code
261285 if installConfig .AdditionalTrustBundlePolicy != "Proxyonly" {
@@ -298,14 +322,6 @@ func warnUnusedConfig(installConfig *types.InstallConfig) {
298322 fieldPath := field .NewPath ("Platform" , "Baremetal" , "LibvirtURI" )
299323 logrus .Debugf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .LibvirtURI ))
300324 }
301- if baremetal .ClusterProvisioningIP != defaultBM .ClusterProvisioningIP {
302- fieldPath := field .NewPath ("Platform" , "Baremetal" , "ClusterProvisioningIP" )
303- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .ClusterProvisioningIP ))
304- }
305- if baremetal .DeprecatedProvisioningHostIP != defaultBM .DeprecatedProvisioningHostIP {
306- fieldPath := field .NewPath ("Platform" , "Baremetal" , "ProvisioningHostIP" )
307- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .DeprecatedProvisioningHostIP ))
308- }
309325 if baremetal .BootstrapProvisioningIP != defaultBM .BootstrapProvisioningIP {
310326 fieldPath := field .NewPath ("Platform" , "Baremetal" , "BootstrapProvisioningIP" )
311327 logrus .Debugf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .BootstrapProvisioningIP ))
@@ -314,48 +330,12 @@ func warnUnusedConfig(installConfig *types.InstallConfig) {
314330 fieldPath := field .NewPath ("Platform" , "Baremetal" , "ExternalBridge" )
315331 logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .ExternalBridge ))
316332 }
317- if baremetal .ProvisioningNetwork != defaultBM .ProvisioningNetwork {
318- fieldPath := field .NewPath ("Platform" , "Baremetal" , "ProvisioningNetwork" )
319- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .ProvisioningNetwork ))
320- }
321333 if baremetal .ProvisioningBridge != defaultBM .ProvisioningBridge {
322334 fieldPath := field .NewPath ("Platform" , "Baremetal" , "ProvisioningBridge" )
323335 logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .ProvisioningBridge ))
324336 }
325- if baremetal .ProvisioningNetworkInterface != defaultBM .ProvisioningNetworkInterface {
326- fieldPath := field .NewPath ("Platform" , "Baremetal" , "ProvisioningNetworkInterface" )
327- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .ProvisioningNetworkInterface ))
328- }
329- if baremetal .ProvisioningNetworkCIDR .String () != defaultBM .ProvisioningNetworkCIDR .String () {
330- fieldPath := field .NewPath ("Platform" , "Baremetal" , "ProvisioningNetworkCIDR" )
331- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .ProvisioningNetworkCIDR ))
332- }
333- if baremetal .DeprecatedProvisioningDHCPExternal != defaultBM .DeprecatedProvisioningDHCPExternal {
334- fieldPath := field .NewPath ("Platform" , "Baremetal" , "ProvisioningDHCPExternal" )
335- logrus .Warnf (fmt .Sprintf ("%s: true is ignored" , fieldPath ))
336- }
337- if baremetal .ProvisioningDHCPRange != defaultBM .ProvisioningDHCPRange {
338- fieldPath := field .NewPath ("Platform" , "Baremetal" , "ProvisioningDHCPRange" )
339- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , baremetal .ProvisioningDHCPRange ))
340- }
341337
342338 for i , host := range baremetal .Hosts {
343- if host .BMC .Username != "" {
344- fieldPath := field .NewPath ("Platform" , "Baremetal" , fmt .Sprintf ("Hosts[%d]" , i ), "BMC" , "Username" )
345- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , host .BMC .Username ))
346- }
347- if host .BMC .Password != "" {
348- fieldPath := field .NewPath ("Platform" , "Baremetal" , fmt .Sprintf ("Hosts[%d]" , i ), "BMC" , "Password" )
349- logrus .Warnf (fmt .Sprintf ("%s is ignored" , fieldPath ))
350- }
351- if host .BMC .Address != "" {
352- fieldPath := field .NewPath ("Platform" , "Baremetal" , fmt .Sprintf ("Hosts[%d]" , i ), "BMC" , "Address" )
353- logrus .Warnf (fmt .Sprintf ("%s: %s is ignored" , fieldPath , host .BMC .Address ))
354- }
355- if host .BMC .DisableCertificateVerification {
356- fieldPath := field .NewPath ("Platform" , "Baremetal" , fmt .Sprintf ("Hosts[%d]" , i ), "BMC" , "DisableCertificateVerification" )
357- logrus .Warnf (fmt .Sprintf ("%s: true is ignored" , fieldPath ))
358- }
359339 // The default is UEFI. +kubebuilder:validation:Enum="";UEFI;UEFISecureBoot;legacy. Set from generic install config code
360340 if host .BootMode != "UEFI" {
361341 fieldPath := field .NewPath ("Platform" , "Baremetal" , fmt .Sprintf ("Hosts[%d]" , i ), "BootMode" )
0 commit comments