code: func Create(c *govmomi.Client, f *object.Folder, s types.VirtualMachineConfigSpec, p *object.ResourcePool, h *object.HostSystem) (*object.VirtualMachine, error) {
  	log.Printf("[DEBUG] Creating virtual machine %q", fmt.Sprintf("%s/%s", f.InventoryPath, s.Name))
  	ctx, cancel := context.WithTimeout(context.Background(), provider.DefaultAPITimeout)
  	defer cancel()
  	var task *object.Task
  	// Check to see if the resource pool is a vApp
  	vc, err := vappcontainer.FromID(c, p.Reference().Value)
  	if err != nil {
  		if !viapi.IsManagedObjectNotFoundError(err) {
  			return nil, err
  		}
  		task, err = f.CreateVM(ctx, s, p, h)
  	} else {
  		task, err = vc.CreateChildVM(ctx, s, h)
  	}
  	if err != nil {
  		return nil, err
  	}
  	tctx, tcancel := context.WithTimeout(context.Background(), provider.DefaultAPITimeout)
  	defer tcancel()
  	result, err := task.WaitForResult(tctx, nil)
  	if err != nil {
  		return nil, err
  	}
  	log.Printf("[DEBUG] Virtual machine %q: creation complete (MOID: %q)", fmt.Sprintf("%s/%s", f.InventoryPath, s.Name), result.Result.(types.ManagedObjectReference).Value)
  	return FromMOID(c, result.Result.(types.ManagedObjectReference).Value)
  }
docs: // Create wraps the creation of a virtual machine and the subsequent waiting of
  // the task. A higher-level virtual machine object is returned.