0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-01 19:12:59 +00:00

fix(vm): timeout_start_vm is ignored (#978)

* fix(vm): `timeout_start_vm` is ignored

Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>

* fix: linter

Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>

---------

Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
Pavel Boldyrev 2024-01-27 21:49:32 -05:00 committed by GitHub
parent 0253eb9757
commit 625bdb696f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 3 deletions

View File

@ -334,7 +334,7 @@ func (c *Client) ShutdownVMAsync(ctx context.Context, d *ShutdownRequestBody) (*
// StartVM starts a virtual machine.
// Returns the task log if the VM had warnings at startup, or fails to start.
func (c *Client) StartVM(ctx context.Context, timeout int) ([]string, error) {
taskID, err := c.StartVMAsync(ctx)
taskID, err := c.StartVMAsync(ctx, timeout)
if err != nil {
return nil, err
}
@ -362,10 +362,13 @@ func (c *Client) StartVM(ctx context.Context, timeout int) ([]string, error) {
}
// StartVMAsync starts a virtual machine asynchronously.
func (c *Client) StartVMAsync(ctx context.Context) (*string, error) {
func (c *Client) StartVMAsync(ctx context.Context, timeout int) (*string, error) {
reqBody := &StartRequestBody{
TimeoutSeconds: &timeout,
}
resBody := &StartResponseBody{}
err := c.DoRequest(ctx, http.MethodPost, c.ExpandPath("status/start"), nil, resBody)
err := c.DoRequest(ctx, http.MethodPost, c.ExpandPath("status/start"), reqBody, resBody)
if err != nil {
return nil, fmt.Errorf("error starting VM: %w", err)
}

View File

@ -699,6 +699,19 @@ type ShutdownResponseBody struct {
Data *string `json:"data,omitempty"`
}
// StartRequestBody contains the body for a VM start request.
type StartRequestBody struct {
ForceCPU *string `json:"force-cpu,omitempty" url:"force-cpu,omitempty"`
Machine *string `json:"machine,omitempty" url:"machine,omitempty"`
MigrateFrom *string `json:"migratefrom,omitempty" url:"migratefrom,omitempty"`
MigrationNetwork *string `json:"migration_network,omitempty" url:"migration_network,omitempty"`
MigrationType *string `json:"migration_type,omitempty" url:"migration_type,omitempty"`
SkipLock *types.CustomBool `json:"skipLock,omitempty" url:"skipLock,omitempty,int"`
StateURI *string `json:"stateuri,omitempty" url:"stateuri,omitempty"`
TargetStorage *string `json:"targetstorage,omitempty" url:"targetstorage,omitempty"`
TimeoutSeconds *int `json:"timeout,omitempty" url:"timeout,omitempty"`
}
// StartResponseBody contains the body from a VM start response.
type StartResponseBody struct {
Data *string `json:"data,omitempty"`