diff --git a/data/data/install.openshift.io_installconfigs.yaml b/data/data/install.openshift.io_installconfigs.yaml index a3a7474f84..a5120a651d 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 @@ -2133,9 +2137,6 @@ spec: vCenter: description: VCenter is the domain name or IP address of the vCenter. type: string - diskType: - description: DiskType is the name of the disk provisioning type for vsphere, for e.g eagerZeroedThick or thin, by default it will be thick. - type: string required: - datacenter - defaultDatastore diff --git a/data/data/vsphere/pre-bootstrap/main.tf b/data/data/vsphere/pre-bootstrap/main.tf index e04e1b40f4..984c15d3a3 100644 --- a/data/data/vsphere/pre-bootstrap/main.tf +++ b/data/data/vsphere/pre-bootstrap/main.tf @@ -50,7 +50,7 @@ resource "vsphereprivate_import_ova" "import" { network = var.vsphere_network folder = local.folder tag = vsphere_tag.tag.id - diskType = var.disk_type + 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 95107eb09f..09bef4a846 100644 --- a/data/data/vsphere/variables-vsphere.tf +++ b/data/data/vsphere/variables-vsphere.tf @@ -76,6 +76,7 @@ variable "vsphere_control_plane_num_cpus" { variable "vsphere_control_plane_cores_per_socket" { type = number } -variable "disk_type" { - type = string +variable "vsphere_disk_type" { + type = string + default = "eagerZeroedThick" } diff --git a/docs/user/vsphere/customization.md b/docs/user/vsphere/customization.md index e2b67e4aec..18cc1e332a 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/terraform/exec/plugins/vsphereprivate/resource_vsphereprivate_import_ova.go b/pkg/terraform/exec/plugins/vsphereprivate/resource_vsphereprivate_import_ova.go index a311c21481..f98ac3fe40 100644 --- a/pkg/terraform/exec/plugins/vsphereprivate/resource_vsphereprivate_import_ova.go +++ b/pkg/terraform/exec/plugins/vsphereprivate/resource_vsphereprivate_import_ova.go @@ -93,10 +93,10 @@ func resourceVSpherePrivateImportOva() *schema.Resource { ForceNew: true, ValidateFunc: validation.NoZeroValues, }, - "diskType": { + "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: false, + Required: true, ForceNew: true, }, }, @@ -356,12 +356,12 @@ func resourceVSpherePrivateImportOvaCreate(d *schema.ResourceData, meta interfac var diskType types.OvfCreateImportSpecParamsDiskProvisioningType - if d.Get("diskType").(string) == "thin" { + if d.Get("disk_type") == "thin" { diskType = types.OvfCreateImportSpecParamsDiskProvisioningTypeThin - } else if d.Get("diskType").(string) == "eagerZeroedThick" { - diskType = types.OvfCreateImportSpecParamsDiskProvisioningTypeEagerZeroedThick - } else { + } else if d.Get("disk_type") == "thick" { diskType = types.OvfCreateImportSpecParamsDiskProvisioningTypeThick + } else { + diskType = types.OvfCreateImportSpecParamsDiskProvisioningTypeEagerZeroedThick } // This is a very minimal spec for importing // an OVF. diff --git a/pkg/tfvars/vsphere/vsphere.go b/pkg/tfvars/vsphere/vsphere.go index 97a7f22d6e..a48f5fbaa3 100644 --- a/pkg/tfvars/vsphere/vsphere.go +++ b/pkg/tfvars/vsphere/vsphere.go @@ -8,25 +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"` - DiskType string `json:"disk_type"` + 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 @@ -37,7 +38,7 @@ type TFVarsSources struct { Cluster string ImageURL string PreexistingFolder bool - DiskType string + DiskType vsphere.DiskType } //TFVars generate vSphere-specific Terraform variables diff --git a/pkg/types/vsphere/platform.go b/pkg/types/vsphere/platform.go index 40c0fb16cd..4565a4b947 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"` @@ -49,5 +63,5 @@ type Platform struct { Network string `json:"network,omitempty"` // Disk Type Thin specifies if thin disks should be use instead of thick - DiskType string `json:"diskType,omitempty"` + DiskType DiskType `json:"diskType,omitempty"` }