From 5dbc4687a3742b684a321ca81c1a54329394a2d3 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 21 Apr 2016 17:53:08 +0200 Subject: [PATCH] added skip_customization setting --- .../resource_vsphere_virtual_machine.go | 34 ++++++++++++++----- .../vsphere/r/virtual_machine.html.markdown | 1 + 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go index 5984f29ff..ce8f11c71 100644 --- a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go +++ b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go @@ -84,6 +84,7 @@ type virtualMachine struct { dnsServers []string bootableVmdk bool linkedClone bool + skipCustomization bool windowsOptionalConfig windowsOptConfig customConfigurations map[string](types.AnyType) } @@ -196,6 +197,13 @@ func resourceVSphereVirtualMachine() *schema.Resource { ForceNew: true, }, + "skip_customization": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Default: false, + }, + "custom_configuration_parameters": &schema.Schema{ Type: schema.TypeMap, Optional: true, @@ -437,6 +445,10 @@ func resourceVSphereVirtualMachineCreate(d *schema.ResourceData, meta interface{ vm.linkedClone = v.(bool) } + if v, ok := d.GetOk("skip_customization"); ok { + vm.skipCustomization = v.(bool) + } + if raw, ok := d.GetOk("dns_suffixes"); ok { for _, v := range raw.([]interface{}) { vm.dnsSuffixes = append(vm.dnsSuffixes, v.(string)) @@ -1568,17 +1580,21 @@ func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error { return err } - taskb, err := newVM.Customize(context.TODO(), customSpec) - if err != nil { - return err + if vm.skipCustomization { + log.Printf("[DEBUG] VM customization skipped") + } else { + log.Printf("[DEBUG] VM customization starting") + taskb, err := newVM.Customize(context.TODO(), customSpec) + if err != nil { + return err + } + _, err = taskb.WaitForResult(context.TODO(), nil) + if err != nil { + return err + } + log.Printf("[DEBUG] VM customization finished") } - _, err = taskb.WaitForResult(context.TODO(), nil) - if err != nil { - return err - } - log.Printf("[DEBUG] VM customization finished") - for i := 1; i < len(vm.hardDisks); i++ { err = addHardDisk(newVM, vm.hardDisks[i].size, vm.hardDisks[i].iops, vm.hardDisks[i].initType, datastore, vm.hardDisks[i].vmdkPath) if err != nil { diff --git a/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown b/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown index 9027bbc36..1de12ddcd 100644 --- a/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown +++ b/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown @@ -80,6 +80,7 @@ The following arguments are supported: * `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. * `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"). The `network_interface` block supports: