Skip to content

Commit 310516e

Browse files
committed
fix: govc: disambiguate vm/host search flags in vm.migrate
PR #2850 fix a search flag issue with the vm.clone command, but caused an issue with the vm.migrate command. Rather than embed the SearchFlag directly, vm.migrate needs to embed the VirtualMachineFlag Issue #2849
1 parent 0f1f07e commit 310516e

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

govc/USAGE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5905,6 +5905,7 @@ Options:
59055905
-host= Host system [GOVC_HOST]
59065906
-pool= Resource pool [GOVC_RESOURCE_POOL]
59075907
-priority=defaultPriority The task priority
5908+
-vm= Virtual machine [GOVC_VM]
59085909
```
59095910

59105911
## vm.network.add

govc/test/vm.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ load test_helper
770770
vm="DC0_H0_VM0"
771771
clone=$(new_id)
772772

773-
run govc vm.clone -vm "$vm" -annotation $$ "$clone"
773+
run govc vm.clone -vm "$vm" -host.ipath /DC0/host/DC0_C0/DC0_C0_H0 -annotation $$ "$clone"
774774
assert_success
775775

776776
backing=$(govc device.info -json -vm "$clone" disk-* | jq .Devices[].Backing)

govc/vm/migrate.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type migrate struct {
3232
*flags.ResourcePoolFlag
3333
*flags.HostSystemFlag
3434
*flags.DatastoreFlag
35-
*flags.SearchFlag
35+
*flags.VirtualMachineFlag
3636

3737
priority types.VirtualMachineMovePriority
3838
spec types.VirtualMachineRelocateSpec
@@ -46,8 +46,8 @@ func (cmd *migrate) Register(ctx context.Context, f *flag.FlagSet) {
4646
cmd.FolderFlag, ctx = flags.NewFolderFlag(ctx)
4747
cmd.FolderFlag.Register(ctx, f)
4848

49-
cmd.SearchFlag, ctx = flags.NewSearchFlag(ctx, flags.SearchVirtualMachines)
50-
cmd.SearchFlag.Register(ctx, f)
49+
cmd.VirtualMachineFlag, ctx = flags.NewVirtualMachineFlag(ctx)
50+
cmd.VirtualMachineFlag.Register(ctx, f)
5151

5252
cmd.ResourcePoolFlag, ctx = flags.NewResourcePoolFlag(ctx)
5353
cmd.ResourcePoolFlag.Register(ctx, f)
@@ -65,6 +65,9 @@ func (cmd *migrate) Process(ctx context.Context) error {
6565
if err := cmd.FolderFlag.Process(ctx); err != nil {
6666
return err
6767
}
68+
if err := cmd.VirtualMachineFlag.Process(ctx); err != nil {
69+
return err
70+
}
6871
if err := cmd.ResourcePoolFlag.Process(ctx); err != nil {
6972
return err
7073
}
@@ -109,7 +112,7 @@ func (cmd *migrate) relocate(ctx context.Context, vm *object.VirtualMachine) err
109112
}
110113

111114
func (cmd *migrate) Run(ctx context.Context, f *flag.FlagSet) error {
112-
vms, err := cmd.VirtualMachines(f.Args())
115+
vms, err := cmd.VirtualMachineFlag.VirtualMachines(f.Args())
113116
if err != nil {
114117
return err
115118
}

0 commit comments

Comments
 (0)