@@ -433,24 +433,19 @@ func ValidatePlatform(p *baremetal.Platform, agentBasedInstallation bool, n *typ
433433 }
434434 }
435435
436- if ! agentBasedInstallation && p .Hosts == nil {
436+ enabledCaps := c .GetEnabledCapabilities ()
437+ if ! agentBasedInstallation && enabledCaps .Has (configv1 .ClusterVersionCapabilityMachineAPI ) && p .Hosts == nil {
437438 allErrs = append (allErrs , field .Invalid (fldPath .Child ("hosts" ), p .Hosts , "bare metal hosts are missing" ))
438439 }
439440
440441 if p .DefaultMachinePlatform != nil {
441442 allErrs = append (allErrs , ValidateMachinePool (p .DefaultMachinePlatform , fldPath .Child ("defaultMachinePlatform" ))... )
442443 }
443444
444- if ! agentBasedInstallation {
445- if err := validateHostsCount ( p . Hosts , c ); err != nil {
446- allErrs = append (allErrs , field . Required ( fldPath . Child ( "Hosts" ), err . Error ()) )
445+ if ! agentBasedInstallation && enabledCaps . Has ( configv1 . ClusterVersionCapabilityMachineAPI ) {
446+ if err := ValidateHosts ( p , fldPath , c ); err != nil {
447+ allErrs = append (allErrs , err ... )
447448 }
448- allErrs = append (allErrs , validateHostsWithoutBMC (p .Hosts , fldPath )... )
449- allErrs = append (allErrs , validateBootMode (p .Hosts , fldPath .Child ("Hosts" ))... )
450- allErrs = append (allErrs , validateRootDeviceHints (p .Hosts , fldPath .Child ("Hosts" ))... )
451- allErrs = append (allErrs , validateNetworkConfig (p .Hosts , fldPath .Child ("Hosts" ))... )
452-
453- allErrs = append (allErrs , validateHostsName (p .Hosts , fldPath .Child ("Hosts" ))... )
454449 }
455450
456451 if c .BareMetal .LoadBalancer != nil {
@@ -462,6 +457,22 @@ func ValidatePlatform(p *baremetal.Platform, agentBasedInstallation bool, n *typ
462457 return allErrs
463458}
464459
460+ // ValidateHosts returns an error if the Hosts are not valid.
461+ func ValidateHosts (p * baremetal.Platform , fldPath * field.Path , c * types.InstallConfig ) field.ErrorList {
462+ allErrs := field.ErrorList {}
463+
464+ if err := validateHostsCount (p .Hosts , c ); err != nil {
465+ allErrs = append (allErrs , field .Required (fldPath .Child ("Hosts" ), err .Error ()))
466+ }
467+ allErrs = append (allErrs , validateHostsWithoutBMC (p .Hosts , fldPath )... )
468+ allErrs = append (allErrs , validateBootMode (p .Hosts , fldPath .Child ("Hosts" ))... )
469+ allErrs = append (allErrs , validateRootDeviceHints (p .Hosts , fldPath .Child ("Hosts" ))... )
470+ allErrs = append (allErrs , validateNetworkConfig (p .Hosts , fldPath .Child ("Hosts" ))... )
471+
472+ allErrs = append (allErrs , validateHostsName (p .Hosts , fldPath .Child ("Hosts" ))... )
473+ return allErrs
474+ }
475+
465476// validateLoadBalancer returns an error if the load balancer is not valid.
466477func validateLoadBalancer (lbType configv1.PlatformLoadBalancerType ) bool {
467478 switch lbType {
0 commit comments