diff --git a/data/data/install.openshift.io_installconfigs.yaml b/data/data/install.openshift.io_installconfigs.yaml index 6d58be6dba1..a5120a651de 100644 --- a/data/data/install.openshift.io_installconfigs.yaml +++ b/data/data/install.openshift.io_installconfigs.yaml @@ -2110,6 +2110,10 @@ spec: type: integer type: object type: object + diskType: + description: Disk Type Thin specifies if thin disks should be + use instead of thick + type: string folder: description: Folder is the absolute path of the folder that will be used and/or created for virtual machines. The absolute path diff --git a/data/data/vsphere/pre-bootstrap/main.tf b/data/data/vsphere/pre-bootstrap/main.tf index 253083ff35f..984c15d3a36 100644 --- a/data/data/vsphere/pre-bootstrap/main.tf +++ b/data/data/vsphere/pre-bootstrap/main.tf @@ -50,6 +50,7 @@ resource "vsphereprivate_import_ova" "import" { network = var.vsphere_network folder = local.folder tag = vsphere_tag.tag.id + disk_type = var.vsphere_disk_type } resource "vsphere_tag_category" "category" { diff --git a/data/data/vsphere/variables-vsphere.tf b/data/data/vsphere/variables-vsphere.tf index 3870e5ddef6..09bef4a846d 100644 --- a/data/data/vsphere/variables-vsphere.tf +++ b/data/data/vsphere/variables-vsphere.tf @@ -76,4 +76,7 @@ variable "vsphere_control_plane_num_cpus" { variable "vsphere_control_plane_cores_per_socket" { type = number } - +variable "vsphere_disk_type" { + type = string + default = "eagerZeroedThick" +} diff --git a/docs/user/vsphere/customization.md b/docs/user/vsphere/customization.md index e2b67e4aecd..18cc1e332a7 100644 --- a/docs/user/vsphere/customization.md +++ b/docs/user/vsphere/customization.md @@ -18,6 +18,7 @@ Beyond the [platform-agnostic `install-config.yaml` properties](../customization * `cpus` (optional integer): The total number of virtual processor cores to assign a vm. * `coresPerSocket` (optional integer): The number of cores per socket in a vm. The number of vCPUs on the vm will be cpus/coresPerSocket (default is 1). * `memoryMB` (optional integer): The size of a VM's memory in megabytes. +* `disk_type` (optional string): DiskType is the name of the disk provisioning type for vsphere, for e.g thick or thin, by default it will be eagerZeroedThick. ## Examples diff --git a/pkg/asset/cluster/tfvars.go b/pkg/asset/cluster/tfvars.go index ad9835d8473..4986ffec61b 100644 --- a/pkg/asset/cluster/tfvars.go +++ b/pkg/asset/cluster/tfvars.go @@ -628,6 +628,7 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error { Cluster: installConfig.Config.VSphere.Cluster, ImageURL: string(*rhcosImage), PreexistingFolder: preexistingFolder, + DiskType: installConfig.Config.Platform.VSphere.DiskType, }, ) if err != nil { diff --git a/pkg/terraform/exec/plugins/vsphereprivate/resource_vsphereprivate_import_ova.go b/pkg/terraform/exec/plugins/vsphereprivate/resource_vsphereprivate_import_ova.go index 1c95add97c6..f98ac3fe401 100644 --- a/pkg/terraform/exec/plugins/vsphereprivate/resource_vsphereprivate_import_ova.go +++ b/pkg/terraform/exec/plugins/vsphereprivate/resource_vsphereprivate_import_ova.go @@ -93,6 +93,12 @@ func resourceVSpherePrivateImportOva() *schema.Resource { ForceNew: true, ValidateFunc: validation.NoZeroValues, }, + "disk_type": { + Type: schema.TypeString, + Description: "The name of the disk provisioning, for e.g eagerZeroedThick or thin, by default it will be thick.", + Required: true, + ForceNew: true, + }, }, } } @@ -347,11 +353,22 @@ func resourceVSpherePrivateImportOvaCreate(d *schema.ResourceData, meta interfac Name: ovfEnvelope.Network.Networks[0].Name, Network: importOvaParams.Network.Reference(), }} + + var diskType types.OvfCreateImportSpecParamsDiskProvisioningType + + if d.Get("disk_type") == "thin" { + diskType = types.OvfCreateImportSpecParamsDiskProvisioningTypeThin + } else if d.Get("disk_type") == "thick" { + diskType = types.OvfCreateImportSpecParamsDiskProvisioningTypeThick + } else { + diskType = types.OvfCreateImportSpecParamsDiskProvisioningTypeEagerZeroedThick + } // This is a very minimal spec for importing // an OVF. cisp := types.OvfCreateImportSpecParams{ - EntityName: d.Get("name").(string), - NetworkMapping: networkMappings, + DiskProvisioning: string(diskType), + EntityName: d.Get("name").(string), + NetworkMapping: networkMappings, } m := ovf.NewManager(client) diff --git a/pkg/tfvars/vsphere/vsphere.go b/pkg/tfvars/vsphere/vsphere.go index 17d46de117f..a48f5fbaa38 100644 --- a/pkg/tfvars/vsphere/vsphere.go +++ b/pkg/tfvars/vsphere/vsphere.go @@ -8,24 +8,26 @@ import ( "github.com/pkg/errors" "github.com/openshift/installer/pkg/tfvars/internal/cache" + "github.com/openshift/installer/pkg/types/vsphere" ) type config struct { - VSphereURL string `json:"vsphere_url"` - VSphereUsername string `json:"vsphere_username"` - VSpherePassword string `json:"vsphere_password"` - MemoryMiB int64 `json:"vsphere_control_plane_memory_mib"` - DiskGiB int32 `json:"vsphere_control_plane_disk_gib"` - NumCPUs int32 `json:"vsphere_control_plane_num_cpus"` - NumCoresPerSocket int32 `json:"vsphere_control_plane_cores_per_socket"` - Cluster string `json:"vsphere_cluster"` - Datacenter string `json:"vsphere_datacenter"` - Datastore string `json:"vsphere_datastore"` - Folder string `json:"vsphere_folder"` - Network string `json:"vsphere_network"` - Template string `json:"vsphere_template"` - OvaFilePath string `json:"vsphere_ova_filepath"` - PreexistingFolder bool `json:"vsphere_preexisting_folder"` + VSphereURL string `json:"vsphere_url"` + VSphereUsername string `json:"vsphere_username"` + VSpherePassword string `json:"vsphere_password"` + MemoryMiB int64 `json:"vsphere_control_plane_memory_mib"` + DiskGiB int32 `json:"vsphere_control_plane_disk_gib"` + NumCPUs int32 `json:"vsphere_control_plane_num_cpus"` + NumCoresPerSocket int32 `json:"vsphere_control_plane_cores_per_socket"` + Cluster string `json:"vsphere_cluster"` + Datacenter string `json:"vsphere_datacenter"` + Datastore string `json:"vsphere_datastore"` + Folder string `json:"vsphere_folder"` + Network string `json:"vsphere_network"` + Template string `json:"vsphere_template"` + OvaFilePath string `json:"vsphere_ova_filepath"` + PreexistingFolder bool `json:"vsphere_preexisting_folder"` + DiskType vsphere.DiskType `json:"vsphere_disk_type"` } // TFVarsSources contains the parameters to be converted into Terraform variables @@ -36,6 +38,7 @@ type TFVarsSources struct { Cluster string ImageURL string PreexistingFolder bool + DiskType vsphere.DiskType } //TFVars generate vSphere-specific Terraform variables @@ -68,6 +71,7 @@ func TFVars(sources TFVarsSources) ([]byte, error) { Template: controlPlaneConfig.Template, OvaFilePath: cachedImage, PreexistingFolder: sources.PreexistingFolder, + DiskType: sources.DiskType, } return json.MarshalIndent(cfg, "", " ") diff --git a/pkg/types/vsphere/platform.go b/pkg/types/vsphere/platform.go index 6b5034e1797..4565a4b947d 100644 --- a/pkg/types/vsphere/platform.go +++ b/pkg/types/vsphere/platform.go @@ -1,6 +1,20 @@ package vsphere -// Platform stores any global configuration used for vsphere platforms. +// DiskType is a disk provisioning type for vsphere. +type DiskType string + +const ( + // DiskTypeThin uses Thin disk type for vsphere in the cluster. + DiskTypeThin DiskType = "thin" + + // DiskTypeThick uses Thick disk type for vsphere in the cluster. + DiskTypeThick DiskType = "thick" + + // DiskTypeEagerZeroedThick uses EagerZeroedThick disk type for vsphere in the cluster. + DiskTypeEagerZeroedThick DiskType = "eagerZeroedThick" +) + +// Platform stores any global configuration used for vsphere platforms type Platform struct { // VCenter is the domain name or IP address of the vCenter. VCenter string `json:"vCenter"` @@ -47,4 +61,7 @@ type Platform struct { // Network specifies the name of the network to be used by the cluster. Network string `json:"network,omitempty"` + + // Disk Type Thin specifies if thin disks should be use instead of thick + DiskType DiskType `json:"diskType,omitempty"` }