Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

govc: Add an unreleased folder.place command for PlaceVMsXCluster #3590

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

derekbeard
Copy link
Contributor

This change adds an unreleased govc command to exercise the cross-cluster placement engine via folder.PlaceVmsXCluster. This command is limited to supporting the only a relocate placement type but will be extended to support createAndPowerOn and reconfigure in the future. Bats tests are added to perform basic validation of the new command.

This change also fixes the PlaceVMSXCluster action types to match the types returned by the VIM API, specifically:
ClusterReconfigurePlacementAction => ClusterClusterReconfigurePlacementAction ClusterRelocatePlacementAction => ClusterClusterRelocatePlacementAction

This change also improves the simulator to return the appropriate action types based off of the placementType and improves the tests to validate the action type.

Testing Done:
./govc/test/folder.bats
go test -v -count=1 ./simulator -run TestPlaceVmsXClusterCreateAndPowerOn
go test -v -count=1 ./simulator -run TestPlaceVmsXClusterReconfigure
go test -v -count=1 ./simulator -run TestPlaceVmsXClusterRelocate

dougm
dougm previously approved these changes Oct 10, 2024
Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @derekbeard , looks good, some minor requests and suggestions.

govc/folder/place.go Outdated Show resolved Hide resolved
}

if vm == nil {
return errors.New("please specify a vm")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can just return flag.ErrHelp here, outputs the command -h help.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

govc/folder/place.go Outdated Show resolved Hide resolved
ResourcePools: refs,
PlacementType: cmd.placementType,
VmPlacementSpecs: vmPlacementSpecs,
HostRecommRequired: &t,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have types.NewBool(true) helper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

cmd.OutputFlag, ctx = flags.NewOutputFlag(ctx)
cmd.OutputFlag.Register(ctx, f)

f.Var(&cmd.resourcePool, "rp", "Resource Pools to use for placement.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use "pool" for the flag name as we do in other commands?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

for _, fault := range pfault.Faults {
err := res.placementFault(w, pfault, &fault)
if err != nil {
return nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return err

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, late night coding. Ack.

if reconfigureAction, ok := action.(*types.ClusterClusterReconfigurePlacementAction); ok {
err := res.reconfigurePlacementAction(w, pinfo, reconfigureAction)
if err != nil {
return nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return err

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

PlacementType: string(types.PlaceVmsXClusterSpecPlacementTypeRelocate),
ResourcePools: test.poolMoRefs,
PlacementType: string(types.PlaceVmsXClusterSpecPlacementTypeRelocate),
HostRecommRequired: &truebool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use types.NewBool(true)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

vimClient *vim25.Client
soapClient *soap.Client
ctx context.Context
dc *flags.DatacenterFlag
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like dc field is unused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

type placementResult struct {
Result *types.PlaceVmsXClusterResult `json:"result,omitempty"`
vimClient *vim25.Client
soapClient *soap.Client
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like soapClient field is unused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

This change adds an unreleased govc command to exercise the
cross-cluster placement engine via folder.PlaceVmsXCluster.  This
command is limited to supporting the only a relocate placement type but
will be extended to support createAndPowerOn and reconfigure in the
future.  Bats tests are added to perform basic validation of the new
command.

This change also fixes the PlaceVMSXCluster action types to match the
types returned by the VIM API, specifically:
ClusterReconfigurePlacementAction => ClusterClusterReconfigurePlacementAction
ClusterRelocatePlacementAction => ClusterClusterRelocatePlacementAction

This change also improves the simulator to return the appropriate action
types based off of the placementType and improves the tests to validate
the action type.

Testing Done:
./govc/test/folder.bats
go test -v -count=1 ./simulator -run TestPlaceVmsXClusterCreateAndPowerOn
go test -v -count=1 ./simulator -run TestPlaceVmsXClusterReconfigure
go test -v -count=1 ./simulator -run TestPlaceVmsXClusterRelocate
Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks @derekbeard !

@derekbeard derekbeard merged commit eeedeaf into vmware:main Oct 11, 2024
10 checks passed
@derekbeard derekbeard deleted the govc-folder-placevmsxcluster branch October 11, 2024 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants