-
Notifications
You must be signed in to change notification settings - Fork 33
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
Conversation
Fixed cap Do not wait for BootAfterCreate false Added bootaftercreate documentation Suppress bootaftercreate changes after creation Added note for wait_on_ip with bootaftercreate
Somewhat related to #263 |
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.
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.", |
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 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.
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 |
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.
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.
@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. |
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