github.com/openshift/installer@v1.4.17/pkg/asset/manifests/vsphere/infrastructure.go (about)

     1  package vsphere
     2  
     3  import (
     4  	"fmt"
     5  
     6  	configv1 "github.com/openshift/api/config/v1"
     7  	"github.com/openshift/installer/pkg/asset/installconfig"
     8  	"github.com/openshift/installer/pkg/types"
     9  )
    10  
    11  // GetInfraPlatformSpec constructs VSpherePlatformSpec for the infrastructure spec
    12  func GetInfraPlatformSpec(ic *installconfig.InstallConfig, clusterID string) *configv1.VSpherePlatformSpec {
    13  	var platformSpec configv1.VSpherePlatformSpec
    14  	icPlatformSpec := ic.Config.VSphere
    15  
    16  	for _, vcenter := range icPlatformSpec.VCenters {
    17  		platformSpec.VCenters = append(platformSpec.VCenters, configv1.VSpherePlatformVCenterSpec{
    18  			Server:      vcenter.Server,
    19  			Port:        vcenter.Port,
    20  			Datacenters: vcenter.Datacenters,
    21  		})
    22  	}
    23  
    24  	for _, failureDomain := range icPlatformSpec.FailureDomains {
    25  		topology := failureDomain.Topology
    26  		if topology.ComputeCluster != "" && topology.Networks[0] != "" {
    27  			template := topology.Template
    28  			if len(template) == 0 {
    29  				template = fmt.Sprintf("/%s/vm/%s-rhcos-%s-%s", topology.Datacenter, clusterID, failureDomain.Region, failureDomain.Zone)
    30  			}
    31  
    32  			platformSpec.FailureDomains = append(platformSpec.FailureDomains, configv1.VSpherePlatformFailureDomainSpec{
    33  				Name:   failureDomain.Name,
    34  				Region: failureDomain.Region,
    35  				Zone:   failureDomain.Zone,
    36  				Server: failureDomain.Server,
    37  				Topology: configv1.VSpherePlatformTopology{
    38  					Datacenter:     topology.Datacenter,
    39  					ComputeCluster: topology.ComputeCluster,
    40  					Networks:       topology.Networks,
    41  					Datastore:      topology.Datastore,
    42  					ResourcePool:   topology.ResourcePool,
    43  					Folder:         topology.Folder,
    44  					Template:       template,
    45  				},
    46  			})
    47  		}
    48  	}
    49  
    50  	platformSpec.APIServerInternalIPs = types.StringsToIPs(icPlatformSpec.APIVIPs)
    51  	platformSpec.IngressIPs = types.StringsToIPs(icPlatformSpec.IngressVIPs)
    52  	platformSpec.MachineNetworks = types.MachineNetworksToCIDRs(ic.Config.MachineNetwork)
    53  
    54  	return &platformSpec
    55  }