provider/vSphere - Add DiskEnableUUID option (#7088)

Since the custom_configuration_parameters can't take dots, we cannot
set 'disk.EnableUUID'.  This adds a parameter for this options that gets
added to a configSpec. This option causes the vm to mount disks by uuid
on the guest OS.
This commit is contained in:
dkalleg 2016-06-09 01:19:10 -07:00 committed by Paul Stack
parent 946cbafb75
commit fb6f2bc750
3 changed files with 21 additions and 2 deletions

View File

@ -88,6 +88,7 @@ type virtualMachine struct {
hasBootableVmdk bool hasBootableVmdk bool
linkedClone bool linkedClone bool
skipCustomization bool skipCustomization bool
enableDiskUUID bool
windowsOptionalConfig windowsOptConfig windowsOptionalConfig windowsOptConfig
customConfigurations map[string](types.AnyType) customConfigurations map[string](types.AnyType)
} }
@ -210,11 +211,19 @@ func resourceVSphereVirtualMachine() *schema.Resource {
Default: false, Default: false,
}, },
"enable_disk_uuid": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: false,
},
"custom_configuration_parameters": &schema.Schema{ "custom_configuration_parameters": &schema.Schema{
Type: schema.TypeMap, Type: schema.TypeMap,
Optional: true, Optional: true,
ForceNew: true, ForceNew: true,
}, },
"windows_opt_config": &schema.Schema{ "windows_opt_config": &schema.Schema{
Type: schema.TypeList, Type: schema.TypeList,
Optional: true, Optional: true,
@ -663,6 +672,10 @@ func resourceVSphereVirtualMachineCreate(d *schema.ResourceData, meta interface{
vm.skipCustomization = v.(bool) vm.skipCustomization = v.(bool)
} }
if v, ok := d.GetOk("enable_disk_uuid"); ok {
vm.enableDiskUUID = v.(bool)
}
if raw, ok := d.GetOk("dns_suffixes"); ok { if raw, ok := d.GetOk("dns_suffixes"); ok {
for _, v := range raw.([]interface{}) { for _, v := range raw.([]interface{}) {
vm.dnsSuffixes = append(vm.dnsSuffixes, v.(string)) vm.dnsSuffixes = append(vm.dnsSuffixes, v.(string))
@ -1524,6 +1537,9 @@ func (vm *virtualMachine) setupVirtualMachine(c *govmomi.Client) error {
MemoryAllocation: &types.ResourceAllocationInfo{ MemoryAllocation: &types.ResourceAllocationInfo{
Reservation: vm.memoryAllocation.reservation, Reservation: vm.memoryAllocation.reservation,
}, },
Flags: &types.VirtualMachineFlagInfo{
DiskUuidEnabled: &vm.enableDiskUUID,
},
} }
if vm.template == "" { if vm.template == "" {
configSpec.GuestId = "otherLinux64Guest" configSpec.GuestId = "otherLinux64Guest"

View File

@ -6,6 +6,8 @@ import (
"os" "os"
"testing" "testing"
"path/filepath"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
"github.com/vmware/govmomi" "github.com/vmware/govmomi"
@ -15,7 +17,6 @@ import (
"github.com/vmware/govmomi/vim25/mo" "github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types" "github.com/vmware/govmomi/vim25/types"
"golang.org/x/net/context" "golang.org/x/net/context"
"path/filepath"
) )
/////// ///////
@ -410,7 +411,7 @@ resource "vsphere_virtual_machine" "car" {
"car" = "ferrari" "car" = "ferrari"
"num" = 42 "num" = 42
} }
enable_disk_uuid = true
` `
func TestAccVSphereVirtualMachine_custom_configs(t *testing.T) { func TestAccVSphereVirtualMachine_custom_configs(t *testing.T) {
@ -439,6 +440,7 @@ func TestAccVSphereVirtualMachine_custom_configs(t *testing.T) {
resource.TestCheckResourceAttr(vmName, "custom_configuration_parameters.foo", "bar"), resource.TestCheckResourceAttr(vmName, "custom_configuration_parameters.foo", "bar"),
resource.TestCheckResourceAttr(vmName, "custom_configuration_parameters.car", "ferrari"), resource.TestCheckResourceAttr(vmName, "custom_configuration_parameters.car", "ferrari"),
resource.TestCheckResourceAttr(vmName, "custom_configuration_parameters.num", "42"), resource.TestCheckResourceAttr(vmName, "custom_configuration_parameters.num", "42"),
resource.TestCheckResourceAttr(vmName, "enable_disk_uuid", "true"),
), ),
}, },
}, },

View File

@ -78,6 +78,7 @@ The following arguments are supported:
* `cdrom` - (Optional) Configures a CDROM device and mounts an image as its media; see [CDROM](#cdrom) below for more details. * `cdrom` - (Optional) Configures a CDROM device and mounts an image as its media; see [CDROM](#cdrom) below for more details.
* `windows_opt_config` - (Optional) Extra options for clones of Windows machines. * `windows_opt_config` - (Optional) Extra options for clones of Windows machines.
* `linked_clone` - (Optional) Specifies if the new machine is a [linked clone](https://www.vmware.com/support/ws5/doc/ws_clone_overview.html#wp1036396) of another machine or not. * `linked_clone` - (Optional) Specifies if the new machine is a [linked clone](https://www.vmware.com/support/ws5/doc/ws_clone_overview.html#wp1036396) of another machine or not.
* `enable_disk_uuid` - (Optional) This option causes the vm to mount disks by uuid on the guest OS.
* `custom_configuration_parameters` - (Optional) Map of values that is set as virtual machine custom configurations. * `custom_configuration_parameters` - (Optional) Map of values that is set as virtual machine custom configurations.
* `skip_customization` - (Optional) skip virtual machine customization (useful if OS is not in the guest OS support matrix of VMware like "other3xLinux64Guest"). * `skip_customization` - (Optional) skip virtual machine customization (useful if OS is not in the guest OS support matrix of VMware like "other3xLinux64Guest").