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

Simple fix for the running attribute when switched to false from an initial state of true #1082

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions libvirt/resource_libvirt_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ func resourceLibvirtDomainCreate(ctx context.Context, d *schema.ResourceData, me
}
}

// We save runnig state to not mix what we have and what we want
// We save running state to not mix what we have and what we want
requiredStatus := d.Get("running")

if diag := resourceLibvirtDomainRead(ctx, d, meta); diag.HasError() {
Expand Down Expand Up @@ -691,7 +691,7 @@ func resourceLibvirtDomainUpdate(ctx context.Context, d *schema.ResourceData, me
return diag.FromErr(err)
}

if !domainRunningNow {
if !domainRunningNow && d.Get("running").(bool) {
err = virConn.DomainCreate(domain)
if err != nil {
return diag.Errorf("error creating libvirt domain: %s", err)
Expand Down Expand Up @@ -772,6 +772,10 @@ func resourceLibvirtDomainUpdate(ctx context.Context, d *schema.ResourceData, me
}
}

if err := destroyDomainByUserRequest(virConn, d, domain); err != nil {
return diag.FromErr(err)
}

return nil
}

Expand Down
Loading