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

Added bootaftercreate option #276

Closed
wants to merge 2 commits into from

Conversation

ravager-dk
Copy link
Contributor

Added new bootaftercreate optional argument

Fixed cap

Do not wait for BootAfterCreate false

Added bootaftercreate documentation

Suppress bootaftercreate changes after creation

Added note for wait_on_ip with bootaftercreate

Fixed cap

Do not wait for BootAfterCreate false

Added bootaftercreate documentation

Suppress bootaftercreate changes after creation

Added note for wait_on_ip with bootaftercreate
@ravager-dk
Copy link
Contributor Author

Somewhat related to #263

Copy link
Collaborator

@ddelnano ddelnano left a comment

Choose a reason for hiding this comment

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

I still think we should proceed with the full fledged power_state support I mentioned here (#263 (comment)), but I still wanted to provide feedback and appreciate your effort on this!

"bootaftercreate": &schema.Schema{
Type: schema.TypeBool,
Default: true,
Description: "Whether Terraform should boot the VM after creation. Defaults to true.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

We are currently partially migrated to tfplugindocs (see #256 for details), but that means that the Description string here should match what is in the docs/resources/vm.md file. That will make the eventual migration easier.

Comment on lines +554 to +571
if !bootAfterCreate {
refreshFn := func() (result interface{}, state string, err error) {
vm, err := c.GetVm(Vm{Id: id})

if err != nil {
return vm, "", err
}

return vm, vm.PowerState, nil
}
stateConf := &StateChangeConf{
Pending: []string{"Running"},
Refresh: refreshFn,
Target: []string{"Halted", "Stopped"},
Timeout: timeout,
}
_, err := stateConf.WaitForState()
return err
Copy link
Collaborator

@ddelnano ddelnano Oct 24, 2023

Choose a reason for hiding this comment

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

This function is already a mess (which is entirely my fault 🙃), so I think in order to support managing power_state we need to leave this better than it currently is. My proposal for that was what I did in my partially implemented power_state change here.

Also from a quick glance, Stopped doesn't seem to be a real state (source). So references to that should ideally be cleaned up. That is dependent on checking the XAPI source to verify that those are a complete set of power states.

@ddelnano
Copy link
Collaborator

@ravager-dk I'm closing this since I believe #281 and #278 accomplished what you were hoping for. Please let me know if that isn't the case or you have more comments to discuss.

@ddelnano ddelnano closed this Dec 28, 2023
@ravager-dk ravager-dk deleted the Boot-on-create branch December 28, 2023 15:41
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