Merge pull request #6355 from godmodelabs/vsphere-disable-customization

provider/vsphere: Add setting to skip customization
This commit is contained in:
James Nugent 2016-04-29 13:06:02 -05:00
commit 9c85c2ed47
2 changed files with 26 additions and 9 deletions

View File

@ -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))
@ -1575,16 +1587,20 @@ func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error {
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")
}
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)

View File

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