From d49e401e94effb5efbd3648893f0a11846cfd38f Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 18 Sep 2023 20:52:55 -0700 Subject: [PATCH] vcsim: set HostSystem.Config.Host Fixes #3221 --- simulator/cluster_compute_resource.go | 1 + simulator/host_system.go | 1 + simulator/host_system_test.go | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/simulator/cluster_compute_resource.go b/simulator/cluster_compute_resource.go index abe001665..4a1579d3e 100644 --- a/simulator/cluster_compute_resource.go +++ b/simulator/cluster_compute_resource.go @@ -70,6 +70,7 @@ func (add *addHost) Run(task *Task) (types.AnyType, types.BaseMethodFault) { task.ctx.Map.PutEntity(cr, task.ctx.Map.NewEntity(host)) host.Summary.Host = &host.Self + host.Config.Host = host.Self cr.Host = append(cr.Host, host.Reference()) addComputeResource(cr.Summary.GetComputeResourceSummary(), host) diff --git a/simulator/host_system.go b/simulator/host_system.go index f8cd3fe7c..fd88cb497 100644 --- a/simulator/host_system.go +++ b/simulator/host_system.go @@ -486,6 +486,7 @@ func CreateStandaloneHost(ctx *Context, f *Folder, spec types.HostConnectSpec) ( ctx.Map.PutEntity(cr, ctx.Map.NewEntity(host)) host.Summary.Host = &host.Self + host.Config.Host = host.Self ctx.Map.PutEntity(cr, ctx.Map.NewEntity(pool)) diff --git a/simulator/host_system_test.go b/simulator/host_system_test.go index 99e61b2c4..04737d65f 100644 --- a/simulator/host_system_test.go +++ b/simulator/host_system_test.go @@ -26,6 +26,7 @@ import ( "github.com/vmware/govmomi/find" "github.com/vmware/govmomi/object" "github.com/vmware/govmomi/simulator/esx" + "github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25/types" ) @@ -70,6 +71,18 @@ func TestDefaultESX(t *testing.T) { } } +func TestDefaultVPX(t *testing.T) { + Test(func(ctx context.Context, c *vim25.Client) { + for _, e := range Map.All("HostSystem") { + host := e.(*HostSystem) + // issue #3221 + if host.Config.Host != host.Self { + t.Errorf("config.host=%s", host.Config.Host) + } + } + }) +} + func TestMaintenanceMode(t *testing.T) { ctx := context.Background() m := ESX()