Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/vsphere: Setting to skip customization #6355

Merged
merged 1 commit into from
Apr 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions builtin/providers/vsphere/resource_vsphere_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ type virtualMachine struct {
dnsServers []string
bootableVmdk bool
linkedClone bool
skipCustomization bool
windowsOptionalConfig windowsOptConfig
customConfigurations map[string](types.AnyType)
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -1568,16 +1580,20 @@ func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error {
return err
}

taskb, err := newVM.Customize(context.TODO(), customSpec)
if err != nil {
return err
}

_, err = taskb.WaitForResult(context.TODO(), nil)
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")
}
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down