vsphere/distributed_virtual_switch_helper.go
func upgradeDVS(client *govmomi.Client, dvs *object.VmwareDistributedVirtualSwitch, version string) error {
	req := &types.PerformDvsProductSpecOperation_Task{
		This:      dvs.Reference(),
		Operation: "upgrade",
		ProductSpec: &types.DistributedVirtualSwitchProductSpec{
			Version: version,
		},
	}

	ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer cancel()
	resp, err := methods.PerformDvsProductSpecOperation_Task(ctx, client, req)
	if err != nil {
		return err
	}
	task := object.NewTask(client.Client, resp.Returnval)
	tctx, tcancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer tcancel()
	if err := task.Wait(tctx); err != nil {
		return err
	}

	return nil
}
func upgradeDVS(client *govmomi.Client, dvs *object.VmwareDistributedVirtualSwitch, version string) error {
	req := &types.PerformDvsProductSpecOperation_Task{
		This:      dvs.Reference(),
		Operation: "upgrade",
		ProductSpec: &types.DistributedVirtualSwitchProductSpec{
			Version: version,
		},
	}

	ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer cancel()
	resp, err := methods.PerformDvsProductSpecOperation_Task(ctx, client, req)
	if err != nil {
		return err
	}
	task := object.NewTask(client.Client, resp.Returnval)
	tctx, tcancel := context.WithTimeout(context.Background(), defaultAPITimeout)
	defer tcancel()
	if err := task.Wait(tctx); err != nil {
		return err
	}

	return nil
}
// upgradeDVS upgrades a DVS to a specific version. Downgrades are not
// supported and will result in an error. This should be checked before running
// this function.