Skip to content

Commit

Permalink
Merge pull request openshift#7737 from jcpowermac/OCPBUGS-23376
Browse files Browse the repository at this point in the history
OCPBUGS-23376: vSphere - when using RP network path is incorrect
  • Loading branch information
openshift-merge-bot[bot] authored Nov 21, 2023
2 parents ca12ca2 + f4ebd5d commit 9b77312
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pkg/asset/cluster/tfvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
for i, c := range controlPlanes {
var clusterMo mo.ClusterComputeResource
controlPlaneConfigs[i] = c.Spec.ProviderSpec.Value.Object.(*machinev1beta1.VSphereMachineProviderSpec)

rpObj, err := finder.ResourcePool(ctx, controlPlaneConfigs[i].Workspace.ResourcePool)
if err != nil {
return err
Expand All @@ -957,16 +958,23 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
return err
}

clusterObj := object.NewClusterComputeResource(vim25Client, clusterRef.Reference())
err = clusterObj.Properties(ctx, clusterRef.Reference(), []string{"name", "summary"}, &clusterMo)
// When using finder.ObjectReference the InventoryPath is defined
// NewClusterComputeResource I don't believe assigns that value.
clusterObjRef, err := finder.ObjectReference(ctx, clusterRef.Reference())
if err != nil {
return err
}

clusterPath := strings.SplitAfter(controlPlaneConfigs[i].Workspace.ResourcePool, clusterMo.Name)

networkPath := path.Join(clusterPath[0], controlPlaneConfigs[i].Network.Devices[0].NetworkName)
clusterObj, ok := clusterObjRef.(*object.ClusterComputeResource)
if !ok {
return errors.New("unable to convert cluster object reference to object cluster compute resource")
}
err = clusterObj.Properties(ctx, clusterRef.Reference(), []string{"name", "summary"}, &clusterMo)
if err != nil {
return err
}

networkPath := path.Join(clusterObj.InventoryPath, controlPlaneConfigs[i].Network.Devices[0].NetworkName)
netObj, err := finder.Network(ctx, networkPath)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions pkg/asset/installconfig/vsphere/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Finder interface {
VirtualMachine(ctx context.Context, path string) (*object.VirtualMachine, error)
VirtualMachineList(ctx context.Context, path string) ([]*object.VirtualMachine, error)
HostSystemList(ctx context.Context, path string) ([]*object.HostSystem, error)
ObjectReference(ctx context.Context, ref types.ManagedObjectReference) (object.Reference, error)
}

// NewFinder creates a new client that conforms with the Finder interface and returns a
Expand Down

0 comments on commit 9b77312

Please sign in to comment.