github.com/openshift/installer@v1.4.17/pkg/asset/cluster/openstack/openstack.go (about) 1 // Package openstack extracts OpenStack metadata from install 2 // configurations. 3 package openstack 4 5 import ( 6 "context" 7 8 "github.com/openshift/installer/pkg/asset" 9 "github.com/openshift/installer/pkg/asset/installconfig" 10 "github.com/openshift/installer/pkg/asset/manifests/capiutils" 11 rhcos_asset "github.com/openshift/installer/pkg/asset/rhcos" 12 "github.com/openshift/installer/pkg/infrastructure/openstack/preprovision" 13 "github.com/openshift/installer/pkg/rhcos" 14 "github.com/openshift/installer/pkg/types" 15 "github.com/openshift/installer/pkg/types/openstack" 16 ) 17 18 // Metadata converts an install configuration to OpenStack metadata. 19 func Metadata(infraID string, config *types.InstallConfig) *openstack.Metadata { 20 return &openstack.Metadata{ 21 Cloud: config.Platform.OpenStack.Cloud, 22 Identifier: map[string]string{ 23 "openshiftClusterID": infraID, 24 }, 25 } 26 } 27 28 // PreTerraform performs any infrastructure initialization which must 29 // happen before Terraform creates the remaining infrastructure. 30 func PreTerraform(ctx context.Context, tfvarsFile *asset.File, installConfig *installconfig.InstallConfig, clusterID *installconfig.ClusterID, rhcosImage *rhcos_asset.Image) error { 31 if !capiutils.IsEnabled(installConfig) { 32 if err := preprovision.ReplaceBootstrapIgnitionInTFVars(ctx, tfvarsFile, installConfig, clusterID); err != nil { 33 return err 34 } 35 36 if err := preprovision.TagVIPPorts(ctx, installConfig, clusterID.InfraID); err != nil { 37 return err 38 } 39 40 // upload the corresponding image to Glance if rhcosImage contains a 41 // URL. If rhcosImage contains a name, then that points to an existing 42 // Glance image. 43 if imageName, isURL := rhcos.GenerateOpenStackImageName(rhcosImage.ControlPlane, clusterID.InfraID); isURL { 44 if err := preprovision.UploadBaseImage(ctx, installConfig.Config.Platform.OpenStack.Cloud, rhcosImage.ControlPlane, imageName, clusterID.InfraID, installConfig.Config.Platform.OpenStack.ClusterOSImageProperties); err != nil { 45 return err 46 } 47 } 48 } 49 50 return preprovision.SetTerraformEnvironment() 51 }