nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: vmware/govmomi
Pull request #2312 (2021-03-06 17:44:27)

govc: fix vm.migrate search index flags
vm.migrate combines the use of VM SearchFlag (-vm.uuid, -vm.path, etc) with HostSystemFlag.
When a -vm.* flag is used, it causes the error:

  expected HostSystem entity, got VirtualMachine

Add a check for the SearchFlag type to avoid this.


Patch:
diff --git a/govc/flags/host_system.go b/govc/flags/host_system.go
index 56dba96c..f8704def 100644
--- a/govc/flags/host_system.go
+++ b/govc/flags/host_system.go
@@ -86,7 +86,7 @@ func (flag *HostSystemFlag) HostSystemIfSpecified() (*object.HostSystem, error)
 	}
 
 	// Use search flags if specified.
-	if flag.SearchFlag.IsSet() {
+	if flag.SearchFlag.IsSet() && flag.SearchFlag.t == SearchHosts {
 		host, err := flag.SearchFlag.HostSystem()
 		if err != nil {
 			return nil, err
diff --git a/vim25/soap/error.go b/vim25/soap/error.go
index 1e150873..46111556 100644
--- a/vim25/soap/error.go
+++ b/vim25/soap/error.go
@@ -17,7 +17,6 @@ limitations under the License.
 package soap
 
 import (
-	"encoding/json"
 	"fmt"
 	"reflect"
 
@@ -50,15 +49,6 @@ func (s soapFaultError) Error() string {
 	return fmt.Sprintf("%s: %s", s.fault.Code, msg)
 }
 
-func (s soapFaultError) MarshalJSON() ([]byte, error) {
-	out := struct {
-		Fault *Fault
-	}{
-		Fault: s.fault,
-	}
-	return json.Marshal(out)
-}
-
 type vimFaultError struct {
 	fault types.BaseMethodFault
 }


Test patch:
diff --git a/govc/test/vm.bats b/govc/test/vm.bats
index d9d28347..e2067a40 100755
--- a/govc/test/vm.bats
+++ b/govc/test/vm.bats
@@ -817,7 +817,8 @@ load test_helper
   run govc object.collect -s "vm/$vm" parent
   assert_success
 
-  run govc vm.migrate -folder vm/new-folder "$vm"
+  uuid=$(govc object.collect -s "vm/$vm" config.uuid)
+  run govc vm.migrate -folder vm/new-folder -vm.uuid "$uuid"
   assert_success
 
   run govc object.collect -s "vm/new-folder/$vm" parent
Repository: vmware/govmomi
Pull request #2363 (2021-04-15 22:45:34)

govc: add vm.customize -dns-suffix flag
Issue #2293


Patch:
diff --git a/govc/vm/customize.go b/govc/vm/customize.go
index c726dbc1..356ab6f2 100644
--- a/govc/vm/customize.go
+++ b/govc/vm/customize.go
@@ -43,6 +43,7 @@ type customize struct {
 	gateway   flags.StringList
 	netmask   flags.StringList
 	dnsserver flags.StringList
+	dnssuffix flags.StringList
 	kind      string
 }
 
@@ -69,8 +70,10 @@ func (cmd *customize) Register(ctx context.Context, f *flag.FlagSet) {
 	cmd.gateway = nil
 	f.Var(&cmd.netmask, "netmask", "Netmask")
 	cmd.netmask = nil
-	f.Var(&cmd.dnsserver, "dns-server", "DNS server")
+	f.Var(&cmd.dnsserver, "dns-server", "DNS server list")
 	cmd.dnsserver = nil
+	f.Var(&cmd.dnssuffix, "dns-suffix", "DNS suffix list")
+	cmd.dnssuffix = nil
 	f.StringVar(&cmd.kind, "type", "Linux", "Customization type if spec NAME is not specified (Linux|Windows)")
 }
 
@@ -86,6 +89,8 @@ Optionally specify a customization spec NAME.
 The '-ip', '-netmask' and '-gateway' flags are for static IP configuration.
 If the VM has multiple NICs, an '-ip' and '-netmask' must be specified for each.
 
+The '-dns-server' and '-dns-suffix' flags can be specified multiple times.
+
 Windows -tz value requires the Index (hex): https://support.microsoft.com/en-us/help/973627/microsoft-time-zone-index-values
 
 Examples:
@@ -223,6 +228,8 @@ func (cmd *customize) Run(ctx context.Context, f *flag.FlagSet) error {
 		}
 	}
 
+	spec.GlobalIPSettings.DnsSuffixList = cmd.dnssuffix
+
 	if cmd.prefix.Base != "" {
 		if isWindows {
 			sysprep.UserData.ComputerName = &cmd.prefix


Test patch:
diff --git a/govc/test/vm.bats b/govc/test/vm.bats
index e2067a40..ad6ec563 100755
--- a/govc/test/vm.bats
+++ b/govc/test/vm.bats
@@ -1036,7 +1036,7 @@ load test_helper
   run govc vm.customize -vm DC0_H0_VM0 -type Linux
   assert_failure # no -ip specified
 
-  run govc vm.customize -vm DC0_H0_VM0 -ip 10.0.0.45 -netmask 255.255.0.0 -type Linux
+  run govc vm.customize -vm DC0_H0_VM0 -ip 10.0.0.45 -netmask 255.255.0.0 -type Linux -dns-server 1.1.1.1 -dns-suffix example.com
   assert_success
 
   run govc vm.power -on DC0_H0_VM0