1
0
mirror of https://github.com/openshift/installer.git synced 2026-02-05 15:47:14 +01:00

Make Disk Type as Enum for Vpshere

This commit is contained in:
ayesha54
2021-11-09 14:05:24 +01:00
parent 02006136b8
commit b06e40517c
7 changed files with 49 additions and 31 deletions

View File

@@ -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

View File

@@ -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" {

View File

@@ -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"
}

View File

@@ -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

View File

@@ -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.

View File

@@ -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

View File

@@ -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"`
}