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

fix: Network is not started if inactive #1095 #1097

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
14 changes: 14 additions & 0 deletions libvirt/resource_libvirt_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ func resourceLibvirtNetwork() *schema.Resource {
Required: false,
Computed: true,
},
"active": {
Type: schema.TypeBool,
Optional: true,
Default: true,
ForceNew: false,
Required: false,
},
"dns": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -516,6 +523,13 @@ func resourceLibvirtNetworkRead(ctx context.Context, d *schema.ResourceData, met
return diag.Errorf("error retrieving libvirt network %s", err)
}

activeInt, err := virConn.NetworkIsActive(network)
if err != nil {
return diag.Errorf("error when getting network %s status during read: %s", network.Name, err)
}

d.Set("active", int2bool(int(activeInt)))

networkDef, err := getXMLNetworkDefFromLibvirt(virConn, network)
if err != nil {
return diag.Errorf("error reading libvirt network XML description: %s", err)
Expand Down