-
Notifications
You must be signed in to change notification settings - Fork 912
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
govc: Add an unreleased folder.place command for PlaceVMsXCluster #3590
Conversation
09ecea6
to
024b95b
Compare
There was a problem hiding this 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
} | ||
|
||
if vm == nil { | ||
return errors.New("please specify a vm") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
ResourcePools: refs, | ||
PlacementType: cmd.placementType, | ||
VmPlacementSpecs: vmPlacementSpecs, | ||
HostRecommRequired: &t, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
cmd.OutputFlag, ctx = flags.NewOutputFlag(ctx) | ||
cmd.OutputFlag.Register(ctx, f) | ||
|
||
f.Var(&cmd.resourcePool, "rp", "Resource Pools to use for placement.") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
for _, fault := range pfault.Faults { | ||
err := res.placementFault(w, pfault, &fault) | ||
if err != nil { | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return err
There was a problem hiding this comment.
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.
govc/folder/place.go
Outdated
if reconfigureAction, ok := action.(*types.ClusterClusterReconfigurePlacementAction); ok { | ||
err := res.reconfigurePlacementAction(w, pinfo, reconfigureAction) | ||
if err != nil { | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return err
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
vimClient *vim25.Client | ||
soapClient *soap.Client | ||
ctx context.Context | ||
dc *flags.DatacenterFlag |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
type placementResult struct { | ||
Result *types.PlaceVmsXClusterResult `json:"result,omitempty"` | ||
vimClient *vim25.Client | ||
soapClient *soap.Client |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
024b95b
to
0920911
Compare
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
0920911
to
831b722
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks @derekbeard !
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